org.apache.mahout.math.decomposer.lanczos
Class LanczosSolver

java.lang.Object
  extended by org.apache.mahout.math.decomposer.lanczos.LanczosSolver

public class LanczosSolver
extends java.lang.Object

Simple implementation of the Lanczos algorithm for finding eigenvalues of a symmetric matrix, applied to non-symmetric matrices by applying Matrix.timesSquared(vector) as the "matrix-multiplication" method.

To avoid floating point overflow problems which arise in power-methods like Lanczos, an initial pass is made through the input matrix to

This latter value, being the sum of all of the singular values, is used to rescale the entire matrix, effectively forcing the largest singular value to be strictly less than one, and transforming floating point overflow problems into floating point underflow (ie, very small singular values will become invisible, as they will appear to be zero and the algorithm will terminate).

This implementation uses EigenvalueDecomposition to do the eigenvalue extraction from the small (desiredRank x desiredRank) tridiagonal matrix. Numerical stability is achieved via brute-force: re-orthogonalization against all previous eigenvectors is computed after every pass. This can be made smarter if (when!) this proves to be a major bottleneck. Of course, this step can be parallelized as well.


Nested Class Summary
static class LanczosSolver.TimingSection
           
 
Field Summary
static double SAFE_MAX
           
protected  double scaleFactor
           
 
Constructor Summary
LanczosSolver()
           
 
Method Summary
protected  void calculateScaleFactor(Vector nextVector)
           
protected  Vector getInitialVector(VectorIterable corpus)
           
 double getTimeMillis(LanczosSolver.TimingSection section)
           
 void solve(VectorIterable corpus, int desiredRank, Matrix eigenVectors, java.util.List<java.lang.Double> eigenValues)
           
 void solve(VectorIterable corpus, int desiredRank, Matrix eigenVectors, java.util.List<java.lang.Double> eigenValues, boolean isSymmetric)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SAFE_MAX

public static final double SAFE_MAX
See Also:
Constant Field Values

scaleFactor

protected double scaleFactor
Constructor Detail

LanczosSolver

public LanczosSolver()
Method Detail

solve

public void solve(VectorIterable corpus,
                  int desiredRank,
                  Matrix eigenVectors,
                  java.util.List<java.lang.Double> eigenValues)

solve

public void solve(VectorIterable corpus,
                  int desiredRank,
                  Matrix eigenVectors,
                  java.util.List<java.lang.Double> eigenValues,
                  boolean isSymmetric)

calculateScaleFactor

protected void calculateScaleFactor(Vector nextVector)

getInitialVector

protected Vector getInitialVector(VectorIterable corpus)

getTimeMillis

public double getTimeMillis(LanczosSolver.TimingSection section)


Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.