From f6b8e0eae4374f339487a33e3e4fe5462d5816e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 25 Nov 2017 10:16:00 +0100 Subject: New upstream version 2.0.0 --- numlib/svd.h | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) mode change 100644 => 100755 numlib/svd.h (limited to 'numlib/svd.h') diff --git a/numlib/svd.h b/numlib/svd.h old mode 100644 new mode 100755 index 59b080d..6a89210 --- a/numlib/svd.h +++ b/numlib/svd.h @@ -13,13 +13,44 @@ extern "C" { #endif +/* + + U[] decomposes A[]'s columns into orthogonal, singular vectors. + U[]'s columns are vectors that sum to 1.0, i.e. they leave a vectors normal unchanged. + The inverse of U[] is its transpose. + U[]'s columns corresponding to non-zero W[] are the orthonormal vectors that span + the (input) RANGE space. Columns corresponding to zero W[] are zero. + + W[] will return singlular values, i.e. the weighting of the singular vectors. + It's inverse is is the reciprical of its elements. + + V[] composes the singular vectors back into A[]'s rows. + V[]'s columns and rows are orthonormal. + V[]'s columns corresponding to non-zero W[] are the orthonormal vectors that span + the (output) RANGE space. + v[]'s columns corresponding to zero W[] are the (output) othonormal vectors that span + the NULL space. + The inverse of V[] is its transpose. + + To re-form, A = U.W.Vt, i.e. multiply by transpose of V. + + i.e. mult. input vector[m] by U[] converts to [n] compact, orthogonal + basis vectors. W then scales them appropiately, setting null space + vectors to 0. V[] then transforms from the orthogonal basis vectors + to A[]'s output space. + + To reveal NULL space, make sure n >= m, since U[] vectors corrsponding + to zero's are set to zero. + +*/ + /* Compute Singular Value Decomposition of A = U.W.Vt */ /* Return status value: */ /* 0 - no error */ /* 1 - m < n error */ int svdecomp( -double **a, /* A[0..m-1][0..n-1], return U[][] */ -double *w, /* return W[0..n-1] */ +double **a, /* A[0..m-1][0..n-1], return U[0..m-1][0..n-1] */ +double *w, /* return W[0..n-1] = singular values */ double **v, /* return V[0..n-1][0..n-1] (not transpose!) */ int m, /* Number of equations */ int n /* Number of unknowns */ -- cgit v1.2.3