Jama.Matrix.det()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中Jama.Matrix.det()方法的一些代码示例,展示了Matrix.det()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.det()方法的具体详情如下:
包路径:Jama.Matrix
类名称:Matrix
方法名:det

Matrix.det介绍

暂无

代码示例

代码示例来源:origin: ujmp/universal-java-matrix-package

public double det() {
  return matrix.det();
}

代码示例来源:origin: org.ujmp/ujmp-jama

public double det() {
  return matrix.det();
}

代码示例来源:origin: broadgsa/gatk-protected

public void precomputeDenominatorForEvaluation() {
  precomputeInverse();
  cachedDenomLog10 = Math.log10(Math.pow(2.0 * Math.PI, -1.0 * ((double) mu.length) / 2.0)) + Math.log10(Math.pow(sigma.det(), -0.5)) ;
}

代码示例来源:origin: lessthanoptimal/Java-Matrix-Benchmark

@Override
  public long process(BenchmarkMatrix[] inputs, BenchmarkMatrix[] outputs, long numTrials) {
    Matrix matA = inputs[0].getOriginal();
    long prev = System.nanoTime();
    for( long i = 0; i < numTrials; i++ ) {
      matA.det();
    }
    return System.nanoTime()-prev;
  }
}

代码示例来源:origin: com.github.yannrichet/JMathArray

public static double det(double[][] v) {
  return new Matrix(v).det();
}

代码示例来源:origin: senbox-org/s1tbx

public void setClusterCovarianceMatrix(final double[][] Cov) {
    final Matrix CMat = new Matrix(Cov);
    this.logDet = Math.log(Math.max(Math.abs(CMat.det()), Constants.EPS));
    this.invCov = CMat.inverse();
  }
}

代码示例来源:origin: openimaj/openimaj

protected void cacheValues() {
  inv_covar = covar.inverse();
  pdf_const_factor = 1.0 / Math.sqrt((Math.pow((2 * Math.PI), N) * covar.det()));
  chol = covar.chol().getL();
}

代码示例来源:origin: broadgsa/gatk-protected

public void precomputeDenominatorForVariationalBayes( final double sumHyperParameterLambda ) {
  // Variational Bayes calculations from Bishop
  precomputeInverse();
  cachedSigmaInverse.timesEquals( hyperParameter_a );
  double sum = 0.0;
  for(int jjj = 1; jjj <= mu.length; jjj++) {
    sum += Gamma.digamma( (hyperParameter_a + 1.0 - jjj) / 2.0 );
  }
  sum -= Math.log( sigma.det() );
  sum += Math.log(2.0) * mu.length;
  final double lambda = 0.5 * sum;
  final double pi = Gamma.digamma( hyperParameter_lambda ) - Gamma.digamma( sumHyperParameterLambda );
  final double beta = (-1.0 * mu.length) / (2.0 * hyperParameter_b);
  cachedDenomLog10 = (pi / Math.log(10.0)) + (lambda / Math.log(10.0)) + (beta / Math.log(10.0));
}

代码示例来源:origin: us.ihmc/IHMCRoboticsToolkit

inputMatrix.print(5, 5);
  outputVector.print(5, 5);
  System.out.println("LinearRegression::solve: xTransX.det() : " + xTransX.det());
if (Math.abs(xTransX.det()) < 1e-86)    // 1e-12;
   System.out.println("LinearRegression::solve: Determinate of xTransposeX " + xTransX.det() + ", is too small to invert safely");

代码示例来源:origin: openimaj/openimaj

@Override
public double estimateProbability(double[] sample) {
  final int N = mean.getColumnDimension();
  final Matrix inv_covar = getCovariance().inverse();
  final double pdf_const_factor = 1.0 / Math.sqrt((Math.pow((2 * Math.PI), N) * getCovariance().det()));
  final Matrix xm = new Matrix(1, N);
  for (int i = 0; i < N; i++)
    xm.set(0, i, sample[i] - mean.get(0, i));
  final Matrix xmt = xm.transpose();
  final double v = xm.times(inv_covar.times(xmt)).get(0, 0);
  return pdf_const_factor * Math.exp(-0.5 * v);
}

