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

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

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

Matrix.setAsDouble介绍

暂无

代码示例

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

@Override
  public void step(int i) {
    for (int c = 0; c < count && c <= i; c++) {
      double value = getDouble(i, c);
      result.setAsDouble(value, i, c);
      result.setAsDouble(value, c, i);
    }
  }
};

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

public static Matrix stringToVector(String string, int size) {
    Matrix m = Matrix.Factory.zeros(size, 1);
    StringTokenizer st = new StringTokenizer(string, " \t\n\r\f,.:;?![]'");
    while (st.hasMoreElements()) {
      long index = Math.abs(st.nextElement().toString().toLowerCase().hashCode()) % size;
      m.setAsDouble(m.getAsDouble(index, 0) + 1, index, 0);
    }
    return m;
  }
}

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

public static final Matrix createBagOfWordsVector(String string, List<String> dictionary) {
  Matrix m = Matrix.Factory.zeros(dictionary.size(), 1);
  StringTokenizer st = new StringTokenizer(string, " \t\n\r\f,.:;?![]'");
  while (st.hasMoreElements()) {
    long index = dictionary.indexOf(st.nextElement());
    m.setAsDouble(m.getAsDouble(index, 0) + 1, index, 0);
  }
  return m;
}

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

public final Matrix getTestMatrix() throws Exception {
  Matrix m = createMatrixWithAnnotation(3, 3);
  m.setAsDouble(1.0, 0, 0);
  m.setAsDouble(3.0, 1, 0);
  m.setAsDouble(4.0, 1, 1);
  m.setAsDouble(2.0, 2, 1);
  m.setAsDouble(-2.0, 1, 2);
  return m;
}

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

public void step(int i) {
    for (int c = 0; c < cols; c++) {
      result.setAsDouble(Math.tanh(getAsDouble(i, c)), i, c);
    }
  }
};

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

public final static void setRandnSymmetric(Matrix a) {
  Random random = new Random();
  int rows = (int) a.getRowCount();
  int cols = (int) a.getColumnCount();
  for (int r = 0; r < rows; r++) {
    for (int c = 0; c < cols && c <= r; c++) {
      double f = random.nextGaussian();
      a.setAsDouble(f, r, c);
      a.setAsDouble(f, c, r);
    }
  }
}

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

public Long call() throws Exception {
  Matrix newColumn = replaceInColumn(getSource(), bestGuess, column);
  synchronized (imputed) {
    for (int r = 0; r < newColumn.getRowCount(); r++) {
      imputed.setAsDouble(newColumn.getAsDouble(r, 0), r, column);
    }
  }
  return column;
}

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

public Long call() throws Exception {
  Matrix newColumn = replaceInColumn(getSource(), firstGuess, column);
  for (int r = 0; r < newColumn.getRowCount(); r++) {
    imputed.setAsDouble(newColumn.getAsDouble(r, 0), r, column);
  }
  return column;
}

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

public final static void setRandSymmetric(Matrix a) {
  Random random = new Random();
  int rows = (int) a.getRowCount();
  int cols = (int) a.getColumnCount();
  for (int r = 0; r < rows; r++) {
    for (int c = 0; c < cols && c <= r; c++) {
      double f = random.nextDouble();
      a.setAsDouble(f, r, c);
      a.setAsDouble(f, c, r);
    }
  }
}

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

public Matrix replaceMissingBy(Matrix matrix) {
  Matrix ret = Matrix.Factory.zeros(getSize());
  for (long[] c : allCoordinates()) {
    double v = getAsDouble(c);
    if (MathUtil.isNaNOrInfinite(v)) {
      ret.setAsDouble(matrix.getAsDouble(c), c);
    } else {
      ret.setAsDouble(getAsDouble(c), c);
    }
  }
  return ret;
}

代码示例来源:origin: jdmp/java-data-mining-package

public final Sample classificationSample(Matrix input, int classId, int classCount) {
  Sample s = new DefaultSample();
  s.put(Sample.INPUT, input);
  Matrix target = Matrix.Factory.zeros(1, classCount);
  target.setAsDouble(1, 0, classId);
  s.put(Sample.TARGET, target);
  return s;
}

