numal.lowprecision
Class LinearAlgebra

java.lang.Object
  extended by numal.lowprecision.LinearAlgebra

public class LinearAlgebra
extends Object

References: Wilkinson,J.H., Reinsch,C. : 1971, Handbook of Automatic Computation, Vol. 2, Linear Algebra, Springer-Verlag, Berlin.


Constructor Summary
LinearAlgebra()
           
 
Method Summary
static void hshreabid(float[][] a, int m, int n, float[] d, float[] b, float[] em)
          Reduces an m x n matrix a to a bidiagonal form B.
static void pretfmmat(float[][] a, int m, int n, float[] d)
          Calculates the premultiplying matrix from the intermediate results generated by hshreabid(float[][], int, int, float[], float[], float[]),
static void psttfmmat(float[][] a, int n, float[][] v, float[] b)
          Calculates the postmultiplying matrix from the intermediate results generated by hshreabid(float[][], int, int, float[], float[], float[]),
static int qrisngvaldec(float[][] a, int m, int n, float[] val, float[][] v, float[] em)
          Calculates the singular value decomposition UDV^T of a given matrix A.
static int qrisngvaldecbid(float[] d, float[] b, int m, int n, float[][] u, float[][] v, float[] em)
          Calculates by use of a variant of the QR algorithm the singular value decomposition of an mxn matrix A (m ≥ n), i.e., the mxn matrix U, the nxn diagonal matrix D, and the nxn matrix V for which A=UDV^T, where U^T U = V^T V = I (nxn unit matrix).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinearAlgebra

public LinearAlgebra()
Method Detail

qrisngvaldec

public static int qrisngvaldec(float[][] a,
                               int m,
                               int n,
                               float[] val,
                               float[][] v,
                               float[] em)
Calculates the singular value decomposition UDV^T of a given matrix A. The matrix is first transformed to bidiagonal form by calling hshreabid(float[][], int, int, float[], float[], float[]), the two transforming matrices are calculated by calling psttfmmat(float[][], int, float[][], float[]) and pretfmmat(float[][], int, int, float[]), and finally the singular value decomposition is calculated by qrisngvaldecbid(float[], float[], int, int, float[][], float[][], float[]).

Dependencies

hshreabid(float[][], int, int, float[], float[], float[]), psttfmmat(float[][], int, float[][], float[]), pretfmmat(float[][], int, int, float[]), qrisngvaldecbid(float[], float[], int, int, float[][], float[][], float[]).

References

Method originally from class numal.LinearAlgebra - Lau (2004) section 3.15.2.B Singular Values - Real full matrices p.316.

Parameters:
a - input: the given mxn matrix output: the matrix U in the singular value decomposition UDV^T
m - the number of rows of the matrix a
n - the number of columns of a, precondition: n ≤ m
val - output: the singular values 1 to n
v - output: V^T (transpose of matrix v) in the singular value decomposition
em - input and output parameters (see above)
Returns:
number of singular values not found, i.e., a number not equal to zero if the number of iterations exceeds em[4]

hshreabid

public static void hshreabid(float[][] a,
                             int m,
                             int n,
                             float[] d,
                             float[] b,
                             float[] em)
Reduces an m x n matrix a to a bidiagonal form B. With A=A1, u(1) is so chosen that all elements but the first column of A1' = (I - 2 u(1) u(1)^T / u(1)^T u(1)) A1 are zero; v(1) is so chosen that all elements but the first two of the first row in A1''= (I - 2 v(1) v(1)^T / v(1)^T v(1)) A1' are zero; the first row and column are stripped from A1'' to produce the (m-1) x (n-1) matrix A2 and the process is repeated. Note: this method is a slight improvement of a part of a procedure (svd) of Wilkinson and Reinsch (1971) by skipping a transformation if the column or row is already in the desired form, (i.e., if the sum of the squares of the elements that ought to be zero is smaller than a certain constant). In svd the transformation is skipped only if the norm of the full row or column is small enough. As a result, some ill-defined transformations are skipped in hshreabid(float[][], int, int, float[], float[], float[]). Moreover, if a transformation is skipped, a zero is not stored in the diagonal or superdiagonal, but the value that would have been found if the column or row were in the desired form already is stored.

Dependencies

