You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/specs/stdlib_linalg.md
+89Lines changed: 89 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -797,3 +797,92 @@ Exceptions trigger an `error stop`.
797
797
```fortran
798
798
{!example/linalg/example_determinant2.f90!}
799
799
```
800
+
801
+
## `svd` - Compute the singular value decomposition of a 2d matrix.
802
+
803
+
### Status
804
+
805
+
Experimental
806
+
807
+
### Description
808
+
809
+
This subroutine computes the singular value decomposition of a `real` or `complex` 2d matrix \( A = U \cdot S \cdot \V^T \).
810
+
The solver is based on LAPACK's `*GESDD` backends.
811
+
812
+
Result vector `s` returns the array of singular values on the diagonal of \( S \).
813
+
If requested, `u` contains the left singular vectors, as columns of \( U \).
814
+
If requested, `vt` contains the right singular vectors, as rows of \( V^T \).
815
+
816
+
### Syntax
817
+
818
+
`call `[[stdlib_linalg(module):svd(interface)]]`(a, s, [, u, vt, overwrite_a, full_matrices, err])`
819
+
820
+
### Arguments
821
+
822
+
`a`: Shall be a rank-2 `real` or `complex` array containing the coefficient matrix of size `[m,n]`. It is an `intent(inout)` argument, but returns unchanged unless `overwrite_a=.true.`.
823
+
824
+
`s`: Shall be a rank-1 `real` array, returning the list of `k = min(m,n)` singular values. It is an `intent(inout)` argument.
825
+
826
+
`u` (optional): Shall be a rank-2 array of same kind as `a`, returning the left singular vectors of `a` as columns. Its size should be `[m,m]` unless `full_matrices=.false.`, in which case, it can be `[m,min(m,n)]`. It is an `intent(inout)` argument.
827
+
828
+
`vt` (optional): Shall be a rank-2 array of same kind as `a`, returning the right singular vectors of `a` as rows. Its size should be `[n,n]` unless `full_matrices=.false.`, in which case, it can be `[min(m,n),n]`. It is an `intent(inout)` argument.
829
+
830
+
`overwrite_a` (optional): Shall be an input `logical` flag. If `.true.`, input matrix `A` will be used as temporary storage and overwritten. This avoids internal data allocation. By default, `overwrite_a=.false.`. This is an `intent(in)` argument.
831
+
832
+
`full_matrices` (optional): Shall be an input `logical` flag. If `.true.` (default), matrices `u` and `vt` shall be full-sized. Otherwise, their secondary dimension can be resized to `min(m,n)`. See `u`, `v` for details.
833
+
834
+
`err` (optional): Shall be a `type(linalg_state_type)` value. This is an `intent(out)` argument.
835
+
836
+
### Return values
837
+
838
+
Returns an array `s` that contains the list of singular values of matrix `a`.
839
+
If requested, returns a rank-2 array `u` that contains the left singular values of `a` along its columns.
840
+
If requested, returns a rank-2 array `vt` that contains the right singular values of `a` along its rows.
841
+
842
+
Raises `LINALG_ERROR` if the underlying Singular Value Decomposition process did not converge.
843
+
Raises `LINALG_VALUE_ERROR` if the matrix or any of the output arrays invalid/incompatible sizes.
844
+
Exceptions trigger an `error stop`, unless argument `err` is present.
845
+
846
+
### Example
847
+
848
+
```fortran
849
+
{!example/linalg/example_svd1.f90!}
850
+
```
851
+
852
+
## `svdvals` - Compute the singular values of a 2d matrix.
853
+
854
+
### Status
855
+
856
+
Experimental
857
+
858
+
### Description
859
+
860
+
This subroutine computes the singular values of a `real` or `complex` 2d matrix from its singular
861
+
value decomposition \( A = U \cdot S \cdot \V^T \). The solver is based on LAPACK's `*GESDD` backends.
862
+
863
+
Result vector `s` returns the array of singular values on the diagonal of \( S \).
0 commit comments