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
+48Lines changed: 48 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -899,6 +899,54 @@ Exceptions trigger an `error stop`.
899
899
{!example/linalg/example_determinant2.f90!}
900
900
```
901
901
902
+
## `qr` - Compute the QR factorization of a matrix.
903
+
904
+
### Status
905
+
906
+
Experimental
907
+
908
+
### Description
909
+
910
+
This subroutine computes the QR factorization of a `real` or `complex` matrix: \( A = Q R \). where \( Q \)
911
+
is orthonormal and \( R \) is upper-triangular. Matrix \( A \) has size `[m,n]`, with \( m \ge n \).
912
+
913
+
The results are returned in output matrices \( Q \) and \(R \), that have the same type and kind as \( A \).
914
+
Given `k = min(m,n)`, one can write \( A = \( Q_1 Q_2 \) \cdot \( \frac{R_1}{0}\)\).
915
+
Because the lower rows of \( R \) are zeros, the user may require to return full matrices (provide `shape(Q)==[m,m]`, `shape(R)==[m,n]`)
916
+
or reduced matrices: \( A = Q_1 R_1 \) (provide `shape(Q)==[m,k]`, `shape(R)==[k,n]`).
917
+
918
+
### Syntax
919
+
920
+
`call `[[stdlib_linalg(module):qr(interface)]]`(a, q, r, [, storage] [, overwrite_a] [, err])`
921
+
922
+
### Arguments
923
+
924
+
`a`: Shall be a rank-2 `real` or `complex` array containing the coefficient matrix of size `[m,n]`. It is normally an `intent(in)` argument. If `overwrite_a=.true.`, it is an `intent(inout)` argument, and is destroyed upon return.
925
+
926
+
`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 shape either `[m,m]` or `[m,k]` whether the full or the reduced problem is sought for.
927
+
928
+
`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 shape either `[m,n]` or `[k,n]` whether the full or the reduced problem is sought for.
929
+
930
+
`storage` (optional): Shall be a rank-1 array of the same type and kind as `a`, providing working storage for the solver. It minimum size can be determined with a call to [[stdlib_linalg(module):qr_space(interface)]]. It is an `intent(inout)` argument.
931
+
932
+
`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. This is an `intent(in)` argument.
933
+
934
+
`err` (optional): Shall be a `type(linalg_state_type)` value. This is an `intent(out)` argument.
935
+
936
+
### Return value
937
+
938
+
Returns the QR factorization matrices into the \( Q \) and \( R \) arguments.
939
+
940
+
Raises `LINALG_VALUE_ERROR` if any of the matrices has invalid or unsuitable size for the full/reduced problem.
941
+
Raises `LINALG_ERROR` on insufficient user storage space.
942
+
If the state argument `err` is not present, exceptions trigger an `error stop`.
943
+
944
+
### Example
945
+
946
+
```fortran
947
+
{!example/linalg/example_qr.f90!}
948
+
```
949
+
902
950
## `qr_space` - Compute internal working space requirements for the QR factorization.
0 commit comments