Package org.apache.commons.math.linear

Examples of org.apache.commons.math.linear.EigenDecompositionImpl


   */
  @Override
  public DoubleMatrix2D getPower(final Matrix<?> m, final double p) {
    if (m instanceof DoubleMatrix2D) {
      final RealMatrix temp = CommonsMathWrapper.wrap((DoubleMatrix2D) m);
      final EigenDecomposition eigen = new EigenDecompositionImpl(temp, 0.0);
      final double[] rEigenValues = eigen.getRealEigenvalues();
      final double[] iEigenValues = eigen.getImagEigenvalues();
      final int n = rEigenValues.length;
      final double[][] d = new double[n][n];
      for (int i = n - 1; i >= 0; --i) {
        d[i][i] = Math.pow(rEigenValues[i], p);
        if (iEigenValues[i] != 0.0) {
          throw new NotImplementedException("Cannot handle complex eigenvalues in getPower");
        }
      }
      final RealMatrix res = eigen.getV().multiply((new Array2DRowRealMatrix(d)).multiply(eigen.getVT()));
      return CommonsMathWrapper.unwrap(res);
    }
    throw new IllegalArgumentException("Can only find pow of DoubleMatrix2D; have " + m.getClass());
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.math.linear.EigenDecompositionImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.