Skip to content

Commit e9d10f0

Browse files
committed
All specs + minor modifs.
1 parent 816d29e commit e9d10f0

File tree

5 files changed

+35
-9
lines changed

5 files changed

+35
-9
lines changed

doc/specs/stdlib_linalg.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,32 @@ where \(A\) is an \( m \times n \) matrix (with \(m \geq n\)) and \(C\) a \( p
955955
{!example/linalg/example_constrained_lstsq2.f90!}
956956
```
957957

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)].
967+
968+
### Syntax
969+
970+
call [stdlib_linalg(module):constrained_lstsq_space(interface)]`(a, c, lwork [, err])`
971+
972+
### Arguments
973+
974+
`a`: Shall be a rank-2 `real` or `complex` array used in the definition of the least-squares cost. It is an `intent(in)` argument.
975+
976+
`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(in)` argument.
977+
978+
`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(in)` argument.
979+
980+
`d`: Shall be a rank-1 array of the same kind as `a` appearing in the definition of the linear equality constraints.
981+
982+
`lwork`: Shall be an `interger` scalar returning the optimal size required for the workspace array to solve the constrained least-squares problem.
983+
958984
## `det` - Computes the determinant of a square matrix
959985

960986
### Status

example/linalg/example_constrained_lstsq2.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ program example_constrained_lstsq2
3131
d = [1.0_dp, 3.0_dp, -1.0_dp]
3232

3333
!> Optimal workspace size.
34-
call constrained_lstsq_space(A, b, C, d, lwork)
34+
call constrained_lstsq_space(A, C, lwork)
3535
allocate (work(lwork))
3636

3737
! Compute the solution.

src/stdlib_linalg.fypp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,11 +668,11 @@ module stdlib_linalg
668668
!! working arrays are provided, no internal allocation will take place.
669669
!!
670670
#:for rk, rt, ri in RC_KINDS_TYPES
671-
module subroutine stdlib_linalg_${ri}$_constrained_lstsq_space(A, b, C, d, lwork, err)
671+
module subroutine stdlib_linalg_${ri}$_constrained_lstsq_space(A, C, lwork, err)
672672
!> Least-squares cost.
673-
${rt}$, intent(in) :: A(:, :), b(:)
673+
${rt}$, intent(in) :: A(:, :)
674674
!> Equality constraints.
675-
${rt}$, intent(in) :: C(:, :), d(:)
675+
${rt}$, intent(in) :: C(:, :)
676676
integer(ilp), intent(out) :: lwork
677677
type(linalg_state_type), optional, intent(out) :: err
678678
end subroutine stdlib_linalg_${ri}$_constrained_lstsq_space

src/stdlib_linalg_least_squares.fypp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,11 @@ submodule (stdlib_linalg) stdlib_linalg_least_squares
390390

391391
#:for rk, rt, ri in RC_KINDS_TYPES
392392
! Compute the size of the workspace requested by the constrained least-squares procedure.
393-
module subroutine stdlib_linalg_${ri}$_constrained_lstsq_space(A, b, C, d, lwork, err)
393+
module subroutine stdlib_linalg_${ri}$_constrained_lstsq_space(A, C, lwork, err)
394394
!> Least-squares cost.
395-
${rt}$, intent(in) :: A(:, :), b(:)
395+
${rt}$, intent(in) :: A(:, :)
396396
!> Equality constraints.
397-
${rt}$, intent(in) :: C(:, :), d(:)
397+
${rt}$, intent(in) :: C(:, :)
398398
!> Size of the workspace array.
399399
integer(ilp), intent(out) :: lwork
400400
!> [optional] State return flag.
@@ -492,7 +492,7 @@ submodule (stdlib_linalg) stdlib_linalg_least_squares
492492
endif
493493

494494
!> Retrieve workspace size.
495-
call stdlib_linalg_${ri}$_constrained_lstsq_space(A, b, C, d, lwork, err0)
495+
call stdlib_linalg_${ri}$_constrained_lstsq_space(A, C, lwork, err0)
496496

497497
if (err0%ok()) then
498498
!> Workspace.

test/linalg/test_linalg_constrained_lstsq.fypp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module test_linalg_constrained_least_squares
7979
if (allocated(error)) return
8080

8181
!----- Pre-allocated storage -----
82-
call constrained_lstsq_space(A, b, C, d, lwork, err=state)
82+
call constrained_lstsq_space(A, C, lwork, err=state)
8383
call check(error, state%ok(), state%print())
8484
if (allocated(error)) return
8585
allocate(work(lwork))

0 commit comments

Comments
 (0)