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
+92-1Lines changed: 92 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -777,7 +777,8 @@ Result vector `x` returns the approximate solution that minimizes the 2-norm \(
777
777
778
778
`cond` (optional): Shall be a scalar `real` value cut-off threshold for rank evaluation: `s_i >= cond*maxval(s), i=1:rank`. Shall be a scalar, `intent(in)` argument.
779
779
780
-
`singvals` (optional): Shall be a `real` rank-1 array of the same kind `a` and size at least `minval(shape(a))`, returning the list of singular values `s(i)>=cond*maxval(s)`, in descending order of magnitude. It is an `intent(out)` argument.
780
+
`singvals` (optional): Shall be a `real` rank-1 array of the same kind `a` and size at least `m
781
+
al(shape(a))`, returning the list of singular values `s(i)>=cond*maxval(s)`, in descending order of magnitude. It is an `intent(out)` argument.
781
782
782
783
`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. This is an `intent(in)` argument.
783
784
@@ -899,6 +900,96 @@ Exceptions trigger an `error stop`.
899
900
{!example/linalg/example_determinant2.f90!}
900
901
```
901
902
903
+
## `svd` - Compute the singular value decomposition of a rank-2 array (matrix).
904
+
905
+
### Status
906
+
907
+
Experimental
908
+
909
+
### Description
910
+
911
+
This subroutine computes the singular value decomposition of a `real` or `complex` rank-2 array (matrix) \( A = U \cdot S \cdot \V^T \).
912
+
The solver is based on LAPACK's `*GESDD` backends.
913
+
914
+
Result vector `s` returns the array of singular values on the diagonal of \( S \).
915
+
If requested, `u` contains the left singular vectors, as columns of \( U \).
916
+
If requested, `vt` contains the right singular vectors, as rows of \( V^T \).
917
+
918
+
### Syntax
919
+
920
+
`call `[[stdlib_linalg(module):svd(interface)]]`(a, s, [, u, vt, overwrite_a, full_matrices, err])`
921
+
922
+
### Class
923
+
Subroutine
924
+
925
+
### Arguments
926
+
927
+
`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.`.
928
+
929
+
`s`: Shall be a rank-1 `real` array, returning the list of `k = min(m,n)` singular values. It is an `intent(out)` argument.
930
+
931
+
`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(out)` argument.
932
+
933
+
`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(out)` argument.
934
+
935
+
`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.`. It is an `intent(in)` argument.
936
+
937
+
`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.
938
+
939
+
`err` (optional): Shall be a `type(linalg_state_type)` value. This is an `intent(out)` argument.
940
+
941
+
### Return values
942
+
943
+
Returns an array `s` that contains the list of singular values of matrix `a`.
944
+
If requested, returns a rank-2 array `u` that contains the left singular vectors of `a` along its columns.
945
+
If requested, returns a rank-2 array `vt` that contains the right singular vectors of `a` along its rows.
946
+
947
+
Raises `LINALG_ERROR` if the underlying Singular Value Decomposition process did not converge.
948
+
Raises `LINALG_VALUE_ERROR` if the matrix or any of the output arrays invalid/incompatible sizes.
949
+
Exceptions trigger an `error stop`, unless argument `err` is present.
950
+
951
+
### Example
952
+
953
+
```fortran
954
+
{!example/linalg/example_svd.f90!}
955
+
```
956
+
957
+
## `svdvals` - Compute the singular values of a rank-2 array (matrix).
958
+
959
+
### Status
960
+
961
+
Experimental
962
+
963
+
### Description
964
+
965
+
This subroutine computes the singular values of a `real` or `complex` rank-2 array (matrix) from its singular
966
+
value decomposition \( A = U \cdot S \cdot \V^T \). The solver is based on LAPACK's `*GESDD` backends.
967
+
968
+
Result vector `s` returns the array of singular values on the diagonal of \( S \).
0 commit comments