Skip to content

Commit a5d1b8a

Browse files
committed
add specs
1 parent 9906c93 commit a5d1b8a

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

doc/specs/stdlib_linalg.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,3 +599,53 @@ Specifically, upper Hessenberg matrices satisfy `a_ij = 0` when `j < i-1`, and l
599599
```fortran
600600
{!example/linalg/example_is_hessenberg.f90!}
601601
```
602+
603+
## `solve` - Solves a linear matrix equation or a linear system of scalar equations.
604+
605+
### Status
606+
607+
Experimental
608+
609+
### Description
610+
611+
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.
612+
613+
Result vector `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.
614+
615+
### Syntax
616+
617+
`Pure` interface:
618+
619+
`x = ` [[stdlib_linalg(module):solve(interface)]] `(a, b)`
620+
621+
Expert interface:
622+
623+
`x = ` [[stdlib_linalg(module):solve(interface)]] `(a, b, [, overwrite_a], err])`
624+
625+
### Arguments
626+
627+
Two
628+
629+
`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.
630+
631+
`b`: Shall be a rank-1 array of the same kind as `a`, containing the right-hand-side vector. It is an `intent(in)` argument.
632+
633+
`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.
634+
635+
`err` (optional): Shall be a `type(linalg_state_type)` value. This is an `intent(out)` argument: the function is not `pure` if this argument is requested.
636+
637+
### Return value
638+
639+
Returns an array value that represents the solution to the linear system of equations.
640+
641+
Raises `LINALG_ERROR` if the matrix is singular to working precision.
642+
Raises `LINALG_VALUE_ERROR` if the matrix and rhs vectors have invalid/incompatible sizes.
643+
Exceptions trigger an `error stop`.
644+
645+
### Example
646+
647+
```fortran
648+
{!example/linalg/example_solve1.f90!}
649+
650+
{!example/linalg/example_solve2.f90!}
651+
```

0 commit comments

Comments
 (0)