Class LanczosSolver

  extended by org.apache.mahout.math.decomposer.lanczos.LanczosSolver

public class LanczosSolver
extends 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 EigenDecomposition 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
Constructor Summary
Method Summary
protected  double calculateScaleFactor(Vector nextVector)
protected  void orthoganalizeAgainstAllButLast(Vector nextVector, LanczosState state)
 void solve(LanczosState state, int desiredRank)
 void solve(LanczosState state, int desiredRank, boolean isSymmetric)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


public static final double SAFE_MAX
See Also:
Constant Field Values
Constructor Detail


public LanczosSolver()
Method Detail


public void solve(LanczosState state,
                  int desiredRank)


public void solve(LanczosState state,
                  int desiredRank,
                  boolean isSymmetric)


protected double calculateScaleFactor(Vector nextVector)


protected void orthoganalizeAgainstAllButLast(Vector nextVector,
                                              LanczosState state)

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