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

◆ WZgels()

Function WZgels ( 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 for complex matrices (full rank) (complex number representation in Excel format)

Purpose
WZgels solves overdetermined or underdetermined complex linear systems involving an M x N matrix A, or its conjugate-transpose, using a QR or LQ factorization of A. It is assumed that A has full rank.

The following options are provided:
  1. If Trans = "N" and M >= N: find the least squares solution of an overdetermined system, i.e., solve the least squares problem
    minimize || B - A*X ||.
  2. If Trans = "N" and M < N: find the minimum norm solution of an underdetermined system A * X = B.
  3. If Trans = "T" and M >= N: find the minimum norm solution of an underdetermined system A^H * X = B.
  4. 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^H*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.

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 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 NrhsColumn Nrhs+1 (if Cov = "D")Columns Nrhs+1 to Nrhs+N (if Cov = "C")
Rows 1 to NLeast squares solution vector xVariance (diagonal elements of variance-covariance matrix)Variance-covariance matrix
Row N+1Residual sum of squares for the solution00
Row N+2Return code (column 1)00
If Trans = "T" and M < N (M+2 x Nrhs)
Column 1 to Nrhs
Rows 1 to MLeast squares solution vector x
Row M+1Residual sum of squares for the solution
Row M+2Return code (column 1)
If Trans = "N" and M <= N (N+1 x Nrhs)
Column 1 to Nrhs
Rows 1 to NMinimum norm solution vector x
Row N+1Return code (column 1)
Id Trans = "T" and M >= N (M+1 x Nrhs)
Column 1 to Nrhs
Rows 1 to MMinimum norm solution vector x
Row M+1Return 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]MNumber of rows of the matrix A. (M >= 1)
[in]NNumber 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
( -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 )

WZgels