|
|
◆ Dgglse()
| Sub Dgglse |
( |
M As |
Long, |
|
|
N As |
Long, |
|
|
P As |
Long, |
|
|
A() As |
Double, |
|
|
B() As |
Double, |
|
|
C() As |
Double, |
|
|
D() As |
Double, |
|
|
X() As |
Double, |
|
|
Info As |
Long |
|
) |
| |
Linear equality-constrained least squares (LSE) problem
- Purpose
- This routine solves the linear equality-constrained least squares (LSE) problem:
minimize || c - Ax ||_2 subject to B*x = d
where A is an m x n matrix, B is a p x n matrix, c is a given m-vector, and d is a given p-vector. It is assumed that p <= n <= m + p, and rank(B) = p and rank( (A) ) = n
( (B) )
These conditions ensure that the LSE problem has a unique solution, which is obtained using a generalized RQ factorization of the matrices (B, A) given by
- Parameters
-
| [in] | M | Number of rows of the matrix A. (M >= 0) |
| [in] | N | Number of columns of the matrices A and B. (N >= 0) (If N = 0, returns without computation) |
| [in] | P | Number of rows of the matrix B. (0 <= P <= N <= M + P) |
| [in,out] | A() | Array A(LA1 - 1, LA2 - 1) (LA1 >= M, LA2 >= N)
[in] M x N matrix A
[out] The elements on and above the diagonal of the array contain the min(M, N) x N upper trapezoidal matrix T. |
| [in,out] | B() | Array B(LB1 - 1, LB2 - 1) (LB1 >= P, LB2 >= N)
[in] P x N matrix B
[out] The upper triangle of the subarray B(0 to P-1, N-P to N-1) contains the P x P upper triangular matrix R. |
| [in,out] | C() | Array C(LC - 1) (LC >= M)
[in] The right hand side vector for the least squares part of the LSE problem.
[out] The residual sum of squares for the solution is given by the sum of squares of elements N-P to M-1 of vector C. |
| [in,out] | D() | Array D(LD - 1) (LD >= P)
[in] The right hand side vector for the constrained equation.
[out] D() is destroyed. |
| [out] | X() | Array X(LX - 1) (LX >= N)
The solution of the LSE problem. |
| [out] | Info | = 0: Successful exit.
= -1: The argument M had an illegal value. (M < 0)
= -2: The argument N had an illegal value. (N < 0)
= -3: The argument P had an illegal value. (P < 0 or P > N or P < N - M)
= -4: The argument A() is invalid.
= -5: The argument B() is invalid.
= -6: The argument C() is invalid.
= -7: The argument D() is invalid.
= -8: The argument X() is invalid.
= 1: The upper triangular factor R associated with B in the generalized RQ factorization of the pair (B, A) is singular, so that rank(B) < P. The least squares solution could not be computed.
= 2: The N-P x N-P part of the upper trapezoidal factor T associated with A in the generalized RQ factorization of the pair (B, A) is singular, so that rank((A^T B^T)^T) < N. The least squares solution could not be computed. |
- Reference
- LAPACK
- Example Program
- Solve the linear equality-constrained least squares (LSE) problem, i.e. minimize || c - Ax ||_2 subject to B*x = d, 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.58 -0.79 0.82 )
B = ( 0.77 0.71 -0.55 )
( -1.36 -1.22 1.66 )
( 0.3884 )
c = ( 0.1120 )
( -0.3644 )
( -0.0002 )
( 1.8250 )
d = ( -1.7058 )
( 3.4904 )
Sub Ex_Dgglse()
Const M = 4, N = 3, P = 3
Dim A(M - 1, N - 1) As Double, B(P - 1, N - 1) As Double
Dim C(M - 1) As Double, D(P - 1) As Double, X(N - 1) As Double
Dim S As Double, Info As Long
A(0, 0) = -1.06: A(0, 1) = 0.48: A(0, 2) = -0.04
A(1, 0) = -1.19: A(1, 1) = 0.73: A(1, 2) = -0.24
A(2, 0) = 1.97: A(2, 1) = -0.89: A(2, 2) = 0.56
A(3, 0) = 0.68: A(3, 1) = -0.53: A(3, 2) = 0.08
B(0, 0) = -0.58: B(0, 1) = -0.79: B(0, 2) = 0.82
B(1, 0) = 0.77: B(1, 1) = 0.71: B(1, 2) = -0.55
B(2, 0) = -1.36: B(2, 1) = -1.22: B(2, 2) = 1.66
C(0) = 0.3884: C(1) = 0.112: C(2) = -0.3644: C(3) = -0.0002
D(0) = 1.825: D(1) = -1.7058: D(2) = 3.4904
Call Dgglse(M, N, P, A(), B(), C(), D(), X(), Info)
S = Dnrm2(M - N + P, C(N - P))
Debug.Print "X =", X(0), X(1), X(2)
Debug.Print "SumSq =", S, "Info =", Info
End Sub
Sub Dgglse(M As Long, N As Long, P As Long, A() As Double, B() As Double, C() As Double, D() As Double, X() As Double, Info As Long) Linear equality-constrained least squares (LSE) problem
Function Dnrm2(N As Long, X_I As Double, Optional IncX As Long=1) As Double ||x||2 (2-norm) (BLAS 1)
- Example Results
X = -0.820000000000002 -0.939999999999998 0.74
SumSq = 7.1082457242971E-15 Info = 0
|