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
`x = `[[stdlib_linalg(module):solve(interface)]]`(a, b [, overwrite_a], err)`
626
+
627
+
### Arguments
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 or rank-2 array of the same kind as `a`, containing the right-hand-side vector(s). 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 provided.
636
+
637
+
### Return value
638
+
639
+
For a full-rank matrix, 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
+
If `err` is not present, 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
+
```
652
+
653
+
## `solve_lu` - Solves a linear matrix equation or a linear system of equations (subroutine interface).
654
+
655
+
### Status
656
+
657
+
Experimental
658
+
659
+
### Description
660
+
661
+
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.
662
+
663
+
Result vector or array `x` returns the exact solution to within numerical precision, provided that the matrix is not ill-conditioned.
664
+
An error is returned if the matrix is rank-deficient or singular to working precision.
665
+
If all optional arrays are provided by the user, no internal allocations take place.
`call `[[stdlib_linalg(module):solve_lu(interface)]]`(a, b, x [, pivot, overwrite_a, err])`
677
+
678
+
### Arguments
679
+
680
+
`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.
681
+
682
+
`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.
683
+
684
+
`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.
685
+
686
+
`pivot` (optional): Shall be a rank-1 array of the same kind and matrix dimension as `a`, providing storage for the diagonal pivot indices. It is an `intent(inout)` arguments, and returns the diagonal pivot indices.
687
+
688
+
`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.
689
+
690
+
### Return value
691
+
692
+
For a full-rank matrix, returns an array value that represents the solution to the linear system of equations.
693
+
694
+
Raises `LINALG_ERROR` if the matrix is singular to working precision.
695
+
Raises `LINALG_VALUE_ERROR` if the matrix and rhs vectors have invalid/incompatible sizes.
696
+
If `err` is not present, exceptions trigger an `error stop`.
697
+
698
+
### Example
699
+
700
+
```fortran
701
+
{!example/linalg/example_solve3.f90!}
702
+
```
703
+
603
704
## `lstsq` - Computes the least squares solution to a linear matrix equation.
0 commit comments