List of usage examples for org.apache.commons.math3.exception MathUnsupportedOperationException MathUnsupportedOperationException
public MathUnsupportedOperationException()
From source file:org.pmad.gmm.MyEDC.java
/** * Computes the square-root of the matrix. * This implementation assumes that the matrix is symmetric and positive * definite./* w w w . j av a 2s . c om*/ * * @return the square-root of the matrix. * @throws MathUnsupportedOperationException if the matrix is not * symmetric or not positive definite. * @since 3.1 */ public RealMatrix getSquareRoot() { if (!isSymmetric) { throw new MathUnsupportedOperationException(); } final double[] sqrtEigenValues = new double[realEigenvalues.length]; for (int i = 0; i < realEigenvalues.length; i++) { final double eigen = realEigenvalues[i]; if (eigen <= 0) { throw new MathUnsupportedOperationException(); } sqrtEigenValues[i] = FastMath.sqrt(eigen); } final RealMatrix sqrtEigen = MatrixUtils.createRealDiagonalMatrix(sqrtEigenValues); final RealMatrix v = getV(); final RealMatrix vT = getVT(); return v.multiply(sqrtEigen).multiply(vT); }
From source file:org.pmad.gmm.MyEDC.java
/** * Gets a solver for finding the A × X = B solution in exact * linear sense.//ww w. j av a 2s.c om * <p> * Since 3.1, eigen decomposition of a general matrix is supported, * but the {@link DecompositionSolver} only supports real eigenvalues. * * @return a solver * @throws MathUnsupportedOperationException if the decomposition resulted in * complex eigenvalues */ public DecompositionSolver getSolver() { if (hasComplexEigenvalues()) { throw new MathUnsupportedOperationException(); } return new Solver(realEigenvalues, imagEigenvalues, eigenvectors); }