org.apache.mahout.math.Matrix.columnSize()方法的使用及代码示例

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

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

Matrix.columnSize介绍

暂无

代码示例

代码示例来源:origin: apache/mahout

@Test(expected = IndexException.class)
public void testSetOver() {
 for (int row = 0; row < test.rowSize() + 1; row++) {
  for (int col = 0; col < test.columnSize(); col++) {
   test.set(row, col, 1.23);
  }
 }
}

代码示例来源:origin: apache/mahout

@Test(expected = IndexException.class)
public void testSetUnder() {
 for (int row = -1; row < test.rowSize(); row++) {
  for (int col = 0; col < test.columnSize(); col++) {
   test.set(row, col, 1.23);
  }
 }
}

代码示例来源:origin: apache/mahout

@Override
public Matrix matrixFactory(double[][] values) {
 Matrix matrix = new SparseMatrix(values.length, values[0].length);
 for (int row = 0; row < matrix.rowSize(); row++) {
  for (int col = 0; col < matrix.columnSize(); col++) {
   matrix.setQuick(row, col, values[row][col]);
  }
 }
 return matrix;
}

代码示例来源:origin: apache/mahout

@Override
public Matrix matrixFactory(double[][] values) {
 Matrix matrix = new SparseColumnMatrix(values.length, values[0].length);
 for (int row = 0; row < matrix.rowSize(); row++) {
  for (int col = 0; col < matrix.columnSize(); col++) {
   matrix.setQuick(row, col, values[row][col]);
  }
 }
 return matrix;
}

代码示例来源:origin: apache/mahout

@Test(expected = IndexException.class)
public void testGetIndexOver() {
 for (int row = 0; row < test.rowSize() + 1; row++) {
  for (int col = 0; col < test.columnSize(); col++) {
   test.get(row, col);
  }
 }
}

代码示例来源:origin: apache/mahout

@Test
public void testTranspose() {
 Matrix transpose = test.transpose();
 assertEquals("rows", test.columnSize(), transpose.rowSize());
 assertEquals("cols", test.rowSize(), transpose.columnSize());
 for (int row = 0; row < test.rowSize(); row++) {
  for (int col = 0; col < test.columnSize(); col++) {
   assertEquals("value[" + row + "][" + col + ']',
     test.getQuick(row, col), transpose.getQuick(col, row), EPSILON);
  }
 }
}

代码示例来源:origin: apache/mahout

@Test
public void testGet() {
 for (int row = 0; row < test.rowSize(); row++) {
  for (int col = 0; col < test.columnSize(); col++) {
   assertEquals("value[" + row + "][" + col + ']', values[row][col], test
     .get(row, col), EPSILON);
  }
 }
}

代码示例来源:origin: apache/mahout

@Test
public void testGetQuick() {
 for (int row = 0; row < test.rowSize(); row++) {
  for (int col = 0; col < test.columnSize(); col++) {
   assertEquals("value[" + row + "][" + col + ']', values[row][col], test
     .getQuick(row, col), EPSILON);
  }
 }
}

代码示例来源:origin: apache/mahout

@Test
public void testViewPart() {
 int[] offset = {1, 1};
 int[] size = {2, 1};
 Matrix view = test.viewPart(offset, size);
 for (int row = 0; row < view.rowSize(); row++) {
  for (int col = 0; col < view.columnSize(); col++) {
   assertEquals("value[" + row + "][" + col + ']',
     values[row + 2][col + 2], view.getQuick(row, col), EPSILON);
  }
 }
}

代码示例来源:origin: apache/mahout

@Test
public void testAssignDouble() {
 test.assign(4.53);
 for (int row = 0; row < test.rowSize(); row++) {
  for (int col = 0; col < test.columnSize(); col++) {
   assertEquals("value[" + row + "][" + col + ']', 4.53, test.getQuick(
     row, col), EPSILON);
  }
 }
}

代码示例来源:origin: apache/mahout

@Test
public void testPlusMatrix() {
 Matrix value = test.plus(test);
 for (int row = 0; row < test.rowSize(); row++) {
  for (int col = 0; col < test.columnSize(); col++) {
   assertEquals("value[" + row + "][" + col + ']', values[row][col] * 2,
     value.getQuick(row, col), EPSILON);
  }
 }
}

