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

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

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

Matrix.setRowLabel介绍

暂无

代码示例

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

public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
  model.getMatrix().setRowLabel(rowIndex, String.valueOf(aValue));
}

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

public void setValueAt(Object aValue, long rowIndex, long columnIndex) {
  model.getMatrix().setRowLabel(rowIndex, String.valueOf(aValue));
}

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

public static void main(String[] args) throws Exception {
  Matrix m = Matrix.Factory.zeros(ValueType.OBJECT, 5, 5);
  m.randn(Ret.ORIG);
  m.setLabel("test");
  m.setColumnLabel(0, "col0");
  m.setColumnLabel(1, "col1");
  m.setColumnLabel(2, "col2");
  m.setColumnLabel(3, "col3");
  m.setColumnLabel(4, "col4");
  m.setRowLabel(0, "row0");
  m.setRowLabel(1, "row1");
  m.setRowLabel(2, "row2");
  m.setRowLabel(3, "row3");
  m.setRowLabel(4, "row4");
  m.setAsDouble(Double.NaN, 2, 2);
  m.setAsDouble(Double.NEGATIVE_INFINITY, 3, 2);
  System.out.println(m);
  System.out.println(m.includeAnnotation(Ret.NEW, Matrix.COLUMN));
}

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

perCell.setLabel(allmeans.getLabel() + "-percell");
for (int r = 0; r < perCell.getRowCount(); r++) {
  perCell.setRowLabel(r, perCell.getRowLabel(r).split("x")[0]);
scaled.setLabel(allmeans.getLabel() + "-scaled");
for (int r = 0; r < scaled.getRowCount(); r++) {
  scaled.setRowLabel(r, scaled.getRowLabel(r).split("x")[0]);

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

@Test
public void testRows() {
  Matrix m1 = Matrix.Factory.zeros(1, 2);
  m1.setLabel("label");
  m1.setRowLabel(0, "row1");
  Matrix m2 = m1.appendVertically(Ret.NEW, Matrix.Factory.zeros(1, 2));
  m2.setRowLabel(1, "row2");
  assertEquals("label", m2.getLabelObject());
  assertEquals("row1", m2.getRowLabel(0));
  assertEquals("row2", m2.getRowLabel(1));
}

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

public final static void setAnnotation(Matrix m) {
  m.setLabel("label");
  m.setDimensionLabel(Matrix.ROW, "rows");
  m.setDimensionLabel(Matrix.COLUMN, "columns");
  for (int r = 0; r < m.getRowCount(); r++) {
    if (r == 0) {
      continue;
    }
    m.setRowLabel(r, "row" + r);
  }
  for (int c = 0; c < m.getColumnCount(); c++) {
    if (c == 1) {
      continue;
    }
    m.setColumnLabel(c, "col" + c);
  }
}

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

private Matrix getMatrix(ValueType valueType) {
  Matrix m = Matrix.Factory.zeros(valueType, 4, 4);
  m.setRowLabel(0, "row0");
  m.setRowLabel(1, "row1");
  m.setRowLabel(2, "row2");
  m.setRowLabel(3, "row3");
  m.setColumnLabel(0, "col0");
  m.setColumnLabel(1, "col1");
  m.setColumnLabel(2, "col2");
  m.setColumnLabel(3, "col3");
  m.setAsDouble(1, 0, 0);
  m.setAsDouble(2, 0, 1);
  m.setAsDouble(30, 0, 2);
  m.setAsDouble(4, 0, 3);
  m.setAsDouble(5, 1, 0);
  m.setAsDouble(6, 1, 1);
  m.setAsDouble(-700, 1, 2);
  m.setAsDouble(8, 1, 3);
  m.setAsDouble(9, 2, 0);
  m.setAsDouble(1, 2, 1);
  m.setAsDouble(-2, 2, 2);
  m.setAsDouble(3, 2, 3);
  m.setAsDouble(-4, 3, 0);
  m.setAsDouble(5, 3, 1);
  m.setAsDouble(6, 3, 2);
  m.setAsDouble(7, 3, 3);
  return m;
}

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

@Test
public void testReverseAnnotation() throws Exception {
  Matrix m = Matrix.Factory.zeros(10, 10);
  m.setColumnLabel(3, "col3");
  m.setRowLabel(3, "row3");
  m.setColumnLabel(5, "col5");
  m.setRowLabel(5, "row5");
  assertEquals(3, m.getRowForLabel("row3"));
  assertEquals(3, m.getColumnForLabel("col3"));
  assertEquals(5, m.getRowForLabel("row5"));
  assertEquals(5, m.getColumnForLabel("col5"));
  assertEquals(-1, m.getColumnForLabel("col1"));
  assertEquals(-1, m.getRowForLabel("col1"));
}

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

private void export(Matrix matrix) {
  String name = matrix.getLabel();
  for (int r = 0; r < matrix.getRowCount(); r++) {
    matrix.setRowLabel(r, String.valueOf(extractSize(matrix.getRowLabel(r))));

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

private Matrix getResult(ValueType valueType) {
  Matrix m = Matrix.Factory.zeros(valueType, 4, 4);
  if (ValueType.STRING.equals(valueType) || ValueType.OBJECT.equals(valueType)) {
    m.setRowLabel(0, "row2");
    m.setRowLabel(1, "row1");
    m.setRowLabel(2, "row0");
    m.setRowLabel(3, "row3");
  } else {
    m.setRowLabel(0, "row1");
    m.setRowLabel(1, "row2");
    m.setRowLabel(2, "row3");
    m.setRowLabel(3, "row0");

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

private Matrix getResultReverse(ValueType valueType) {
  Matrix m = Matrix.Factory.zeros(valueType, 4, 4);
  if (ValueType.STRING.equals(valueType) || ValueType.OBJECT.equals(valueType)) {
    m.setRowLabel(0, "row3");
    m.setRowLabel(1, "row0");
    m.setRowLabel(2, "row1");
    m.setRowLabel(3, "row2");
  } else {
    m.setRowLabel(0, "row0");
    m.setRowLabel(1, "row3");
    m.setRowLabel(2, "row2");
    m.setRowLabel(3, "row1");

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

@Test
public final void testTransposeNewSmall() throws Exception {
  Matrix m = createMatrixWithAnnotation(2, 3);
  m.setAsDouble(1.0, 0, 0);
  m.setAsDouble(2.0, 0, 1);
  m.setAsDouble(3.0, 0, 2);
  m.setAsDouble(4.0, 1, 0);
  m.setAsDouble(5.0, 1, 1);
  m.setAsDouble(6.0, 1, 2);
  m.setLabel("label");
  m.setRowLabel(1, "row1");
  m.setColumnLabel(2, "col2");
  Matrix r = m.transpose(Ret.NEW);
  assertEquals(getLabel(), m.getRowCount(), r.getColumnCount());
  assertEquals(getLabel(), m.getColumnCount(), r.getRowCount());
  assertEquals(getLabel(), 1.0, r.getAsDouble(0, 0), TOLERANCE);
  assertEquals(getLabel(), 4.0, r.getAsDouble(0, 1), TOLERANCE);
  assertEquals(getLabel(), 2.0, r.getAsDouble(1, 0), TOLERANCE);
  assertEquals(getLabel(), 5.0, r.getAsDouble(1, 1), TOLERANCE);
  assertEquals(getLabel(), 3.0, r.getAsDouble(2, 0), TOLERANCE);
  assertEquals(getLabel(), 6.0, r.getAsDouble(2, 1), TOLERANCE);
  assertEquals(getLabel(), "label", r.getLabel());
  assertEquals(getLabel(), "row1", r.getColumnLabel(1));
  assertEquals(getLabel(), "col2", r.getRowLabel(2));
  if (m instanceof Erasable) {
    ((Erasable) m).erase();
  }
}

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

@Test
public final void testTransposeLinkSmall() throws Exception {
  Matrix m = createMatrixWithAnnotation(2, 3);
  m.setAsDouble(1.0, 0, 0);
  m.setAsDouble(2.0, 0, 1);
  m.setAsDouble(3.0, 0, 2);
  m.setAsDouble(4.0, 1, 0);
  m.setAsDouble(5.0, 1, 1);
  m.setAsDouble(6.0, 1, 2);
  m.setLabel("label");
  m.setRowLabel(1, "row1");
  m.setColumnLabel(2, "col2");
  Matrix r = m.transpose(Ret.LINK);
  assertEquals(getLabel(), m.getRowCount(), r.getColumnCount());
  assertEquals(getLabel(), m.getColumnCount(), r.getRowCount());
  assertEquals(getLabel(), 1.0, r.getAsDouble(0, 0), TOLERANCE);
  assertEquals(getLabel(), 4.0, r.getAsDouble(0, 1), TOLERANCE);
  assertEquals(getLabel(), 2.0, r.getAsDouble(1, 0), TOLERANCE);
  assertEquals(getLabel(), 5.0, r.getAsDouble(1, 1), TOLERANCE);
  assertEquals(getLabel(), 3.0, r.getAsDouble(2, 0), TOLERANCE);
  assertEquals(getLabel(), 6.0, r.getAsDouble(2, 1), TOLERANCE);
  assertEquals(getLabel(), "label", r.getLabel());
  assertEquals(getLabel(), "row1", r.getColumnLabel(1));
  assertEquals(getLabel(), "col2", r.getRowLabel(2));
  if (m instanceof Erasable) {
    ((Erasable) m).erase();
  }
}

相关文章

Matrix类方法