@NotThreadSafe
public abstract class SVD
extends java.lang.Object
Wrapper for SVD libraries.
Currently only provides thin SVD, with subclasses for JLAPACK and netlib-java backends. Support for other SVD styles and other backends, such as JAMA, is TBD.
Typical SVD implementations are O(l*s^2+s^3) where l is the larger matrix dimension and s is the smaller dimension (see e.g. Tony F. Chan, "An Improved Algorithm for Computing the Singular Value Decomposition", ACM Transactions on Mathematmal Software, 1982; David Bau, "Faster SVD for Matrices with small m/n, Cornell TR 94-1414, 1994). Informal timings of the SVD_DGESVD_NETLIB_JAVA backend agree with this. These bounds assume that the internal convergence loop terminates within a fixed number of iterations; if it doesn't then typical SVD implementations bail.
For performance, instances of concrete subclasses may allocate internal work storage, and are not intended to be MT-safe.
Copyright (C) 2008 Marsette A. Vona, III
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Constructor and Description |
---|
SVD() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
checkStatus(int status)
Check if a status code indicates success.
|
static SVD |
cons(java.lang.String impl)
Generic factory.
|
java.lang.String |
getDescription()
Get a human-readable description of this SVD implementation.
|
abstract java.lang.String |
getStatusMessage(int status)
Translate a return status code into a human-readable message.
|
abstract int |
thinSVD(int m,
int n,
double[] a,
double[] s,
double[] u,
double[] vt)
Compute the thin SVD of m x n matrix a.
|
java.lang.String |
toString()
|
public static SVD cons(java.lang.String impl)
Generic factory.
impl
- the simple name of a concrete implementation class,
e.g. "SVD_JLAPACK"java.lang.RuntimeException
- wrapping the reflection exception on failurepublic abstract int thinSVD(int m, int n, double[] a, double[] s, double[] u, double[] vt)
Compute the thin SVD of m x n matrix a.
a = u*s*vt
[m x n] = [m x n] * [maxRank x maxRank] * [maxRank x n]
maxRank = min(m, n)
All matrices are packed column major as in Fortran.
m
- the number of rows in the input matrixn
- the number of columns in the input matrixa
- the input m x n matrix, may be trashed on returns
- maxRank singular values are output here, in decreasing
orderu
- maxRank left singular column vectors, each of
length m, are output herevt
- the right singular row vectors, each of length n, are
output here, filling in an maxRank x n matrixpublic abstract java.lang.String getStatusMessage(int status)
Translate a return status code into a human-readable message.
public abstract boolean checkStatus(int status)
Check if a status code indicates success.
public java.lang.String getDescription()
Get a human-readable description of this SVD implementation.
public java.lang.String toString()
toString
in class java.lang.Object