Basic.tammat(int, int, int, int, float[][], float[][]), Basic.mattam(int, int, int, int, float[][], float[][]), Basic.elmcol(int, int, int, int, float[][], float[][], float), Basic.elmrow(int, int, int, int, float[][], float[][], float)

References

Method originally from class numal.LinearAlgebra - Lau (2004) section 3.12.1.A Other transformations : To bidiagonal form - real matrices p.212.

Parameters:
a - input: m by n matrix output: data concerning the premultiplying and postmultiplying matrices
m - number of rows
n - number of columns
d - output: diagonal of the bidiagonal matrix B
b - output: super diagonal of the bidiagonal matrix B
em - input: em[0] machine precision output: em[1] infinity norm of original matrix

psttfmmat

public static void psttfmmat(float[][] a,
                             int n,
                             float[][] v,
                             float[] b)
Calculates the postmultiplying matrix from the intermediate results generated by hshreabid(float[][], int, int, float[], float[], float[]),

Dependencies

Basic.elmcol(int, int, int, int, float[][], float[][], float), Basic.matmat(int, int, int, int, float[][], float[][])

References

Method originally from class numal.LinearAlgebra - Lau (2004) section 3.12.1.B Other transformations : To bidiagonal form - real matrices p.214.

Parameters:
a - data concerning postmultiplying matrix, as generated by hshreabid(float[][], int, int, float[], float[], float[]) (nxn)
n - number of columns and rows of a
v - output: postmultiplying matrix (nxn)
b - superdiagonal of A as generated by hshreabid(float[][], int, int, float[], float[], float[]) are in the [1:n-1] elements of this array

pretfmmat

public static void pretfmmat(float[][] a,
                             int m,
                             int n,
                             float[] d)
Calculates the premultiplying matrix from the intermediate results generated by hshreabid(float[][], int, int, float[], float[], float[]),

Dependencies

Basic.elmcol(int, int, int, int, float[][], float[][], float), Basic.tammat(int, int, int, int, float[][], float[][])

References

Method originally from class numal.LinearAlgebra - Lau (2004) section 3.12.1.C Other transformations : To bidiagonal form - real matrices p.214.

Parameters:
a - input: data concerning premultiplying matrix, as generated by hshreabid(float[][], int, int, float[], float[], float[]) (nxn) output: premultiplying matrix
m - number of rows of a
n - number of columns of a, precondition: n ≤ m
d - diagonal as generated by hshreabid(float[][], int, int, float[], float[], float[]) (1xn)

qrisngvaldecbid

public static int qrisngvaldecbid(float[] d,
                                  float[] b,
                                  int m,
                                  int n,
                                  float[][] u,
                                  float[][] v,
                                  float[] em)
Calculates by use of a variant of the QR algorithm the singular value decomposition of an mxn matrix A (m ≥ n), i.e., the mxn matrix U, the nxn diagonal matrix D, and the nxn matrix V for which A=UDV^T, where U^T U = V^T V = I (nxn unit matrix). It is assumed that A has been reduced to bidiagonal form form by preliminary pre- and post-multiplication by matrices of the form I - 2 u u^T / u^T u by use of hshreabid(float[][], int, int, float[], float[], float[]). Note: Matrix A is input as a synthesis of d, b vectors and u and v matrices.

Dependencies

Basic.rotcol(int, int, int, int, float[][], float, float).

References

Method originally from class numal.LinearAlgebra - Lau (2004) section 3.15.1.B Singular Values - Real bidiagonal matrices p.312. Wilkinson,J.H., Reinsch,C. : 1971, Handbook of Automatic Computation, Vol. 2, Linear Algebra, Springer-Verlag, Berlin.

Parameters:
d - input: diagonal of the bidiagonal matrix output: singular values
b - superdiagonal of the bidiagonal matrix in the [1:n-1] elements of this array
m - rows of matrix U
n - columns of matrix U (also size of matrix V, vector d and b),
u - input: premultiplying matrix as produced by pretfmmat(float[][], int, int, float[]) output: premultiplying matrix U of the singular value decomposition UDV^T
v - input: transpose of postmultiplying matrix as produced by psttfmmat(float[][], int, float[][], float[]) output: transpose of postmultiplying matrix V of the singular value decomposition UDV^T
em - see description above
Returns:
number of singular values not found if the number of iterations exceeds em[4] (zero if iterations ≤ em[4])