Skip to content

Commit 194f4a1

Browse files
committed
document svdvals and interface
1 parent 6abe7df commit 194f4a1

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

src/stdlib_linalg.fypp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,12 +533,50 @@ module stdlib_linalg
533533
interface svdvals
534534
!! version: experimental
535535
!!
536+
!! Computes the singular values of a `real` or `complex` 2d matrix.
537+
!!
538+
!!### Summary
539+
!!
540+
!! Function interface for computing the array of singular values from the singular value decomposition
541+
!! of a `real` or `complex` 2d matrix.
542+
!!
536543
!!### Description
537544
!!
545+
!! This interface provides methods for computing the singular values a 2d matrix.
546+
!! Supported data types include `real` and `complex`. The function returns a `real` array of
547+
!! singular values, with size [min(m,n)].
538548
!!
549+
!!@note The solution is based on LAPACK's singular value decomposition `*GESDD` methods.
550+
!!@note BLAS/LAPACK backends do not currently support extended precision (``xdp``).
551+
!!
552+
!!### Example
553+
!!
554+
!!```fortran
555+
!! real(sp) :: a(2,3), s(2)
556+
!! a = reshape([3,2, 2,3, 2,-2],[2,3])
557+
!!
558+
!! s = svdvals(A)
559+
!! print *, 'singular values = ',s
560+
!!```
561+
!!
539562
#:for rk,rt,ri in RC_KINDS_TYPES
540563
#:if rk!="xdp"
541564
module function stdlib_linalg_svdvals_${ri}$(a,err) result(s)
565+
!!### Summary
566+
!! Compute singular values \(S \) from the singular-value decomposition of a matrix \( A = U \cdot S \cdot \V^T \).
567+
!!
568+
!!### Description
569+
!!
570+
!! This function returns the array of singular values from the singular value decomposition of a `real`
571+
!! or `complex` matrix \( A = U \cdot S \cdot V^T \).
572+
!!
573+
!! param: a Input matrix of size [m,n].
574+
!! param: err [optional] State return flag.
575+
!!
576+
!!### Return value
577+
!!
578+
!! param: s `real` array of size [min(m,n)] returning a list of singular values.
579+
!!
542580
!> Input matrix A[m,n]
543581
${rt}$, intent(in), target :: a(:,:)
544582
!> [optional] state return flag. On error if not requested, the code will stop

src/stdlib_linalg_svd.fypp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ submodule(stdlib_linalg) stdlib_linalg_svd
6363

6464
!> Singular values of matrix A
6565
module function stdlib_linalg_svdvals_${ri}$(a,err) result(s)
66+
!!### Summary
67+
!! Compute singular values \(S \) from the singular-value decomposition of a matrix \( A = U \cdot S \cdot \V^T \).
68+
!!
69+
!!### Description
70+
!!
71+
!! This function returns the array of singular values from the singular value decomposition of a `real`
72+
!! or `complex` matrix \( A = U \cdot S \cdot V^T \).
73+
!!
74+
!! param: a Input matrix of size [m,n].
75+
!! param: err [optional] State return flag.
76+
!!
77+
!!### Return value
78+
!!
79+
!! param: s `real` array of size [min(m,n)] returning a list of singular values.
80+
!!
6681
!> Input matrix A[m,n]
6782
${rt}$, intent(in), target :: a(:,:)
6883
!> [optional] state return flag. On error if not requested, the code will stop

0 commit comments

Comments
 (0)