Skip to content

Commit 905692c

Browse files
committed
document interface
1 parent 2b2ade9 commit 905692c

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/stdlib_linalg.fypp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,22 @@ module stdlib_linalg
223223

224224
! Least squares solution to system Ax=b, i.e. such that the 2-norm abs(b-Ax) is minimized.
225225
interface lstsq
226+
!! version: experimental
227+
!!
228+
!! Computes the squares solution to system \( A \cdot x = b \).
229+
!! ([Specification](../page/specs/stdlib_linalg.html#det-computes-the-determinant-of-a-square-matrix))
230+
!!
231+
!!### Summary
232+
!! Interface for computing least squares, i.e. the 2-norm \( || (b-A \cdot x ||_2 \) minimizing solution.
233+
!!
234+
!!### Description
235+
!!
236+
!! This interface provides methods for computing the least squares of a linear matrix system.
237+
!! Supported data types include `real` and `complex`.
238+
!!
239+
!!@note The solution is based on LAPACK's singular value decomposition `*GELSD` methods.
240+
!!@note BLAS/LAPACK backends do not currently support extended precision (``xdp``).
241+
!!
226242
#:for nd,ndsuf,nde in ALL_RHS
227243
#:for rk,rt,ri in RC_KINDS_TYPES
228244
#:if rk!="xdp"

src/stdlib_linalg_least_squares.fypp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,24 @@ submodule (stdlib_linalg) stdlib_linalg_least_squares
6161
#:for rk,rt,ri in RC_KINDS_TYPES
6262
#:if rk!="xdp"
6363

64-
! Compute the least-squares solution to a real system of linear equations Ax = B
64+
! Compute the least-squares solution to a real system of linear equations Ax = b
6565
module function stdlib_linalg_${ri}$_lstsq_${ndsuf}$(a,b,cond,overwrite_a,rank,err) result(x)
66+
!!### Summary
67+
!! Compute least-squares solution to a real system of linear equations \( Ax = b \)
68+
!!
69+
!!### Description
70+
!!
71+
!! This function computes the least-squares solution of a linear matrix problem.
72+
!!
73+
!! param: a Input matrix of size [m,n].
74+
!! param: b Right-hand-side vector of size [n] or matrix of size [n,nrhs].
75+
!! param: cond [optional] Real input threshold indicating that singular values `s_i <= cond*maxval(s)`
76+
!! do not contribute to the matrix rank.
77+
!! param: overwrite_a [optional] Flag indicating if the input matrix can be overwritten.
78+
!! param: rank [optional] integer flag returning matrix rank.
79+
!! param: err [optional] State return flag.
80+
!! return: x Solution vector of size [n] or solution matrix of size [n,nrhs].
81+
!!
6682
!> Input matrix a[n,n]
6783
${rt}$, intent(inout), target :: a(:,:)
6884
!> Right hand side vector or array, b[n] or b[n,nrhs]

0 commit comments

Comments
 (0)