### SLA_SVDSOL

Solution Vector from SVD

ACTION:
From a given vector and the SVD of a matrix (as obtained from the sla_SVD routine), obtain the solution vector. This routine solves the equation:
 A $\cdot$x = b

where:

 A is a given $m$ (rows) $×n$ (columns) matrix, where $m\ge n$ x is the $n$-vector we wish to find, and b is a given $m$-vector

by means of the Singular Value Decomposition method (SVD).

CALL:
CALL sla_SVDSOL (M, N, MP, NP, B, U, W, V, WORK, X)
##### GIVEN:
 M,N I $m$, $n$, the numbers of rows and columns in matrix A MP,NP I physical dimensions of array containing matrix A B D(M) known vector b U D(MP,NP) array containing $m×n$ matrix U W D(N) $n×n$ diagonal matrix W (diagonal elements only) V D(NP,NP) array containing $n×n$ orthogonal matrix V

##### RETURNED:
 WORK D(N) workspace X D(N) unknown vector x

NOTES:
(1)
In the Singular Value Decomposition method (SVD), the matrix A is first factorized (for example by the routine sla_SVD) into the following components:
 A = U $\cdot$W $\cdot$V${}^{T}$

where:

 A is any $m$ (rows) $×n$ (columns) matrix, where $m>n$ U is an $m×n$ column-orthogonal matrix W is an $n×n$ diagonal matrix with ${w}_{ii}\ge 0$ V${}^{T}$ is the transpose of an $n×n$ orthogonal matrix

Note that $m$ and $n$ are the logical dimensions of the matrices and vectors concerned, which can be located in arrays of larger physical dimensions MP and NP. The solution is then found from the expression:

 x = V $\cdot \phantom{\rule{1em}{0ex}}\left[diag\left(1/$W${}_{j}\right)\right]\cdot \left($U${}^{T}\cdot$b)
(2)
If matrix A is square, and if the diagonal matrix W is not altered, the method is equivalent to conventional solution of simultaneous equations.
(3)
If $m>n$, the result is a least-squares fit.
(4)
If the solution is poorly determined, this shows up in the SVD factorization as very small or zero W${}_{j}$ values. Where a W${}_{j}$ value is small but non-zero it can be set to zero to avoid ill effects. The present routine detects such zero W${}_{j}$ values and produces a sensible solution, with highly correlated terms kept under control rather than being allowed to elope to infinity, and with meaningful values for the other terms.
REFERENCE:
Numerical Recipes, section 2.9.