XLPack 6.1
Excel Worksheet Function Numerical Library Reference Manual
Loading...
Searching...
No Matches

◆ WZgelss2()

Function WZgelss2 ( 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 numbers in pairs of cells)

Purpose
WZgelss2 computes the minimum norm solution to a complex linear least squares problem:
minimize || A * X - B ||
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, a real part and an imaginary part are stored in a pair of adjacent cells (a real part in a left cell, and an imaginary part in a right cell). The computed results are stored in the same way.
Returns
If M >= N and Sing = "N" (N+1 x 2Nrhs (Cov = "N"), N+1 x 2Nrhs+1 (Cov = "D") or N+1 x 2Nrhs+2N (Cov = "C"))
Columns 1 to 2NrhsColumn 2Nrhs+1 (if Cov = "D")Columns 2Nrhs+1 to 2Nrhs+2N (if Cov = "C")
Rows 1 to NLeast squares solution vector xVariance (diagonal elements of variance-covariance matrix)Variance-covariance matrix
Row N+1Effective rank (column 1), return code (column 2)00
If M >= N and Sing = "S" (N+1 x 2Nrhs+1 (Cov = "N"), N+1 x 2Nrhs+2 (Cov = "D") or N+1 x 2Nrhs+2N+2 (Cov = "C"))
Columns 1 to 2NrhsColumn 2Nrhs+1Column 2Nrhs+2 (if Cov = "D")Columns 2Nrhs+2 to 2Nrhs+2N+1 (if Cov = "C")
Rows 1 to NLeast squares solution vector xSingular values of A in descending orderVariance (diagonal elements of variance-covariance matrix)Variance-covariance matrix
Row N+1Effective rank (column 1), return code (column 2)000
If M < N (N+1 x 2Nrhs (Sing = "N"), N+1 x 2Nrhs+1 (Sing = "S"))
Columns 1 to 2NrhsColumn 2Nrhs+1 (if SIng = "S")
Rows 1 to NMinimum norm solution vector xSingular values of A in descending order
Row N+1Effective rank (column 1), return code (column 2)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]MNumber of rows of the matrix A. (M >= 1)
[in]NNumber of columns of the matrix A. (N >= 1)
[in]A(M x 2N) M x N coefficient matrix A. (May be rank-deficient)
[in]B(M x 2Nrhs) 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 )

WZgelss2