|
|
◆ WZgelss()
| Function WZgelss |
( |
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 for complex matrices using the singular value decomposition (SVD) (complex number representation in Excel format)
- Purpose
- WZgelss computes the minimum norm solution to a complex 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.
To represent complex numbers in Excel cells, complex number format in Excel (e.g. 2.5+1i) is used. Worksheet function Complex can be used to input complex numbers into cells.
- 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
( -0.82+0.83i 0.18-0.94i -0.18-0.12i )
A = ( -0.76-0.24i 0.57-0.16i -0.08-0.27i )
( 1.90+0.26i -0.98+0.54i 0.21+0.28i )
( 0.50-0.30i -0.31+0.37i 0.22+0.19i )
( 1.7126-0.6648i )
B = ( 0.8697+0.7604i )
( -2.1048-1.6171i )
( -0.9297+0.1252i )
|