|
|
◆ WDgels()
| Function WDgels |
( |
M As |
Long, |
|
|
N As |
Long, |
|
|
A As |
Variant, |
|
|
B As |
Variant, |
|
|
Optional Nrhs As |
Long = 1, |
|
|
Optional Trans As |
String = "N", |
|
|
Optional Cov As |
String = "N" |
|
) |
| |
Solution to overdetermined or underdetermined linear equations Ax = b (full rank)
- Purpose
- WDgels solves overdetermined or underdetermined real linear systems involving an m x n matrix A, or its transpose, using a QR or LQ factorization of A. It is assumed that A has full rank.
The following options are provided:
- If Trans = "N" and m >= n: find the least squares solution of an overdetermined system, i.e., solve the least squares problem
- If Trans = "N" and m < n: find the minimum norm solution of an underdetermined system A * X = B.
- If Trans = "T" and m >= n: find the minimum norm solution of an underdetermined system A^T * X = B.
- If Trans = "T" and m < n: find the least squares solution of an overdetermined system, i.e., solve the least squares problem
minimize || B - A^T*X ||.
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.
- Returns
- If Trans = "N" and M > N (N+2 x Nrhs (Cov = "N"), N+2 x Nrhs+1 (Cov = "D") or N+2 x Nrhs+N (Cov = "C"))
| Column 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 | Residual sum of squares for the solution | 0 | 0 |
| Row N+2 | Return code (column 1) | 0 | 0 |
If Trans = "T" and M < N (M+2 x Nrhs)
| Column 1 to Nrhs |
| Rows 1 to M | Least squares solution vector x |
| Row M+1 | Residual sum of squares for the solution |
| Row M+2 | Return code (column 1) |
If Trans = "N" and M <= N (N+1 x Nrhs)
| Column 1 to Nrhs |
| Rows 1 to N | Minimum norm solution vector x |
| Row N+1 | Return code (column 1) |
Id Trans = "T" and M >= N (M+1 x Nrhs)
| Column 1 to Nrhs |
| Rows 1 to M | Minimum norm solution vector x |
| Row M+1 | Return code (column 1) |
Return code
= 0: Successful exit.
= i > 0: The i-th diagonal element of the triangular factor of A is zero. (A does not have full rank)
- 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. (should be full rank) |
| [in] | B | (M x Nrhs if Trans = "N", N x Nrhs if Trans = "T") Right hand side matrix B. |
| [in] | Nrhs | (Optional)
Number of columns of right hand side matrix B. (Nrhs >= 1) (default = 1) |
| [in] | Trans | (Optional)
= "N": Solve Ax = b
= "T": Solve (A^T)x = b
(default = "N") |
| [in] | Cov | (Optional)
= "N": Do not compute variance-covariance matrix.
= "D": Compute variance. (diagonal elements of variance-covariance matrix) (effective if Trans = "N" and M >= N)
= "C": Compute variance-covariance matrix. (effective if Trans = "N" and M >= N)
(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 )
|