Java Code Examples for org.ejml.data.DenseMatrix64F#getNumRows()
The following examples show how to use
org.ejml.data.DenseMatrix64F#getNumRows() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MissingOps.java From beast-mcmc with GNU Lesser General Public License v2.1 | 6 votes |
public static double det(DenseMatrix64F mat) { int numCol = mat.getNumCols(); int numRow = mat.getNumRows(); if (numCol != numRow) { throw new IllegalArgumentException("Must be a square matrix."); } else if (numCol <= 6) { return numCol >= 2 ? UnrolledDeterminantFromMinor.det(mat) : mat.get(0); } else { LUDecompositionAlt_D64 alg = new LUDecompositionAlt_D64(); if (alg.inputModified()) { mat = mat.copy(); } return !alg.decompose(mat) ? 0.0D : alg.computeDeterminant().real; } }
Example 2
Source File: MissingOps.java From beast-mcmc with GNU Lesser General Public License v2.1 | 6 votes |
public static double invertAndGetDeterminant(DenseMatrix64F mat, DenseMatrix64F result, boolean log) { final int numCol = mat.getNumCols(); final int numRow = mat.getNumRows(); if (numCol != numRow) { throw new IllegalArgumentException("Must be a square matrix."); } if (numCol <= 5) { if (numCol >= 2) { UnrolledInverseFromMinor.inv(mat, result); } else { result.set(0, 1.0D / mat.get(0)); } double det = numCol >= 2 ? UnrolledDeterminantFromMinor.det(mat) : mat.get(0); return log ? Math.log(det) : det; } else { LUDecompositionAlt_D64 alg = new LUDecompositionAlt_D64(); LinearSolverLu_D64 solver = new LinearSolverLu_D64(alg); if (solver.modifiesA()) { mat = mat.copy(); } if (!solver.setA(mat)) { return Double.NaN; } solver.invert(result); return log ? computeLogDeterminant(alg) : alg.computeDeterminant().real; } }
Example 3
Source File: MissingOps.java From beast-mcmc with GNU Lesser General Public License v2.1 | 5 votes |
public static void blockUnwrap(final DenseMatrix64F block, final double[] destination, final int destinationOffset, final int offsetRow, final int offsetCol, final int nCols) { for (int i = 0; i < block.getNumRows(); i++) { // Rows for (int j = 0; j < block.getNumCols(); j++) { destination[destinationOffset + (i + offsetRow) * nCols + j + offsetCol] = block.get(i, j); } } }
Example 4
Source File: AbstractDiffusionModelDelegate.java From beast-mcmc with GNU Lesser General Public License v2.1 | 5 votes |
public double[] getGradientDisplacementWrtRoot(NodeRef node, ContinuousDiffusionIntegrator cdi, ContinuousDataLikelihoodDelegate likelihoodDelegate, DenseMatrix64F gradient) { boolean fixedRoot = likelihoodDelegate.getRootProcessDelegate().getPseudoObservations() == Double.POSITIVE_INFINITY; if (fixedRoot && tree.isRoot(tree.getParent(node))) { return gradient.getData(); } if (!fixedRoot && tree.isRoot(node)) { return gradient.getData(); } return new double[gradient.getNumRows()]; }
Example 5
Source File: OUDiffusionModelDelegate.java From beast-mcmc with GNU Lesser General Public License v2.1 | 5 votes |
@Override public double[] getGradientDisplacementWrtRoot(NodeRef node, ContinuousDiffusionIntegrator cdi, ContinuousDataLikelihoodDelegate likelihoodDelegate, DenseMatrix64F gradient) { boolean fixedRoot = likelihoodDelegate.getRootProcessDelegate().getPseudoObservations() == Double.POSITIVE_INFINITY; if (fixedRoot && tree.isRoot(tree.getParent(node))) { return actualizeRootGradient(cdi, node.getNumber(), gradient); } if (!fixedRoot && tree.isRoot(node)) { return gradient.getData(); } return new double[gradient.getNumRows()]; }
Example 6
Source File: ContinuousTraitGradientForBranch.java From beast-mcmc with GNU Lesser General Public License v2.1 | 5 votes |
@Override public double[] chainRuleRoot(ContinuousDiffusionIntegrator cdi, DiffusionProcessDelegate diffusionProcessDelegate, ContinuousDataLikelihoodDelegate likelihoodDelegate, BranchSufficientStatistics statistics, NodeRef node, final DenseMatrix64F gradQInv, final DenseMatrix64F gradN) { return new double[gradN.getNumRows()]; }
Example 7
Source File: SafeMultivariateActualizedWithDriftIntegrator.java From beast-mcmc with GNU Lesser General Public License v2.1 | 5 votes |
private static void transformMatrixGeneral(DenseMatrix64F matrix, DenseMatrix64F rotation) { int dim = matrix.getNumRows(); DenseMatrix64F tmp = new DenseMatrix64F(dim, dim); DenseMatrix64F rotationInverse = new DenseMatrix64F(dim, dim); CommonOps.invert(rotation, rotationInverse); CommonOps.mult(rotationInverse, matrix, tmp); CommonOps.multTransB(tmp, rotationInverse, matrix); }
Example 8
Source File: MissingOps.java From beast-mcmc with GNU Lesser General Public License v2.1 | 4 votes |
public static void addToDiagonal(DenseMatrix64F source, double increment) { final int width = source.getNumRows(); for (int i = 0; i < width; ++i) { source.unsafe_set(i, i, source.unsafe_get(i, i) + increment); } }
Example 9
Source File: SafeMultivariateActualizedWithDriftIntegrator.java From beast-mcmc with GNU Lesser General Public License v2.1 | 4 votes |
private static void transformMatrixSymmetric(DenseMatrix64F matrix, DenseMatrix64F rotation) { int dim = matrix.getNumRows(); DenseMatrix64F tmp = new DenseMatrix64F(dim, dim); CommonOps.multTransA(rotation, matrix, tmp); CommonOps.mult(tmp, rotation, matrix); }
Example 10
Source File: SafeMultivariateActualizedWithDriftIntegrator.java From beast-mcmc with GNU Lesser General Public License v2.1 | 4 votes |
public static void transformMatrixBack(DenseMatrix64F matrix, DenseMatrix64F rotation) { int dim = matrix.getNumRows(); DenseMatrix64F tmp = new DenseMatrix64F(dim, dim); CommonOps.multTransB(matrix, rotation, tmp); CommonOps.mult(rotation, tmp, matrix); }