代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit

inputMatrix.print(5, 5);
  outputVector.print(5, 5);
  System.out.println("LinearRegression::solve: xTransX.det() : " + xTransX.det());
if (Math.abs(xTransX.det()) < 1e-86)    // 1e-12;
   System.out.println("LinearRegression::solve: Determinate of xTransposeX " + xTransX.det() + ", is too small to invert safely");

代码示例来源:origin: openimaj/openimaj

@Override
public double estimateLogProbability(double[] sample) {
  final int N = mean.getColumnDimension();
  final Matrix inv_covar = getCovariance().inverse();
  final double cov_det = getCovariance().det();
  final double pdf_const_factor = 1.0 / Math.sqrt((Math.pow((2 * Math.PI), N) * cov_det));
  final Matrix xm = new Matrix(1, N);
  for (int i = 0; i < N; i++)
    xm.set(0, i, sample[i] - mean.get(0, i));
  final Matrix xmt = xm.transpose();
  final double v = xm.times(inv_covar.times(xmt)).get(0, 0);
  return Math.log(pdf_const_factor) + (-0.5 * v);
}

代码示例来源:origin: us.ihmc/IHMCRoboticsToolkit

public static void computePrincipalMomentsOfInertia(Matrix inertiaForSVD, Matrix3d principalAxesRotationToPack, Vector3d principalMomentsOfInertiaToPack)
{
 // Decompose Inertia Matrix:  I = U*sigma*V
 SingularValueDecomposition inertiaSVD = new SingularValueDecomposition(inertiaForSVD);
 Matrix sigma = inertiaSVD.getS();
 //    Matrix U = inertiaSVD.getU();
 Matrix V = inertiaSVD.getV();
 // If determinant is -1.0, then multiply V by -1. Since I = U*sigma*U_Transpose, then I = (-U) * sigma * (-U_Transpose)
 double determinant = V.det();
 if (determinant < 0.0)
 {
   V = V.times(-1.0);
   determinant = -determinant;
 }
 if (Math.abs(determinant - 1.0) > 1e-5)
 {
   throw new RuntimeException("Problem in Link.addEllipsoidFromMassProperties(). Determinant should be 1.0");
 }
 principalMomentsOfInertiaToPack.set(sigma.get(0, 0), sigma.get(1, 1), sigma.get(2, 2));
 principalAxesRotationToPack.set(V.getRowPackedCopy());
}

代码示例来源:origin: openimaj/openimaj

final double divFactor = 1 / Math.sqrt(secondMoments.det());
final EigenvalueDecomposition rdr = secondMoments.times(divFactor).eig();
double d1, d2;

代码示例来源:origin: org.openimaj/core-image

/**
 * Returns a normalisation matrix for this component.
 * 
 * @return A normalisation matrix.
 */
public Matrix normMatrix() {
  final double u20 = calculateMoment(2, 0);
  final double u02 = calculateMoment(0, 2);
  final double u11 = -calculateMoment(1, 1);
  Matrix tf = new Matrix(3, 3);
  tf.set(0, 0, u20);
  tf.set(1, 1, u02);
  tf.set(0, 1, u11);
  tf.set(1, 0, u11);
  tf.set(2, 2, 1);
  tf = tf.inverse();
  tf = tf.times(1 / Math.sqrt(tf.det()));
  tf = MatrixUtils.sqrt(tf);
  tf.set(2, 2, 1);
  return tf;
}

代码示例来源:origin: openimaj/openimaj

/**
 * Returns a normalisation matrix for this component.
 * 
 * @return A normalisation matrix.
 */
