Java Code Examples for org.ejml.data.DenseMatrix64F#getData()
The following examples show how to use
org.ejml.data.DenseMatrix64F#getData() .
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 void gatherRowsAndColumns(final DenseMatrix64F source, final DenseMatrix64F destination, final int[] rowIndices, final int[] colIndices) { final int rowLength = rowIndices.length; final int colLength = colIndices.length; final double[] out = destination.getData(); int index = 0; for (int i = 0; i < rowLength; ++i) { final int rowIndex = rowIndices[i]; for (int j = 0; j < colLength; ++j) { out[index] = source.unsafe_get(rowIndex, colIndices[j]); ++index; } } }
Example 2
Source File: MissingOps.java From beast-mcmc with GNU Lesser General Public License v2.1 | 6 votes |
public static void scatterRowsAndColumns(final DenseMatrix64F source, final DenseMatrix64F destination, final int[] rowIdices, final int[] colIndices, final boolean clear) { if (clear) { Arrays.fill(destination.getData(), 0.0); } final int rowLength = rowIdices.length; final int colLength = colIndices.length; final double[] in = source.getData(); int index = 0; for (int i = 0; i < rowLength; ++i) { final int rowIndex = rowIdices[i]; for (int j = 0; j < colLength; ++j) { destination.unsafe_set(rowIndex, colIndices[j], in[index]); ++index; } } }
Example 3
Source File: WrappedNormalSufficientStatistics.java From beast-mcmc with GNU Lesser General Public License v2.1 | 6 votes |
public WrappedNormalSufficientStatistics(double[] buffer, int index, int dim, DenseMatrix64F Pd, PrecisionType precisionType) { int partialOffset = (dim + precisionType.getMatrixLength(dim)) * index; this.mean = new WrappedVector.Raw(buffer, partialOffset, dim); if (precisionType == PrecisionType.SCALAR) { this.precision = new WrappedMatrix.Raw(Pd.getData(), 0, dim, dim); this.precisionScalar = buffer[partialOffset + dim]; this.variance = null; } else { this.precisionScalar = 1.0; this.precision = new WrappedMatrix.Raw(buffer, partialOffset + dim, dim, dim); this.variance = new WrappedMatrix.Raw(buffer, partialOffset + dim + dim * dim, dim, dim); } }
Example 4
Source File: ContinuousTraitGradientForBranch.java From beast-mcmc with GNU Lesser General Public License v2.1 | 6 votes |
@Override public double[] chainRule(ContinuousDiffusionIntegrator cdi, DiffusionProcessDelegate diffusionProcessDelegate, ContinuousDataLikelihoodDelegate likelihoodDelegate, BranchSufficientStatistics statistics, NodeRef node, final DenseMatrix64F gradQInv, final DenseMatrix64F gradN) { DenseMatrix64F gradient = diffusionProcessDelegate.getGradientVarianceWrtVariance(node, cdi, likelihoodDelegate, gradQInv); if (DEBUG) { System.err.println("gradQ = " + NormalSufficientStatistics.toVectorizedString(gradient)); } return gradient.getData(); }
Example 5
Source File: ContinuousTraitGradientForBranch.java From beast-mcmc with GNU Lesser General Public License v2.1 | 6 votes |
@Override public double[] chainRule(ContinuousDiffusionIntegrator cdi, DiffusionProcessDelegate diffusionProcessDelegate, ContinuousDataLikelihoodDelegate likelihoodDelegate, BranchSufficientStatistics statistics, NodeRef node, final DenseMatrix64F gradQInv, final DenseMatrix64F gradN) { DenseMatrix64F gradQInvDiag = ((OUDiffusionModelDelegate) diffusionProcessDelegate).getGradientVarianceWrtAttenuation(node, cdi, statistics, gradQInv); if (DEBUG) { System.err.println("gradQ = " + NormalSufficientStatistics.toVectorizedString(gradQInv)); } DenseMatrix64F gradNDiag = ((OUDiffusionModelDelegate) diffusionProcessDelegate).getGradientDisplacementWrtAttenuation(node, cdi, statistics, gradN); CommonOps.addEquals(gradQInvDiag, gradNDiag); return gradQInvDiag.getData(); }
Example 6
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 7
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 8
Source File: OUDiffusionModelDelegate.java From beast-mcmc with GNU Lesser General Public License v2.1 | 5 votes |
private double[] actualizeRootGradientDiagonal(ContinuousDiffusionIntegrator cdi, int nodeIndex, DenseMatrix64F gradient) { double[] qi = new double[dim]; cdi.getBranchActualization(getMatrixBufferOffsetIndex(nodeIndex), qi); DenseMatrix64F tmp = new DenseMatrix64F(dim, 1); MissingOps.diagMult(qi, gradient, tmp); return tmp.getData(); }
Example 9
Source File: OUDiffusionModelDelegate.java From beast-mcmc with GNU Lesser General Public License v2.1 | 5 votes |
private double[] actualizeRootGradientFull(ContinuousDiffusionIntegrator cdi, int nodeIndex, DenseMatrix64F gradient) { // q_i double[] qi = new double[dim * dim]; cdi.getBranchActualization(getMatrixBufferOffsetIndex(nodeIndex), qi); DenseMatrix64F Actu = wrap(qi, 0, dim, dim); DenseMatrix64F tmp = new DenseMatrix64F(dim, 1); CommonOps.mult(Actu, gradient, tmp); return tmp.getData(); }
Example 10
Source File: ContinuousTraitGradientForBranch.java From beast-mcmc with GNU Lesser General Public License v2.1 | 5 votes |
@Override public double[] chainRule(ContinuousDiffusionIntegrator cdi, DiffusionProcessDelegate diffusionProcessDelegate, ContinuousDataLikelihoodDelegate likelihoodDelegate, BranchSufficientStatistics statistics, NodeRef node, final DenseMatrix64F gradQInv, final DenseMatrix64F gradN) { DenseMatrix64F gradient = ((AbstractDriftDiffusionModelDelegate) diffusionProcessDelegate).getGradientDisplacementWrtDrift(node, cdi, likelihoodDelegate, gradN); if (DEBUG) { System.err.println("gradQ = " + NormalSufficientStatistics.toVectorizedString(gradient)); } return gradient.getData(); }
Example 11
Source File: ContinuousTraitGradientForBranch.java From beast-mcmc with GNU Lesser General Public License v2.1 | 5 votes |
@Override public double[] chainRule(ContinuousDiffusionIntegrator cdi, DiffusionProcessDelegate diffusionProcessDelegate, ContinuousDataLikelihoodDelegate likelihoodDelegate, BranchSufficientStatistics statistics, NodeRef node, final DenseMatrix64F gradQInv, final DenseMatrix64F gradN) { return gradQInv.getData(); }
Example 12
Source File: CompoundEigenMatrix.java From beast-mcmc with GNU Lesser General Public License v2.1 | 4 votes |
public double[] getEigenVectors() { DenseMatrix64F baseMatrix = wrapSpherical(offDiagonalParameter.getParameterValues(), 0, dim); return baseMatrix.getData(); }
Example 13
Source File: RandomRotation.java From multimedia-indexing with Apache License 2.0 | 3 votes |
/** * Randomly rotates a vector using the random rotation matrix that was created in the constructor. * * @param vector * The initial vector * @return The randomly rotated vector */ public double[] rotate(double[] vector) { DenseMatrix64F transformed = new DenseMatrix64F(1, vector.length); DenseMatrix64F original = DenseMatrix64F.wrap(1, vector.length, vector); CommonOps.mult(original, randomMatrix, transformed); return transformed.getData(); }