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
Copy file name to clipboardExpand all lines: doc/specs/stdlib_linalg.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -860,6 +860,55 @@ This subroutine computes the internal working space requirements for the least-s
860
860
861
861
`lcwork` (`complex``a`, `b`): For a `complex` system, shall be an `integer` scalar, that returns the minimum array size required for the `complex` working storage to this system.
862
862
863
+
## `constrained_lstsq` - Compute the solution of the equality-constrained least-squares problem {#constrained-lstsq}
864
+
865
+
### Status
866
+
867
+
Experimental
868
+
869
+
### Description
870
+
871
+
This function computes the solution \(x\) of the equality-constrained linear least-squares problem
872
+
$$
873
+
\begin{aligned}
874
+
\mathrm{minimize} & \quad \| Ax - b \|^2 \\
875
+
\mathrm{subject~to} & \quad Cx = d,
876
+
\end{aligned}
877
+
$$
878
+
where \(A\) is an \( m \times n \) matrix (with \(m \geq n\)) and \(C\) a \( p \times n\) matrix (with \(p \leq n\)). The solver is based on LAPACK's `*GLSE` backends.
`a`: Shall be a rank-2 `real` or `complex` array used in the definition of the least-squares cost. It is an `intent(inout)` argument.
887
+
888
+
`b`: Shall be a rank-1 array of the same kind as `a` appearing in the definition of the least-squares cost. It is an `intent(inout)` argument.
889
+
890
+
`c`: Shall be a rank-2 `real` or `complex` array of the same kind as `a` defining the linear equality constraints. It is an `intent(inout)` argument.
891
+
892
+
`d`: Shall be a rank-1 array of the same kind as `a` appearing in the definition of the linear equality constraints.
893
+
894
+
`overwrite_matrices` (optional): Shall be an input `logical` flag. If `.true.`, the input matrices and vectors will be overwritten during the computation of the solution. It is an `intent(in)` argument.
895
+
896
+
`err` (optional): Shall be a `type(linalg_state_type)` value. This is an `intent(out)` argument.
897
+
898
+
### Return value
899
+
900
+
Returns an array of the same kind as `a` containing the solution of the equality constrained least-squares problem.
901
+
902
+
Raises `LINALG_ERROR` if the underlying constrained least-squares solver did not converge.
903
+
Raises `LINALG_VALUE_ERROR` if the matrices and vectors have invalid/incompatible dimensions.
904
+
Exceptions trigger an `error stop`.
905
+
906
+
### Example
907
+
908
+
```fortran
909
+
{!example/linalg/example_constrained_lstsq1.f90!}
910
+
```
911
+
863
912
## `det` - Computes the determinant of a square matrix
0 commit comments