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

    java.lang.Object
      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.

See the SSVD code for a better option `SequentialBigSvd` See also the docs on stochastic projection SVD

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

- generate a good starting seed vector by summing all the rows of the input matrix, and
- compute the trace(inputMatrixt*matrix)

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.

See Also:
  `SequentialBigSvd`

Nested Class Summary
`static class` `LanczosSolver.TimingSection`

Field Summary
`static double` `SAFE_MAX`

Constructor Summary
`LanczosSolver()`

Method Summary
`protected static double` `calculateScaleFactor(Vector nextVector)`
`protected static 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

### SAFE_MAX

    public static final double SAFE_MAX

See Also:
  Constant Field Values

Constructor Detail

### LanczosSolver

    public LanczosSolver()

Method Detail

### solve

    public void solve(LanczosState state,
                      int desiredRank)

### solve

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

### calculateScaleFactor

    protected static double calculateScaleFactor(Vector nextVector)

### orthoganalizeAgainstAllButLast

    protected static void orthoganalizeAgainstAllButLast(Vector nextVector,
                                                         LanczosState state)

Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.