/** * Validates that the x data and covariance matrix have the same * number of rows and that the covariance matrix is square. * * @param x the [n,k] array representing the x sample * @param covariance the [n,n] array representing the covariance matrix * @throws DimensionMismatchException if the number of rows in x is not equal * to the number of rows in covariance * @throws NonSquareMatrixException if the covariance matrix is not square */ protected void validateCovarianceData(double[][] x, double[][] covariance) { if (x.length != covariance.length) { throw new DimensionMismatchException(x.length, covariance.length); } if (covariance.length > 0 && covariance.length != covariance[0].length) { throw new NonSquareMatrixException(covariance.length, covariance[0].length); } }
/** {@inheritDoc} */ public double getTrace() throws NonSquareMatrixException { final int nRows = getRowDimension(); final int nCols = getColumnDimension(); if (nRows != nCols) { throw new NonSquareMatrixException(nRows, nCols); } double trace = 0; for (int i = 0; i < nRows; ++i) { trace += getEntry(i, i); } return trace; }
/** * @param weight Weight matrix. * @throws NonSquareMatrixException if the argument is not * a square matrix. */ public Weight(RealMatrix weight) { if (weight.getColumnDimension() != weight.getRowDimension()) { throw new NonSquareMatrixException(weight.getColumnDimension(), weight.getRowDimension()); } weightMatrix = weight.copy(); }
/** * @param weight Weight matrix. * @throws NonSquareMatrixException if the argument is not * a square matrix. */ public Weight(RealMatrix weight) { if (weight.getColumnDimension() != weight.getRowDimension()) { throw new NonSquareMatrixException(weight.getColumnDimension(), weight.getRowDimension()); } weightMatrix = weight.copy(); }
/** {@inheritDoc} */ public T getTrace() throws NonSquareMatrixException { final int nRows = getRowDimension(); final int nCols = getColumnDimension(); if (nRows != nCols) { throw new NonSquareMatrixException(nRows, nCols); } T trace = field.getZero(); for (int i = 0; i < nRows; ++i) { trace = trace.add(getEntry(i, i)); } return trace; }
throw new NonSquareMatrixException(getRowDimension(), getColumnDimension());
throw new NonSquareMatrixException(getRowDimension(), getColumnDimension());
/** * Build the transformation to Hessenberg form of a general matrix. * * @param matrix matrix to transform * @throws NonSquareMatrixException if the matrix is not square */ HessenbergTransformer(final RealMatrix matrix) { if (!matrix.isSquare()) { throw new NonSquareMatrixException(matrix.getRowDimension(), matrix.getColumnDimension()); } final int m = matrix.getRowDimension(); householderVectors = matrix.getData(); ort = new double[m]; cachedP = null; cachedPt = null; cachedH = null; // transform matrix transform(); }
/** * Build the transformation to tridiagonal shape of a symmetrical matrix. * <p>The specified matrix is assumed to be symmetrical without any check. * Only the upper triangular part of the matrix is used.</p> * * @param matrix Symmetrical matrix to transform. * @throws NonSquareMatrixException if the matrix is not square. */ TriDiagonalTransformer(RealMatrix matrix) { if (!matrix.isSquare()) { throw new NonSquareMatrixException(matrix.getRowDimension(), matrix.getColumnDimension()); } final int m = matrix.getRowDimension(); householderVectors = matrix.getData(); main = new double[m]; secondary = new double[m - 1]; cachedQ = null; cachedQt = null; cachedT = null; // transform matrix transform(); }
/** * Build the transformation to Schur form of a general real matrix. * * @param matrix matrix to transform * @throws NonSquareMatrixException if the matrix is not square */ SchurTransformer(final RealMatrix matrix) { if (!matrix.isSquare()) { throw new NonSquareMatrixException(matrix.getRowDimension(), matrix.getColumnDimension()); } HessenbergTransformer transformer = new HessenbergTransformer(matrix); matrixT = transformer.getH().getData(); matrixP = transformer.getP().getData(); cachedT = null; cachedP = null; cachedPt = null; // transform matrix transform(); }
throw new NonSquareMatrixException(matrix.getRowDimension(), matrix.getColumnDimension());
if (rows != matrix.getColumnDimension()) { if (raiseException) { throw new NonSquareMatrixException(rows, matrix.getColumnDimension()); } else { return false;
throw new NonSquareMatrixException(matrix.getRowDimension(), matrix.getColumnDimension());
throw new NonSquareMatrixException(matrix.getRowDimension(), matrix.getColumnDimension());
final double absolutePositivityThreshold) { if (!matrix.isSquare()) { throw new NonSquareMatrixException(matrix.getRowDimension(), matrix.getColumnDimension());
throw new NonSquareMatrixException(rm.getRowDimension(), rm.getColumnDimension());
throw new NonSquareMatrixException(rm.getRowDimension(), rm.getColumnDimension());
final int n = m.getRowDimension(); if (m.getColumnDimension() != n) { throw new NonSquareMatrixException(m.getRowDimension(), m.getColumnDimension());
throw new NonSquareMatrixException( transitionMatrix.getRowDimension(), transitionMatrix.getColumnDimension());
/** * Validates that the x data and covariance matrix have the same * number of rows and that the covariance matrix is square. * * @param x the [n,k] array representing the x sample * @param covariance the [n,n] array representing the covariance matrix * @throws DimensionMismatchException if the number of rows in x is not equal * to the number of rows in covariance * @throws NonSquareMatrixException if the covariance matrix is not square */ protected void validateCovarianceData(double[][] x, double[][] covariance) { if (x.length != covariance.length) { throw new DimensionMismatchException(x.length, covariance.length); } if (covariance.length > 0 && covariance.length != covariance[0].length) { throw new NonSquareMatrixException(covariance.length, covariance[0].length); } }