org.ujmp.core.Matrix.toDoubleArray()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(146)

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

Matrix.toDoubleArray介绍

暂无

代码示例

代码示例来源:origin: davidandrzej/LogicLDA

public void writeTopics(String basefn, Matrix matphi, int topN)
{        
  writeTopics(basefn, matphi.toDoubleArray(), topN);
}

代码示例来源:origin: davidandrzej/LogicLDA

public RelaxedSample(Corpus c, LDAParameters p, DiscreteSample s)
{        
  // Init phi/theta as mean of posteriors from prev sample
  //
  zrelax = new double[c.N][p.T];		
  phi = (s.getPhi(p)).toDoubleArray();
  theta = (s.getTheta(p)).toDoubleArray();
  
  // Init z-relax as posterior given phi/theta
  for(int i = 0; i < s.z.length; i++)
  {            
    double normsum = 0;
    for(int t = 0; t < p.T; t++)
    {
      zrelax[i][t] = theta[c.d[i]][t] * phi[t][c.w[i]];
      assert(!Double.isNaN(zrelax[i][t]));
      normsum += zrelax[i][t]; 
    }
    assert(normsum > 0);
    for(int t = 0; t < p.T; t++)
      zrelax[i][t] /= normsum;                        
  }        
}

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

final double[][] A = Arg.toDoubleArray();
n = (int) Arg.getRowCount();
L = new double[n][n];

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

LU = A.toDoubleArray();
m = (int) A.getRowCount();
n = (int) A.getColumnCount();

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

final double[][] X = B.toDoubleArray();
final int nx = (int) B.getColumnCount();

代码示例来源:origin: davidandrzej/LogicLDA

alpha = matalpha.toDoubleArray()[0];
beta = matbeta.toDoubleArray();

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

QR = A.toDoubleArray();
m = (int) A.getRowCount();
n = (int) A.getColumnCount();

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

final double[][] A = Arg.toDoubleArray();
m = (int) Arg.getRowCount();
n = (int) Arg.getColumnCount();

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

final double[][] X = B.toDoubleArray();

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

final double[][] A = Arg.toDoubleArray();
m = (int) Arg.getRowCount();
n = (int) Arg.getColumnCount();

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

public JScienceDenseDoubleMatrix2D(Matrix matrix) {
  super(matrix.getRowCount(), matrix.getColumnCount());
  this.matrix = Float64Matrix.valueOf(matrix.toDoubleArray());
  if (matrix.getMetaData() != null) {
    setMetaData(matrix.getMetaData().clone());
  }
}

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

public JScienceDenseDoubleMatrix2D(Matrix matrix) {
  super(matrix.getRowCount(), matrix.getColumnCount());
  this.matrix = Float64Matrix.valueOf(matrix.toDoubleArray());
  if (matrix.getMetaData() != null) {
    setMetaData(matrix.getMetaData().clone());
  }
}

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

public MTJDenseDoubleMatrix2D(Matrix m) {
  super(m.getRowCount(), m.getColumnCount());
  if (m instanceof MTJDenseDoubleMatrix2D) {
    this.matrix = ((MTJDenseDoubleMatrix2D) m).matrix.copy();
  } else {
    this.matrix = new DenseMatrix(m.toDoubleArray());
  }
  if (m.getMetaData() != null) {
    setMetaData(m.getMetaData().clone());
  }
}

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

final double[][] A = Arg.toDoubleArray();
n = (int) Arg.getColumnCount();
V = new double[n][n];

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

public MTJDenseDoubleMatrix2D(Matrix m) {
  super(m.getRowCount(), m.getColumnCount());
  if (m instanceof MTJDenseDoubleMatrix2D) {
    this.matrix = ((MTJDenseDoubleMatrix2D) m).matrix.copy();
  } else {
    this.matrix = new DenseMatrix(m.toDoubleArray());
  }
  if (m.getMetaData() != null) {
    setMetaData(m.getMetaData().clone());
  }
}

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

@Test
public final void testToDoubleArraySmall() throws Exception {
  Matrix m = createMatrixWithAnnotation(6, 7);
  m.randn(Ret.ORIG);
  double[][] array = m.toDoubleArray();
  for (int r = 0; r < m.getRowCount(); r++) {
    for (int c = 0; c < m.getColumnCount(); c++) {
      assertEquals(getLabel(), m.getAsDouble(r, c), array[r][c], 0.0);
    }
  }
  if (m instanceof Erasable) {
    ((Erasable) m).erase();
  }
}

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

@Test
public final void testToDoubleArrayLarge() throws Exception {
  if (!isTestLarge()) {
    return;
  }
  Matrix m = createMatrixWithAnnotation(106, 117);
  m.randn(Ret.ORIG);
  double[][] array = m.toDoubleArray();
  for (int r = 0; r < m.getRowCount(); r++) {
    for (int c = 0; c < m.getColumnCount(); c++) {
      assertEquals(getLabel(), m.getAsDouble(r, c), array[r][c], 0.0);
    }
  }
  if (m instanceof Erasable) {
    ((Erasable) m).erase();
  }
}

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

@Test
public final void testToDoubleArray() throws Exception {
  Matrix m = createMatrixWithAnnotation(2, 2);
  m.setAsDouble(1.0, 0, 0);
  m.setAsDouble(2.0, 0, 1);
  m.setAsDouble(3.0, 1, 0);
  m.setAsDouble(4.0, 1, 1);
  double[][] values = m.toDoubleArray();
  assertEquals(getLabel(), 1.0, values[0][0], TOLERANCE);
  assertEquals(getLabel(), 2.0, values[0][1], TOLERANCE);
  assertEquals(getLabel(), 3.0, values[1][0], TOLERANCE);
  assertEquals(getLabel(), 4.0, values[1][1], TOLERANCE);
  if (m instanceof Erasable) {
    ((Erasable) m).erase();
  }
}

相关文章

Matrix类方法