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

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

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

Matrix.setColumnLabel介绍

暂无

代码示例

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

m.setColumnLabel(0, "Id");
m.setColumnLabel(1, "Label");
m.setColumnLabel(2, "Link");
m.setColumnLabel(3, "Description");
m.setColumnLabel(4, "Date");
for (int i = 0; i < items.getLength(); i++) {
  Node item = items.item(i);

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

m.setColumnLabel(0, "Id");
m.setColumnLabel(1, "Label");
m.setColumnLabel(2, "Link");
m.setColumnLabel(3, "Description");
m.setColumnLabel(4, "Date");
for (int i = 0; i < items.getLength(); i++) {
  Node item = items.item(i);

代码示例来源: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

@Test
public void testCols() {
  Matrix m1 = Matrix.Factory.zeros(2, 1);
  m1.setLabel("label");
  m1.setColumnLabel(0, "col1");
  Matrix m2 = m1.appendHorizontally(Ret.NEW, Matrix.Factory.zeros(2, 1));
  m2.setColumnLabel(1, "col2");
  assertEquals("label", m2.getLabelObject());
  assertEquals("col1", m2.getColumnLabel(0));
  assertEquals("col2", m2.getColumnLabel(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

plt.setColumnLabel(0, "matrix size");
for (int c = 1; c < plt.getColumnCount(); c++) {
  plt.setColumnLabel(c, matrix.getColumnLabel(c - 1));

代码示例来源: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

m.setRowLabel(3, "row0");
m.setColumnLabel(0, "col0");
m.setColumnLabel(1, "col1");
m.setColumnLabel(2, "col2");
m.setColumnLabel(3, "col3");

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

m.setRowLabel(3, "row1");
m.setColumnLabel(0, "col0");
m.setColumnLabel(1, "col1");
m.setColumnLabel(2, "col2");
m.setColumnLabel(3, "col3");

代码示例来源: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类方法