Skip to content

Commit 99ca106

Browse files
committed
documentation
1 parent 80a1df1 commit 99ca106

File tree

2 files changed

+76
-3
lines changed

2 files changed

+76
-3
lines changed

doc/specs/stdlib_linalg.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,81 @@ This subroutine computes the internal working space requirements for the QR fact
979979
{!example/linalg/example_qr_space.f90!}
980980
```
981981

982+
## `schur` - Compute the Schur decomposition of a matrix
983+
984+
### Status
985+
986+
Experimental
987+
988+
### Description
989+
990+
This subroutine computes the Schur decomposition of a `real` or `complex` matrix: \( A = Z T Z^H \), where \( Z \) is unitary (orthonormal) and \( T \) is upper-triangular (for complex matrices) or quasi-upper-triangular (for real matrices, with possible \( 2 \times 2 \) blocks on the diagonal). Matrix \( A \) has size `[n,n]`.
991+
992+
The results are returned in output matrices \( T \) and \( Z \). Matrix \( T \) is the Schur form, and matrix \( Z \) is the unitary transformation matrix such that \( A = Z T Z^H \). If requested, the eigenvalues of \( T \) can also be returned as a `complex` array of size `[n]`.
993+
994+
### Syntax
995+
996+
`call ` [[stdlib_linalg(module):schur(interface)]] `(a, t, z, [, eigvals] [, overwrite_a] [, storage] [, err])`
997+
998+
### Arguments
999+
1000+
- `a`: Shall be a rank-2 `real` or `complex` array containing the matrix to be decomposed. It is an `intent(inout)` argument if `overwrite_a = .true.`; otherwise, it is an `intent(in)` argument.
1001+
1002+
- `t`: Shall be a rank-2 array of the same kind as `a`, containing the Schur form \( T \) of the matrix. It is an `intent(out)` argument and should have a shape of `[n,n]`.
1003+
1004+
- `z`: Shall be a rank-2 array of the same kind as `a`, containing the unitary matrix \( Z \). It is an `intent(out)` argument and is optional. If provided, it should have the shape `[n,n]`.
1005+
1006+
- `eigvals` (optional): Shall be a rank-1 `complex` array containing the eigenvalues of \( A \) (the diagonal elements of \( T \)). The array must be of size `[n]`. If not provided, the eigenvalues are not returned.
1007+
1008+
- `overwrite_a` (optional): Shall be a `logical` flag (default: `.false.`). If `.true.`, the input matrix `a` will be overwritten and destroyed upon return, avoiding internal data allocation. It is an `intent(in)` argument.
1009+
1010+
- `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):schur_space(interface)]]. It is an `intent(inout)` argument.
1011+
1012+
- `err` (optional): Shall be a `type(linalg_state_type)` value. It is an `intent(out)` argument. If not provided, exceptions trigger an `error stop`.
1013+
1014+
### Return value
1015+
1016+
Returns the Schur decomposition matrices into the \( T \) and \( Z \) arguments. If `eigvals` is provided, it will also return the eigenvalues of the matrix \( A \).
1017+
1018+
Raises `LINALG_VALUE_ERROR` if any of the matrices have invalid or unsuitable size for the decomposition.
1019+
Raises `LINALG_ERROR` on insufficient user storage space.
1020+
If the state argument `err` is not present, exceptions trigger an `error stop`.
1021+
1022+
### Example
1023+
1024+
```fortran
1025+
{!example/linalg/example_schur_eigvals.f90!}
1026+
```
1027+
1028+
---
1029+
1030+
## `schur_space` - Compute internal working space requirements for the Schur decomposition
1031+
1032+
### Status
1033+
1034+
Experimental
1035+
1036+
### Description
1037+
1038+
This subroutine computes the internal working space requirements for the Schur decomposition, [[stdlib_linalg(module):schur(interface)]].
1039+
1040+
### Syntax
1041+
1042+
`call ` [[stdlib_linalg(module):schur_space(interface)]] `(a, lwork, [, err])`
1043+
1044+
### Arguments
1045+
1046+
- `a`: Shall be a rank-2 `real` or `complex` array containing the matrix to be decomposed. It is an `intent(in)` argument.
1047+
1048+
- `lwork`: Shall be an `integer` scalar that returns the minimum array size required for the working storage in [[stdlib_linalg(module):schur(interface)]] to decompose `a`.
1049+
1050+
- `err` (optional): Shall be a `type(linalg_state_type)` value. It is an `intent(out)` argument.
1051+
1052+
### Return value
1053+
1054+
Returns the required working storage size `lwork` for the Schur decomposition. This value can be used to pre-allocate a workspace array in case multiple Schur decompositions of the same matrix size are needed. If pre-allocated working arrays are provided, no internal memory allocations will take place during the decomposition.
1055+
1056+
9821057
## `eig` - Eigenvalues and Eigenvectors of a Square Matrix
9831058

9841059
### Status

src/stdlib_linalg.fypp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,10 +619,8 @@ module stdlib_linalg
619619
!!
620620
!! The output matrix \( T \) is upper-triangular for `complex` input matrices and quasi-upper-triangular
621621
!! for `real` input matrices (with possible \( 2 \times 2 \) blocks on the diagonal).
622-
!! The user can optionally request sorting of eigenvalues based on conditions, or a custom sorting function.
623622
!!
624-
!!@note The solution is based on LAPACK's Schur decomposition routines (`*GEES`). Sorting options
625-
!! are implemented using LAPACK's eigenvalue sorting mechanism.
623+
!!@note The solution is based on LAPACK's Schur decomposition routines (`*GEES`).
626624
!!
627625
#:for rk,rt,ri in RC_KINDS_TYPES
628626
module subroutine stdlib_linalg_${ri}$_schur(a, t, z, eigvals, overwrite_a, storage, err)

0 commit comments

Comments
 (0)