use of dr.math.matrixAlgebra.SymmetricMatrix in project beast-mcmc by beast-dev.
the class FactorIndependenceOperator method doOperation.
@Override
public double doOperation() {
setupParameters();
getPrecision(precision);
double[][] variance = (new SymmetricMatrix(precision)).inverse().toComponents();
if (randomScan) {
int i = MathUtils.nextInt(LFM.getFactors().getColumnDimension());
randomDraw(i, variance);
}
for (int i = 0; i < LFM.getFactors().getColumnDimension(); i++) {
randomDraw(i, variance);
}
LFM.getFactors().fireParameterChangedEvent();
// To change body of implemented methods use File | Settings | File Templates.
return 0;
}
use of dr.math.matrixAlgebra.SymmetricMatrix in project beast-mcmc by beast-dev.
the class ModeIndependenceOperator method formXtXInverse.
private double[][] formXtXInverse(double[][] X) {
int N = X.length;
int P = X[0].length;
double[][] matrix = new double[P][P];
for (int i = 0; i < P; i++) {
for (int j = 0; j < P; j++) {
double total = 0.0;
for (int k = 0; k < N; k++) {
total += X[k][i] * X[k][j];
}
matrix[i][j] = total;
}
}
// System.err.println("XtX:");
// System.err.println(new Matrix(matrix));
// Take inverse
matrix = new SymmetricMatrix(matrix).inverse().toComponents();
return matrix;
}
use of dr.math.matrixAlgebra.SymmetricMatrix in project beast-mcmc by beast-dev.
the class FactorGibbsOperator method doOperation.
@Override
public double doOperation() {
setupParameters();
getPrecision(precision);
double[][] variance = (new SymmetricMatrix(precision)).inverse().toComponents();
if (randomScan) {
int i = MathUtils.nextInt(LFM.getFactors().getColumnDimension());
randomDraw(i, variance);
}
for (int i = 0; i < LFM.getFactors().getColumnDimension(); i++) {
randomDraw(i, variance);
}
LFM.getFactors().fireParameterChangedEvent();
// To change body of implemented methods use File | Settings | File Templates.
return 0;
}
use of dr.math.matrixAlgebra.SymmetricMatrix in project beast-mcmc by beast-dev.
the class CorrelationToCholesky method inverse.
// values = cholesky
@Override
protected double[] inverse(double[] values) {
WrappedMatrix.WrappedUpperTriangularMatrix L = fillDiagonal(values, dimVector);
SymmetricMatrix R = L.transposedProduct();
return extractUpperTriangular(R);
}
use of dr.math.matrixAlgebra.SymmetricMatrix in project beast-mcmc by beast-dev.
the class CorrelationToCholesky method transform.
// values = correlation
@Override
protected double[] transform(double[] values) {
SymmetricMatrix R = compoundCorrelationSymmetricMatrix(values, dimVector);
double[] L;
try {
L = (new CholeskyDecomposition(R)).getStrictlyUpperTriangular();
} catch (IllegalDimension illegalDimension) {
throw new RuntimeException("Unable to decompose matrix in LKJ inverse transform.");
}
return L;
}
Aggregations