|
|
◆ WDgelss()
| Function WDgelss |
( |
M As |
Long, |
|
|
N As |
Long, |
|
|
A As |
Variant, |
|
|
B As |
Variant, |
|
|
Optional Nrhs As |
Long = 1, |
|
|
Optional RCond As |
Double = 0, |
|
|
Optional Cov As |
String = "N", |
|
|
Optional Sing As |
String = "N" |
|
) |
| |
Solution to overdetermined or underdetermined linear equations Ax = b using the singular value decomposition (SVD)
- Purpose
- WDgelss computes the minimum norm solution to a real linear least squares problem: using the singular value decomposition (SVD) of A. A is an M x N matrix which may be rank-deficient.
Several right hand side vectors b and solution vectors x can be handled in a single call; they are stored as the columns of the M x Nrhs right hand side matrix B and the N x Nrhs solution matrix X.
The effective rank of A is determined by treating as zero those singular values which are less than RCond times the largest singular value.
- Returns
- If M >= N and Sing = "N" (N+2 x Nrhs (Cov = "N"), N+2 x Nrhs+1 (Cov = "D") or N+2 x Nrhs+N (Cov = "C"))
| Columns 1 to Nrhs | Column Nrhs+1 (if Cov = "D") | Columns Nrhs+1 to Nrhs+N (if Cov = "C") |
| Rows 1 to N | Least squares solution vector x | Variance (diagonal elements of variance-covariance matrix) | Variance-covariance matrix |
| Row N+1 | Effective rank (column 1) | 0 | 0 |
| Row N+2 | Return code (column 1) | 0 | 0 |
If M >= N and Sing = "S" (N+2 x Nrhs+1 (Cov = "N"), N+2 x Nrhs+2 (Cov = "D") or N+2 x Nrhs+N+2 (Cov = "C"))
| Columns 1 to Nrhs | Column Nrhs+1 | Column Nrhs+2 (if Cov = "D") | Columns Nrhs+2 to Nrhs+N+1 (if Cov = "C") |
| Rows 1 to N | Least squares solution vector x | Singular values of A in descending order | Variance (diagonal elements of variance-covariance matrix) | Variance-covariance matrix |
| Row N+1 | Effective rank (column 1) | 0 | 0 | 0 |
| Row N+2 | Return code (column 1) | 0 | 0 | 0 |
If M < N (N+2 x Nrhs (Sing = "N"), N+2 x Nrhs+1 (Sing = "S"))
| Columns 1 to Nrhs | Column Nrhs+1 (if SIng = "S") |
| Rows 1 to N | Minimum norm solution vector x | Singular values of A in descending order |
| Row N+1 | Effective rank (column 1) | 0 |
| Row N+2 | Return code (column 1) | 0 |
Return code
= 0: Successful exit.
= i > 0: The algorithm for computing the SVD failed to converge; i off-diagonal elements of an intermediate bidiagonal form did not converge to zero.
- Parameters
-
| [in] | M | Number of rows of the matrix A. (M >= 1) |
| [in] | N | Number of columns of the matrix A. (N >= 1) |
| [in] | A | (M x N) M x N coefficient matrix A. (May be rank-deficient) |
| [in] | B | (M x Nrhs) Right hand side matrix B. |
| [in] | Nrhs | (Optional)
Number of columns of right hand side matrix B. (Nrhs >= 1) (default = 1) |
| [in] | RCond | (Optional)
The parameter used to determine the effective rank of A. The effective rank is the number of singular values which are greater than RCond * largest singular value.
(default = machine precision) |
| [in] | Cov | (Optional)
= "N": Do not compute variance-covariance matrix.
= "D": Compute diagonal elements of variance-covariance matrix. (If M >= N)
= "C": Compute variance-covariance matrix. (If M >= N)
(default = "N") |
| [in] | Sing | (Optional)
= "N": Singular values are not returned
= "S": Singular values are returned
(default = "N") |
- Reference
- LAPACK
- Example
- Compute the least squares solution of the overdetermined linear equations Ax = b and its variance, where
( -1.06 0.48 -0.04 )
A = ( -1.19 0.73 -0.24 )
( 1.97 -0.89 0.56 )
( 0.68 -0.53 0.08 )
( 0.3884 )
B = ( 0.1120 )
( -0.3644 )
( -0.0002 )
|