代码示例来源:origin: apache/mahout

@Test
public void testAssignDouble() {
 test.assign(4.53);
 for (int row = 0; row < test.rowSize(); row++) {
  for (int col = 0; col < test.columnSize(); col++) {
   assertEquals("value[" + row + "][" + col + ']', 4.53, test.getQuick(
     row, col), EPSILON);
  }
 }
}

代码示例来源:origin: apache/mahout

@Test
public void testAssignDoubleArrayArray() {
 test.assign(new double[3][2]);
 for (int row = 0; row < test.rowSize(); row++) {
  for (int col = 0; col < test.columnSize(); col++) {
   assertEquals("value[" + row + "][" + col + ']', 0.0, test.getQuick(row,
     col), EPSILON);
  }
 }
}

代码示例来源:origin: apache/mahout

@Test
public void testAssignUnaryFunction() {
 test.assign(Functions.NEGATE);
 for (int row = 0; row < test.rowSize(); row++) {
  for (int col = 0; col < test.columnSize(); col++) {
   assertEquals("value[" + row + "][" + col + ']',
     -values[row + 1][col + 1], test.getQuick(row, col), EPSILON);
  }
 }
}

代码示例来源:origin: apache/mahout

@Test
public void testAssignDoubleArrayArray() {
 test.assign(new double[3][2]);
 for (int row = 0; row < test.rowSize(); row++) {
  for (int col = 0; col < test.columnSize(); col++) {
   assertEquals("value[" + row + "][" + col + ']', 0.0, test.getQuick(row,
     col), EPSILON);
  }
 }
}

代码示例来源:origin: apache/mahout

@Test
public void testMinus() {
 Matrix value = test.minus(test);
 for (int row = 0; row < test.rowSize(); row++) {
  for (int col = 0; col < test.columnSize(); col++) {
   assertEquals("value[" + row + "][" + col + ']', 0.0, value.getQuick(
     row, col), EPSILON);
  }
 }
}

代码示例来源:origin: apache/mahout

public SequentialBigSvd(Matrix A, int p) {
 // Y = A * \Omega
 y = A.times(new RandomTrinaryMatrix(A.columnSize(), p));
 // R'R = Y' Y
 cd1 = new CholeskyDecomposition(y.transpose().times(y));
 // B = Q" A = (Y R^{-1} )' A
 b = cd1.solveRight(y).transpose().times(A);
 // L L' = B B'
 cd2 = new CholeskyDecomposition(b.times(b.transpose()));
 // U_0 D V_0' = L
 svd = new SingularValueDecomposition(cd2.getL());
}

代码示例来源:origin: apache/mahout

@Test
public void testAssignUnaryFunction() {
 test.assign(Functions.mult(-1));
 for (int row = 0; row < test.rowSize(); row++) {
  for (int col = 0; col < test.columnSize(); col++) {
   assertEquals("value[" + row + "][" + col + ']', -values[row][col], test
     .getQuick(row, col), EPSILON);
  }
 }
}

代码示例来源:origin: apache/mahout

@Test
public void testCrossProduct() {
 Matrix result = test.cross(test);
 assertEquals("row size", test.size(), result.rowSize());
 assertEquals("col size", test.size(), result.columnSize());
 for (int row = 0; row < result.rowSize(); row++) {
  for (int col = 0; col < result.columnSize(); col++) {
   assertEquals("cross[" + row + "][" + col + ']', test.getQuick(row)
     * test.getQuick(col), result.getQuick(row, col), EPSILON);
  }
 }
}

代码示例来源:origin: apache/mahout

@Test
public void testCopy() {
 Matrix copy = test.clone();
 assertTrue("wrong class", copy instanceof MatrixView);
 for (int row = 0; row < test.rowSize(); row++) {
  for (int col = 0; col < test.columnSize(); col++) {
   assertEquals("value[" + row + "][" + col + ']',
     test.getQuick(row, col), copy.getQuick(row, col), EPSILON);
  }
 }
}

相关文章