Skip to content

Commit 6b98c46

Browse files
committed
doc: specs
1 parent ac1e0f9 commit 6b98c46

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

doc/specs/stdlib_linalg.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,3 +990,95 @@ Exceptions trigger an `error stop`, unless argument `err` is present.
990990
{!example/linalg/example_svdvals.f90!}
991991
```
992992

993+
## `cholesky` - Compute the Cholesky factorization of a rank-2 square array (matrix).
994+
995+
### Status
996+
997+
Experimental
998+
999+
### Description
1000+
1001+
This subroutine computes the Cholesky factorization of a `real` or `complex` rank-2 square array (matrix),
1002+
\( A = L \cdot L^T \), or \( A = U^T \cdot U \). \( A \) is symmetric or complex Hermitian, and \( L \),
1003+
\( U \) are lower- or upper-triangular, respectively.
1004+
The solver is based on LAPACK's `*POTRF` backends.
1005+
1006+
### Syntax
1007+
1008+
`call ` [[stdlib_linalg(module):cholesky(interface)]] `(a, c, lower [, other_zeroed] [, err])`
1009+
### Class
1010+
Subroutine
1011+
1012+
### Arguments
1013+
1014+
`a`: Shall be a rank-2 square `real` or `complex` array containing the coefficient matrix of size `[n,n]`. It is an `intent(inout)` argument, but returns unchanged if argument `c` is present.
1015+
1016+
`c` (optional): Shall be a rank-2 square `real` or `complex` of the same size and kind as `a`. It is an `intent(out)` argument, that returns the triangular Cholesky matrix `L` or `U`.
1017+
1018+
`lower`: Shall be an input `logical` flag. If `.true.`, the lower triangular decomposition \( A = L \cdot L^T \) will be performed. If `.false.`, the upper decomposition \( A = U^T \cdot U \) will be performed.
1019+
1020+
`other_zeroed` (optional): Shall be an input `logical` flag. If `.true.`, the unused part of the output matrix will contains zeroes. Otherwise, it will not be accessed. This saves cpu time. By default, `other_zeroed=.true.`. It is an `intent(in)` argument.
1021+
1022+
`err` (optional): Shall be a `type(linalg_state_type)` value. This is an `intent(out)` argument.
1023+
1024+
### Return values
1025+
1026+
The factorized matrix is returned in-place overwriting `a` if no other arguments are provided.
1027+
Otherwise, it can be provided as a second argument `c`. In this case, `a` is not overwritten.
1028+
The `logical` flag `lower` determines whether the lower- or the upper-triangular factorization should be performed.
1029+
1030+
Results are returned on the applicable triangular region of the output matrix, while the unused triangular region
1031+
is filled by zeroes by default. Optional argument `other_zeroed`, if `.false.` allows the expert user to avoid zeroing the unused part;
1032+
however, in this case, the unused region of the matrix is not accessed and will usually contain invalid values.
1033+
1034+
Raises `LINALG_ERROR` if the underlying process did not converge.
1035+
Raises `LINALG_VALUE_ERROR` if the matrix or any of the output arrays invalid/incompatible sizes.
1036+
Exceptions trigger an `error stop`, unless argument `err` is present.
1037+
1038+
### Example
1039+
1040+
```fortran
1041+
{!example/linalg/example_cholesky.f90!}
1042+
```
1043+
1044+
## `chol` - Compute the Cholesky factorization of a rank-2 square array (matrix).
1045+
1046+
### Status
1047+
1048+
Experimental
1049+
1050+
### Description
1051+
1052+
This is a `pure` functional interface for Cholesky factorization. The Cholesky factorization of a `real` or
1053+
`complex` rank-2 square array (matrix) is computed, \( A = L \cdot L^T \), or \( A = U^T \cdot U \).
1054+
\( A \) is symmetric or complex Hermitian, and \( L \), \( U \) are lower- or upper-triangular, respectively.
1055+
The solver is based on LAPACK's `*POTRF` backends.
1056+
1057+
Result matrix `c` has the same size and kind as `a`, and returns the lower or upper triangular factor.
1058+
1059+
### Syntax
1060+
1061+
`c = ` [[stdlib_linalg(module):chol(interface)]] `(a, lower [, other_zeroed])`
1062+
1063+
### Arguments
1064+
1065+
`a`: Shall be a rank-2 square `real` or `complex` array containing the coefficient matrix of size `[n,n]`. It is an `intent(inout)` argument, but returns unchanged if argument `c` is present.
1066+
1067+
`lower`: Shall be an input `logical` flag. If `.true.`, the lower triangular decomposition \( A = L \cdot L^T \) will be performed. If `.false.`, the upper decomposition \( A = U^T \cdot U \) will be performed.
1068+
1069+
`other_zeroed` (optional): Shall be an input `logical` flag. If `.true.`, the unused part of the output matrix will contains zeroes. Otherwise, it will not be accessed. This saves cpu time. By default, `other_zeroed=.true.`. It is an `intent(in)` argument.
1070+
1071+
### Return values
1072+
1073+
Returns a rank-2 array `c` of the same size and kind as `a`, that contains the triangular Cholesky matrix `L` or `U`.
1074+
1075+
Raises `LINALG_ERROR` if the underlying process did not converge.
1076+
Raises `LINALG_VALUE_ERROR` if the matrix or any of the output arrays invalid/incompatible sizes.
1077+
Exceptions trigger an `error stop`, unless argument `err` is present.
1078+
1079+
### Example
1080+
1081+
```fortran
1082+
{!example/linalg/example_chol.f90!}
1083+
```
1084+

0 commit comments

Comments
 (0)