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
+78-1
Original file line number
Diff line number
Diff line change
@@ -902,6 +902,83 @@ Exceptions trigger an `error stop`.
902
902
{!example/linalg/example_determinant2.f90!}
903
903
```
904
904
905
+
## `qr` - Compute the QR factorization of a matrix
906
+
907
+
### Status
908
+
909
+
Experimental
910
+
911
+
### Description
912
+
913
+
This subroutine computes the QR factorization of a `real` or `complex` matrix: \( A = Q R \) where \( Q \)
914
+
is orthonormal and \( R \) is upper-triangular. Matrix \( A \) has size `[m,n]`, with \( m \ge n \).
915
+
916
+
The results are returned in output matrices \( Q \) and \(R \), that have the same type and kind as \( A \).
917
+
Given `k = min(m,n)`, one can write \( A = \( Q_1 Q_2 \) \cdot \( \frac{R_1}{0}\)\).
918
+
Because the lower rows of \( R \) are zeros, a reduced problem \( A = Q_1 R_1 \) may be solved. The size of
919
+
the input arguments determines what problem is solved: on full matrices (`shape(Q)==[m,m]`, `shape(R)==[m,n]`),
920
+
the full problem is solved. On reduced matrices (`shape(Q)==[m,k]`, `shape(R)==[k,n]`), the reduced problem is solved.
921
+
922
+
### Syntax
923
+
924
+
`call `[[stdlib_linalg(module):qr(interface)]]`(a, q, r, [, storage] [, overwrite_a] [, err])`
925
+
926
+
### Arguments
927
+
928
+
`a`: Shall be a rank-2 `real` or `complex` array containing the coefficient matrix of size `[m,n]`. It is an `intent(in)` argument, if `overwrite_a=.false.`. Otherwise, it is an `intent(inout)` argument, and is destroyed upon return.
929
+
930
+
`q`: Shall be a rank-2 array of the same kind as `a`, containing the orthonormal matrix `q`. It is an `intent(out)` argument. It should have a shape equal to either `[m,m]` or `[m,k]`, whether the full or the reduced problem is sought for.
931
+
932
+
`r`: Shall be a rank-2 array of the same kind as `a`, containing the upper triangular matrix `r`. It is an `intent(out)` argument. It should have a shape equal to either `[m,n]` or `[k,n]`, whether the full or the reduced problem is sought for.
933
+
934
+
`storage` (optional): Shall be a rank-1 array of the same type and kind as `a`, providing working storage for the solver. Its minimum size can be determined with a call to [[stdlib_linalg(module):qr_space(interface)]]. It is an `intent(out)` argument.
935
+
936
+
`overwrite_a` (optional): Shall be an input `logical` flag (default: `.false.`). If `.true.`, input matrix `a` will be used as temporary storage and overwritten. This avoids internal data allocation. It is an `intent(in)` argument.
937
+
938
+
`err` (optional): Shall be a `type(linalg_state_type)` value. It is an `intent(out)` argument.
939
+
940
+
### Return value
941
+
942
+
Returns the QR factorization matrices into the \( Q \) and \( R \) arguments.
943
+
944
+
Raises `LINALG_VALUE_ERROR` if any of the matrices has invalid or unsuitable size for the full/reduced problem.
945
+
Raises `LINALG_ERROR` on insufficient user storage space.
946
+
If the state argument `err` is not present, exceptions trigger an `error stop`.
947
+
948
+
### Example
949
+
950
+
```fortran
951
+
{!example/linalg/example_qr.f90!}
952
+
```
953
+
954
+
## `qr_space` - Compute internal working space requirements for the QR factorization.
955
+
956
+
### Status
957
+
958
+
Experimental
959
+
960
+
### Description
961
+
962
+
This subroutine computes the internal working space requirements for the QR factorization, [[stdlib_linalg(module):qr(interface)]] .
`a`: Shall be a rank-2 `real` or `complex` array containing the coefficient matrix. It is an `intent(in)` argument.
971
+
972
+
`lwork`: Shall be an `integer` scalar, that returns the minimum array size required for the working storage in [[stdlib_linalg(module):qr(interface)]] to factorize `a`.
973
+
974
+
`err` (optional): Shall be a `type(linalg_state_type)` value. This is an `intent(out)` argument.
975
+
976
+
### Example
977
+
978
+
```fortran
979
+
{!example/linalg/example_qr_space.f90!}
980
+
```
981
+
905
982
## `eig` - Eigenvalues and Eigenvectors of a Square Matrix
906
983
907
984
### Status
@@ -1028,7 +1105,6 @@ Raises `LINALG_ERROR` if the calculation did not converge.
1028
1105
Raises `LINALG_VALUE_ERROR` if any matrix or arrays have invalid/incompatible sizes.
1029
1106
If `err` is not present, exceptions trigger an `error stop`.
1030
1107
1031
-
1032
1108
### Example
1033
1109
1034
1110
```fortran
@@ -1096,6 +1172,7 @@ If requested, `vt` contains the right singular vectors, as rows of \( V^T \).
1096
1172
`call `[[stdlib_linalg(module):svd(interface)]]`(a, s, [, u, vt, overwrite_a, full_matrices, err])`
0 commit comments