public Matrix normMatrix() {
  final double u20 = calculateMoment(2, 0);
  final double u02 = calculateMoment(0, 2);
  final double u11 = -calculateMoment(1, 1);
  Matrix tf = new Matrix(3, 3);
  tf.set(0, 0, u20);
  tf.set(1, 1, u02);
  tf.set(0, 1, u11);
  tf.set(1, 0, u11);
  tf.set(2, 2, 1);
  tf = tf.inverse();
  tf = tf.times(1 / Math.sqrt(tf.det()));
  tf = MatrixUtils.sqrt(tf);
  tf.set(2, 2, 1);
  return tf;
}

代码示例来源:origin: openimaj/openimaj

void metricUpgrade(Matrix R) {
  assert ((R.getRowDimension() == 3) && (R.getColumnDimension() == 3));
  SingularValueDecomposition svd = R.svd();
  Matrix X = svd.getU().times(svd.getV().transpose());
  Matrix W = Matrix.identity(3, 3);
  W.set(2, 2, X.det());
  R.setMatrix(0, 3 - 1, 0, 3 - 1,
      svd.getU().times(W).times(svd.getV().transpose()));
}

代码示例来源:origin: org.openimaj/FaceTracker

void metricUpgrade(Matrix R) {
  assert ((R.getRowDimension() == 3) && (R.getColumnDimension() == 3));
  SingularValueDecomposition svd = R.svd();
  Matrix X = svd.getU().times(svd.getV().transpose());
  Matrix W = Matrix.identity(3, 3);
  W.set(2, 2, X.det());
  R.setMatrix(0, 3 - 1, 0, 3 - 1,
      svd.getU().times(W).times(svd.getV().transpose()));
}

代码示例来源:origin: percyliang/fig

/**
 * To compute the logProb from the suff stats:
 * Expand the bilinear forms (x_i - mean)^T covar^-1 (x_i - mean), and
 * note that the terms (\sum_i x_i^T) covar^-1 (\sum_i x_i) are equal to 
 * aggregatePtwiseProduct(outerproduct sufficient stats, covar^-1)
 * @param stats
 * @return
 */
public double logProb(SuffStats _stats) {
 MultGaussianSuffStats stats = (MultGaussianSuffStats)_stats;
 // TODO: cache the normalizer
 double normalizer = 0.5 * Gaussian.LOG_INV_SQRT_2_PI * stats.dim() - covar.det() * 0.5;
 // TODO : cache this (not that important for now, always id)
 Matrix inv = covar.inverse();
 // t1, t2, t3 and t4 are the terms obtained by expanding the bilinear form
 double t1 = aggregatePtwiseProduct(stats.getMtxOuterProduct(), inv);
 // TODO : cache this
 double t2 = mean.transpose().times(inv).times(mean).get(0, 0) * stats.numPoints();
 // TODO : do some of this in place
 double t3 = - stats.getMtxSum().transpose().times(inv).times(mean).get(0, 0);
 double t4 = - mean.transpose().times(inv).times(stats.getMtxSum()).get(0, 0);
 return (normalizer - 0.5 * (t1 + t2 + t3 + t4));
}
public double logProbObject(double[] x) {

代码示例来源:origin: apache/sis

/**
 * Tests {@link MatrixSIS#inverse()}.
 * SIS implements the {@code inverse} operation as a special case of the {@code solve} operation.
 *
 * @throws NoninvertibleMatrixException if the matrix can not be inverted.
 */
@Test
@DependsOnMethod("testSolve")
public void testInverse() throws NoninvertibleMatrixException {
  initialize(-9063921123024549789L);
  for (int n=0; n<NUMBER_OF_REPETITIONS; n++) {
    prepareNewMatrixSize(random);
    final int numRow = getNumRow();
    final int numCol = getNumCol();
    final double[] elements = createRandomPositiveValues(numRow * numCol);
    final Matrix reference = new Matrix(elements, numCol).transpose();
    if (!(reference.det() >= DETERMINANT_THRESHOLD)) {
      continue; // To close to a singular matrix - search an other one.
    }
    final MatrixSIS matrix = Matrices.create(numRow, numCol, elements);
    assertEqualsJAMA(reference.inverse(), matrix.inverse(), TOLERANCE);
  }
}

相关文章