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

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

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

Matrix.chol介绍

暂无

代码示例

代码示例来源:origin: h2oai/h2o-2

for( int j = 0; j < i; ++j )
  arr[j][i] = arr[i][j];
CholeskyDecomposition c = new Matrix(arr).chol();
fchol.setSPD(c.isSPD());
arr = c.getL().getArray();

代码示例来源:origin: h2oai/h2o-2

public void test () {
 Log.info("CholTest::test enter");
 for (int sz = 6000; sz < 10000; sz+=2000) {
  Log.info("CholTest::test sz is " + sz);
  DataSetup data = new DataSetup(sz, 12345);
  long start = System.currentTimeMillis();
  CholeskyDecomposition jamaChol = new Matrix(data.xx).chol();
  Log.info("JAMA CHOLESKY [N = " + sz + "] TAKES " + (System.currentTimeMillis() - start) + " MILLISECONDS.");
  if (!jamaChol.isSPD()) continue;
  ForkJoinPool fjp = new ForkJoinPool(32);
  for (int t = 2; t <= 32; t += 2) {
   for (int step : STEPS)
    fjp.invoke(new TestSetup(new DataSetup(data.xx),jamaChol.getL().getArray(),step,t));
  }
 }
 Log.info("CholTest::test exit");
}

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

private CholeskyDecomposition getChol()
{
 if (chol != null)
 {
  return chol;
 }
 chol = covar.chol();
 return chol;
}

代码示例来源: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: lessthanoptimal/Java-Matrix-Benchmark

@Override
  public long process(BenchmarkMatrix[] inputs, BenchmarkMatrix[] outputs, long numTrials) {
    Matrix matA = inputs[0].getOriginal();
    Matrix result = null;
    int N = matA.getColumnDimension();
    long prev = System.nanoTime();
    for( long i = 0; i < numTrials; i++ ) {
      result = matA.chol().solve(Matrix.identity(N,N));
    }
    long elapsed = System.nanoTime()-prev;
    if( outputs != null ) {
      outputs[0] = new JamaBenchmarkMatrix(result);
    }
    return elapsed;
  }
}

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

@Override
  public long process(BenchmarkMatrix[] inputs, BenchmarkMatrix[] outputs, long numTrials) {
    Matrix matA = inputs[0].getOriginal();
    Matrix L = null;
    long prev = System.nanoTime();
    for( long i = 0; i < numTrials; i++ ) {
      CholeskyDecomposition chol = matA.chol();
      if( !chol.isSPD() ) {
        throw new DetectedException("Is not SPD");
      }
      L = chol.getL();
    }
    long elapsed = System.nanoTime()-prev;
    if( outputs != null ) {
      outputs[0] = new JamaBenchmarkMatrix(L);
    }
    return elapsed;
  }
}

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

@Override
public double[] sample(Random rng) {
  final int N = mean.getColumnDimension();
  final Matrix chol = getCovariance().chol().getL();
  final Matrix vec = new Matrix(N, 1);
  for (int i = 0; i < N; i++)
    vec.set(i, 0, rng.nextGaussian());
  final Matrix result = this.mean.plus(chol.times(vec).transpose());
  return result.getArray()[0];
}

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

final Matrix cv = gaussians[i].getCovariance();
final CholeskyDecomposition chol = cv.chol();
Matrix cv_chol;
if (chol.isSPD()) {
  cv_chol = m.chol().getL();

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

@Override
public double[][] sample(int nsamples, Random rng) {
  if (nsamples == 0)
    return new double[0][0];
  final int N = mean.getColumnDimension();
  final Matrix chol = getCovariance().chol().getL();
  final Matrix vec = new Matrix(N, nsamples);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < nsamples; j++)
      vec.set(i, j, rng.nextGaussian());
  final Matrix result = chol.times(vec).transpose();
  for (int i = 0; i < result.getRowDimension(); i++)
    for (int j = 0; j < result.getColumnDimension(); j++)
      result.set(i, j, result.get(i, j) + mean.get(0, j));
  return result.getArray();
}

代码示例来源:origin: cmu-phil/tetrad

CholeskyDecomposition cd = K.chol();
if(!cd.isSPD()) {
  throw new RuntimeException("The covariance Matrix is not SDP, check your covariance function (maybe you mess the noise term..)");

代码示例来源:origin: gov.nist.math/jama

CholeskyDecomposition Chol = A.chol(); 
Matrix L = Chol.getL();
try {

相关文章