Skip to content

Commit 816d29e

Browse files
committed
Specs for solve_constrained_lstsq
1 parent ed45fb5 commit 816d29e

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

doc/specs/stdlib_linalg.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,52 @@ Exceptions trigger an `error stop`.
909909
{!example/linalg/example_constrained_lstsq1.f90!}
910910
```
911911

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 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+
912958
## `det` - Computes the determinant of a square matrix
913959

914960
### Status

0 commit comments

Comments
 (0)