@Override public double get(int row, int column) { if (row == column) return 1; return super.get(row, column); }
@Override public UpperTriangDenseMatrix copy() { return new UpperTriangDenseMatrix(this); }
@Override public void add(int row, int column, double value) { if (column == row) throw new IllegalArgumentException("column == row"); super.add(row, column, value); }
int M = triangularMatrix.numRows(); int N = triangularMatrix.numColumns(); int maxIndex = (M < N) ? M : N; for (int i = 0; i < maxIndex; i++) double eigenvalue = triangularMatrix.get(i, i); if (eigenvalue < 0.0)
/** * Solves for <code>B</code>, overwriting it on return */ public DenseMatrix solve(DenseMatrix B) throws MatrixNotSPDException { if (notspd) throw new MatrixNotSPDException(); if (n != B.numRows()) throw new IllegalArgumentException("n != B.numRows()"); intW info = new intW(0); if (upper) LAPACK.getInstance().dpotrs(UpLo.Upper.netlib(), Cu.numRows(), B.numColumns(), Cu.getData(), Matrices.ld(Cu.numRows()), B.getData(), Matrices.ld(Cu.numRows()), info); else LAPACK.getInstance().dpotrs(UpLo.Lower.netlib(), Cl.numRows(), B.numColumns(), Cl.getData(), Matrices.ld(Cl.numRows()), B.getData(), Matrices.ld(Cl.numRows()), info); if (info.val < 0) throw new IllegalArgumentException(); return B; }
new UpperTriangDenseMatrix(H, i, false).solve(s, s); for (int j = 0; j < i; j++) x.add(s.get(j), v[j]);
int M = triangularMatrix.numRows(); int N = triangularMatrix.numColumns(); int maxIndex = (M < N) ? M : N; for (int i = 0; i < maxIndex; i++) double eigenvalue = triangularMatrix.get(i, i); if (eigenvalue < 0.0)
/** * Solves for <code>B</code>, overwriting it on return */ public DenseMatrix solve(DenseMatrix B) throws MatrixNotSPDException { if (notspd) throw new MatrixNotSPDException(); if (n != B.numRows()) throw new IllegalArgumentException("n != B.numRows()"); intW info = new intW(0); if (upper) LAPACK.getInstance().dpotrs(UpLo.Upper.netlib(), Cu.numRows(), B.numColumns(), Cu.getData(), Matrices.ld(Cu.numRows()), B.getData(), Matrices.ld(Cu.numRows()), info); else LAPACK.getInstance().dpotrs(UpLo.Lower.netlib(), Cl.numRows(), B.numColumns(), Cl.getData(), Matrices.ld(Cl.numRows()), B.getData(), Matrices.ld(Cl.numRows()), info); if (info.val < 0) throw new IllegalArgumentException(); return B; }
new UpperTriangDenseMatrix(H, i, false).solve(s, s); for (int j = 0; j < i; j++) x.add(s.get(j), v[j]);
int M = triangularMatrix.numRows(); int N = triangularMatrix.numColumns(); int maxIndex = (M < N) ? M : N; for (int i = 0; i < maxIndex; i++) double eigenvalue = triangularMatrix.get(i, i); if (eigenvalue < 0.0)
@Override public double get(int row, int column) { if (row == column) return 1; return super.get(row, column); }
@Override public UpperTriangDenseMatrix copy() { return new UpperTriangDenseMatrix(this); }
@Override public void add(int row, int column, double value) { if (column == row) throw new IllegalArgumentException("column == row"); super.add(row, column, value); }
/** * Generates the estimator based on the given observations and weight vector. * Equal weights are assumed if the weight vector is null. */ @Override public void estimate(double[][] observations, double[] weights) { if (weights == null) { weights = new double[observations.length]; for (int i = 0; i < weights.length; i++) { weights[i] = 1.0; } } DenseVector weightVector = new DenseVector(weights); weightVector = weightVector.scale(1.0 / weightVector.norm(Vector.Norm.One)); mean = weightedMean(observations, weightVector); Matrix cov = weightedCovariance(observations, weightVector, mean); // Compute inverse of covariance matrix DenseCholesky chol = new DenseCholesky(observations[0].length, true).factor((UpperSPDDenseMatrix)cov); covarianceInverse = new UpperSPDDenseMatrix(chol.solve(Matrices.identity(observations[0].length))); double logDeterminant = 0; for (int i = 0; i < observations[0].length; i++) { logDeterminant += Math.log(chol.getU().get(i, i)); } logDeterminant *= 2; lnconstant = -(Log2PI * observations[0].length + logDeterminant) * 0.5; }
/** * Returns the upper triangular factor */ public UpperTriangDenseMatrix getU() { return new UpperTriangDenseMatrix(getLU(), false); }
/** * Generates the estimator based on the given observations and weight vector. * Equal weights are assumed if the weight vector is null. */ @Override public void estimate(double[][] observations, double[] weights) { if (weights == null) { weights = new double[observations.length]; for (int i = 0; i < weights.length; i++) { weights[i] = 1.0; } } DenseVector weightVector = new DenseVector(weights); weightVector = weightVector.scale(1.0 / weightVector.norm(Vector.Norm.One)); mean = weightedMean(observations, weightVector); Matrix cov = weightedCovariance(observations, weightVector, mean); // Compute inverse of covariance matrix DenseCholesky chol = new DenseCholesky(observations[0].length, true).factor((UpperSPDDenseMatrix)cov); covarianceInverse = new UpperSPDDenseMatrix(chol.solve(Matrices.identity(observations[0].length))); double logDeterminant = 0; for (int i = 0; i < observations[0].length; i++) { logDeterminant += Math.log(chol.getU().get(i, i)); } logDeterminant *= 2; lnconstant = -(Log2PI * observations[0].length + logDeterminant) * 0.5; }
/** * Returns the upper triangular factor */ public UpperTriangDenseMatrix getU() { return new UpperTriangDenseMatrix(getLU(), false); }
logDeterminant += Math.log(chol.getU().get(i, i));