Skip to content

Commit c9f5f0c

Browse files
committed
document solve_lu
1 parent 5e0620c commit c9f5f0c

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

doc/specs/stdlib_linalg.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,9 @@ Experimental
610610

611611
This function computes the solution to a linear matrix equation \( A \cdot x = b \), where \( A \) is a square, full-rank, `real` or `complex` matrix.
612612

613-
Result vector or array `x` returns the exact solution to within numerical precision, provided that the matrix is not ill-conditioned. The solver is based on LAPACK's `*GESV` backends.
613+
Result vector or array `x` returns the exact solution to within numerical precision, provided that the matrix is not ill-conditioned.
614+
An error is returned if the matrix is rank-deficient or singular to working precision.
615+
The solver is based on LAPACK's `*GESV` backends.
614616

615617
### Syntax
616618

@@ -640,7 +642,57 @@ For a full-rank matrix, returns an array value that represents the solution to t
640642

641643
Raises `LINALG_ERROR` if the matrix is singular to working precision.
642644
Raises `LINALG_VALUE_ERROR` if the matrix and rhs vectors have invalid/incompatible sizes.
643-
Exceptions trigger an `error stop`.
645+
If `err` is not present, exceptions trigger an `error stop`.
646+
647+
### Example
648+
649+
```fortran
650+
{!example/linalg/example_solve1.f90!}
651+
652+
{!example/linalg/example_solve2.f90!}
653+
```
654+
655+
## `solve_lu` - Solves a linear matrix equation or a linear system of equations (subroutine interface).
656+
657+
### Status
658+
659+
Experimental
660+
661+
### Description
662+
663+
This subroutine computes the solution to a linear matrix equation \( A \cdot x = b \), where \( A \) is a square, full-rank, `real` or `complex` matrix.
664+
665+
Result vector or array `x` returns the exact solution to within numerical precision, provided that the matrix is not ill-conditioned.
666+
An error is returned if the matrix is rank-deficient or singular to working precision.
667+
The solver is based on LAPACK's `*GESV` backends.
668+
669+
### Syntax
670+
671+
`Pure` interface:
672+
673+
`x = ` [[stdlib_linalg(module):solve_lu(interface)]] `(a, b, x, pivot [, overwrite_a, err])`
674+
675+
### Arguments
676+
677+
Two
678+
679+
`a`: Shall be a rank-2 `real` or `complex` square array containing the coefficient matrix. It is normally an `intent(in)` argument. If `overwrite_a=.true.`, it is an `intent(inout)` argument and is destroyed by the call.
680+
681+
`b`: Shall be a rank-1 or rank-2 array of the same kind as `a`, containing the right-hand-side vector(s). It is an `intent(in)` argument.
682+
683+
`x`: Shall be a rank-1 or rank-2 array of the same kind and size as `b`, that returns the solution(s) to the system. It is an `intent(inout)` argument, and must have the `contiguous` property.
684+
685+
`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.
686+
687+
`err` (optional): Shall be a `type(linalg_state_type)` value. This is an `intent(out)` argument.
688+
689+
### Return value
690+
691+
For a full-rank matrix, returns an array value that represents the solution to the linear system of equations.
692+
693+
Raises `LINALG_ERROR` if the matrix is singular to working precision.
694+
Raises `LINALG_VALUE_ERROR` if the matrix and rhs vectors have invalid/incompatible sizes.
695+
If `err` is not present, exceptions trigger an `error stop`.
644696

645697
### Example
646698

0 commit comments

Comments
 (0)