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
+116Lines changed: 116 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -860,6 +860,122 @@ 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
+
912
+
## `solve_constrained_lstsq` - Compute the solution of the equality-constrained least squares problem (subroutine interface) {#solve-constrained-lstsq}
913
+
914
+
### Status
915
+
916
+
Experimental
917
+
918
+
### Description
919
+
920
+
This subroutine computes the solution \(x\) of the equality-constrained linear least-squares problem
921
+
$$
922
+
\begin{aligned}
923
+
\mathrm{minimize} & \quad \| Ax - b \|^2 \\
924
+
\mathrm{subject~to} & \quad Cx = d,
925
+
\end{aligned}
926
+
$$
927
+
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.
928
+
929
+
### Syntax
930
+
931
+
932
+
`call `[[stdlib_linalg(module):solve_constrained_lstsq(interface)]]`(a, b, c, d, x [, storage, overwrite_matrices, err])`
933
+
934
+
### Arguments
935
+
936
+
`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.
937
+
938
+
`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.
939
+
940
+
`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.
941
+
942
+
`d`: Shall be a rank-1 array of the same kind as `a` appearing in the definition of the linear equality constraints.
943
+
944
+
`x`: Shall be a rank-1 array of the same kind as `a`. On exit, it contains the solution of the constrained least-squares problem. It is an `intent(out)` argument.
945
+
946
+
`storage` (optional): Shall be a rank-1 array of the same kind as `a` providing working storage for the solver. Its minimum size can be determined with a call to [stdlib_linalg(module):constrained_lstsq_space(interface)]. It is an `intent(out)` argument.
947
+
948
+
`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.
949
+
950
+
`err` (optional): Shall be a `type(linalg_state_type)` value. This is an `intent(out)` argument.
951
+
952
+
### Example
953
+
954
+
```fortran
955
+
{!example/linalg/example_constrained_lstsq2.f90!}
956
+
```
957
+
958
+
## `constrained_lstsq_space` - Compute internal workspace requirements for the constrained least-square solver {#constrained-lstsq-space}
959
+
960
+
### Status
961
+
962
+
Experimental
963
+
964
+
### Description
965
+
966
+
This subroutine computes the internal workspace requirements for the constrained least-squares solver, [stdlib_linalg(module):solve_constrained_lstsq(interface)].
0 commit comments