代码示例来源:origin: jdmp/java-data-mining-package

public Matrix predictOne(Matrix input) {
  input = input.toColumnVector(Ret.NEW);
  Matrix x = Matrix.Factory.zeros(1, input.getColumnCount() + 1);
  for (int c = 0; c < input.getColumnCount(); c++) {
    x.setAsDouble(input.getAsDouble(0, c), 0, c + 1);
  }
  x = x.minus(mean).divide(std);
  x.setAsDouble(1, 0, 0);
  Matrix result = x.mtimes(getParameterMatrix());
  return result;
}

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

public final static void setAscending(Matrix source) {
  for (int r = 0, v = 1; r < source.getRowCount(); r++) {
    for (int c = 0; c < source.getColumnCount(); c++) {
      source.setAsDouble(v++, r, c);
    }
  }
}

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

public Matrix[] lu() {
  LUDecomposition lu = new LUDecomposition(matrix);
  Matrix l = new JamaDenseDoubleMatrix2D(lu.getL());
  Matrix u = new JamaDenseDoubleMatrix2D(lu.getU());
  int m = (int) getRowCount();
  int[] piv = lu.getPivot();
  Matrix p = new JamaDenseDoubleMatrix2D(m, m);
  for (int i = 0; i < m; i++) {
    p.setAsDouble(1, i, piv[i]);
  }
  return new Matrix[] { l, u, p };
}

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

public Matrix calcOrig() {
  if (!Coordinates.equals(getSource().getSize(), getSize())) {
    throw new RuntimeException(
        "Cannot change Matrix size. Use calc(Ret.NEW) or calc(Ret.LINK) instead.");
  }
  final Matrix matrix = getSource();
  for (final long[] c : getSource().allCoordinates()) {
    matrix.setAsDouble(getDouble(c), c);
  }
  getSource().fireValueChanged();
  return getSource();
}

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

public Matrix[] lu() {
  LUDecomposition lu = new LUDecomposition(matrix);
  Matrix l = new JamaDenseDoubleMatrix2D(lu.getL());
  Matrix u = new JamaDenseDoubleMatrix2D(lu.getU());
  int m = (int) getRowCount();
  int[] piv = lu.getPivot();
  Matrix p = new JamaDenseDoubleMatrix2D(m, m);
  for (int i = 0; i < m; i++) {
    p.setAsDouble(1, i, piv[i]);
  }
  return new Matrix[] { l, u, p };
}

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

public Matrix calcNew() {
  Matrix result = DoubleMatrix2D.Factory.zeros(getSize()[ROW], getSize()[COLUMN]);
  for (long[] c : result.allCoordinates()) {
    result.setAsDouble(getDouble(c), c);
  }
  if (getMetaData() != null) {
    result.setMetaData(getMetaData().clone());
  }
  return result;
}

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

@Test
public void testGet() {
  Matrix matrix = Matrix.Factory.zeros(M1ROWS, M1COLS);
  setValues(matrix);
  for (int row = 0; row < M1ROWS; ++row) {
    for (int col = 0; col < M1COLS; ++col) {
      matrix.setAsDouble(row + col, row, col);
      assertEquals(row + col, (int) matrix.getAsDouble(row, col));
    }
  }
}

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

@Test
public void testNotEqualsValue() {
  Matrix matrix1 = Matrix.Factory.zeros(M1ROWS, M1COLS);
  setValues(matrix1);
  Matrix matrix2 = Matrix.Factory.zeros(M1ROWS, M1COLS);
  setValues(matrix2);
  matrix2.setAsDouble(1.00001 * matrix2.getAsDouble(1, 1), 1, 1);
  boolean result = matrix1.equals(matrix2);
  assertFalse(result);
}

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

@Test
public final void testSize() throws Exception {
  Matrix m = createMatrixWithAnnotation(21, 12);
  m.setAsDouble(1.0, 20, 11);
  assertEquals(getLabel(), 21, m.getRowCount());
  assertEquals(getLabel(), 12, m.getColumnCount());
  if (m instanceof Erasable) {
    ((Erasable) m).erase();
  }
}

相关文章

Matrix类方法