/** * @param n Number of rows. * @param m Number of columns. * @return n-by-m matrix of zero values. */ private static RealMatrix zeros(int n, int m) { return new Array2DRowRealMatrix(n, m); }
/** * @param n Number of rows. * @param m Number of columns. * @return n-by-m matrix of zero values. */ private static RealMatrix zeros(int n, int m) { return new Array2DRowRealMatrix(n, m); }
/** * Add the covariance data. * * @param omega the [n,n] array representing the covariance */ protected void newCovarianceData(double[][] omega){ this.Omega = new Array2DRowRealMatrix(omega); this.OmegaInverse = null; }
/** * Get the converted matrix. * * @return the converted matrix. */ Array2DRowRealMatrix getConvertedMatrix() { return new Array2DRowRealMatrix(data, false); }
/** * Get the converted matrix. * * @return the converted matrix. */ Array2DRowRealMatrix getConvertedMatrix() { return new Array2DRowRealMatrix(data, false); } }
/** {@inheritDoc} */ @Override public RealMatrix createMatrix(final int rowDimension, final int columnDimension) throws NotStrictlyPositiveException { return new Array2DRowRealMatrix(rowDimension, columnDimension); }
/** * @param n Number of rows. * @param m Number of columns. * @return n-by-m matrix filled with 1. */ private static RealMatrix ones(int n, int m) { final double[][] d = new double[n][m]; for (int r = 0; r < n; r++) { Arrays.fill(d[r], 1); } return new Array2DRowRealMatrix(d, false); }
/** * @param n Number of rows. * @param m Number of columns. * @return n-by-m matrix filled with 1. */ private static RealMatrix ones(int n, int m) { final double[][] d = new double[n][m]; for (int r = 0; r < n; r++) { Arrays.fill(d[r], 1); } return new Array2DRowRealMatrix(d, false); }
/** {@inheritDoc} */ public RealMatrix computeJacobian(final double[] params) { return new Array2DRowRealMatrix(jacobian.value(params), false); } }
/** {@inheritDoc} */ @Override public RealMatrix copy() { return new Array2DRowRealMatrix(copyOut(), false); }
public SpeakerCluster(Segment s, Array2DRowRealMatrix featureMatrix, double bicValue) { this.segmentSet = new TreeSet<Segment>(); this.featureMatrix = new Array2DRowRealMatrix(featureMatrix.getData()); this.bicValue = bicValue; addSegment(s); }
public SpeakerCluster(SpeakerCluster c) { this.segmentSet = new TreeSet<Segment>(); this.featureMatrix = new Array2DRowRealMatrix(c.getFeatureMatrix().getData()); Iterator<Segment> it = c.segmentSet.iterator(); while (it.hasNext()) this.addSegment(it.next()); }
protected double[][] evaluate(double[][] d1) throws EvaluationException { Array2DRowRealMatrix temp = new Array2DRowRealMatrix(d1); return temp.transpose().getData(); } };
protected double[][] evaluate(double[][] d1, double[][] d2) throws EvaluationException{ Array2DRowRealMatrix first = new Array2DRowRealMatrix(d1); Array2DRowRealMatrix second = new Array2DRowRealMatrix(d2); try { MatrixUtils.checkMultiplicationCompatible(first, second); } catch (DimensionMismatchException e) { throw new EvaluationException(ErrorEval.VALUE_INVALID); } return first.multiply(second).getData(); } };
protected double[][] evaluate(double[][] d1) throws EvaluationException { if (d1.length != d1[0].length) { throw new EvaluationException(ErrorEval.VALUE_INVALID); } Array2DRowRealMatrix temp = new Array2DRowRealMatrix(d1); return MatrixUtils.inverse(temp).getData(); } };
protected double[][] evaluate(double[][] d1) throws EvaluationException { if (d1.length != d1[0].length) { throw new EvaluationException(ErrorEval.VALUE_INVALID); } double result[][] = new double[1][1]; Array2DRowRealMatrix temp = new Array2DRowRealMatrix(d1); result[0][0] = (new LUDecomposition(temp)).getDeterminant(); return result; } };
/** * @param m Input matrix. * @return Matrix representing the element-wise square root of m. */ private static RealMatrix sqrt(final RealMatrix m) { final double[][] d = new double[m.getRowDimension()][m.getColumnDimension()]; for (int r = 0; r < m.getRowDimension(); r++) { for (int c = 0; c < m.getColumnDimension(); c++) { d[r][c] = FastMath.sqrt(m.getEntry(r, c)); } } return new Array2DRowRealMatrix(d, false); }
/** * @param m Input matrix * @return Matrix representing the element-wise logarithm of m. */ private static RealMatrix log(final RealMatrix m) { final double[][] d = new double[m.getRowDimension()][m.getColumnDimension()]; for (int r = 0; r < m.getRowDimension(); r++) { for (int c = 0; c < m.getColumnDimension(); c++) { d[r][c] = FastMath.log(m.getEntry(r, c)); } } return new Array2DRowRealMatrix(d, false); }
/** * @param m Input matrix * @return Matrix representing the element-wise logarithm of m. */ private static RealMatrix log(final RealMatrix m) { final double[][] d = new double[m.getRowDimension()][m.getColumnDimension()]; for (int r = 0; r < m.getRowDimension(); r++) { for (int c = 0; c < m.getColumnDimension(); c++) { d[r][c] = FastMath.log(m.getEntry(r, c)); } } return new Array2DRowRealMatrix(d, false); }
double computeDistance(SpeakerCluster c1, SpeakerCluster c2) { int rowDim = c1.getFeatureMatrix().getRowDimension() + c2.getFeatureMatrix().getRowDimension(); int colDim = c1.getFeatureMatrix().getColumnDimension(); Array2DRowRealMatrix combinedFeatures = new Array2DRowRealMatrix(rowDim, colDim); combinedFeatures.setSubMatrix(c1.getFeatureMatrix().getData(), 0, 0); combinedFeatures.setSubMatrix(c2.getFeatureMatrix().getData(), c1.getFeatureMatrix() .getRowDimension(), 0); double bicValue = getBICValue(combinedFeatures); double d = Segment.FEATURES_SIZE; double penalty = 0.5 * (d + 0.5 * d * (d + 1)) * Math.log(combinedFeatures.getRowDimension()) * 2; return bicValue - c1.getBicValue() - c2.getBicValue() - penalty; }