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

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

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

Matrix.like介绍

[英]Return an empty matrix of the same underlying class as the receiver
[中]返回与接收方相同的基础类的空矩阵

代码示例

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

@Override
protected Matrix matrixLike(int rows, int columns) {
 return matrix.like(rows, columns);
}

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

@Override
public Matrix like() {
 return m.like(rows, columns);
}

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

@Override
public Matrix like(int rows, int columns) {
 return m.like(rows,columns);
}

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

@Override
public Matrix like(int rows, int columns) {
 return matrix.like(rows, columns);
}

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

/**
 * Return the eigenvector matrix
 *
 * @return V
 */
public Matrix getV() {
 return v.like().assign(v);
}

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

/**
 * Return an empty matrix of the same underlying class as the receiver
 *
 * @return a Matrix
 */
@Override
public Matrix like() {
 return new PivotedMatrix(base.like());
}

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

/**
 * Returns an empty matrix of the same underlying class as the receiver and of the specified
 * size.
 *
 * @param rows    the int number of rows
 * @param columns the int number of columns
 */
@Override
public Matrix like(int rows, int columns) {
 return new PivotedMatrix(base.like(rows, columns));
}

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

@Override
public Vector like(int cardinality) {
 return matrix.like(cardinality, 1).viewColumn(0);
}

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

/**
 * Return an empty vector of the same underlying class as the receiver
 *
 * @return a Vector
 */
@Override
public Vector like() {
 return matrix.like(size(), 1).viewColumn(0);
}

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

@Test(expected = CardinalityException.class)
public void testTimesMatrixCardinality() {
 Matrix other = test.like(5, 8);
 test.times(other);
}

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

@Override
public Matrix timesLeft(Matrix that) {
 if (that.numCols() != diagonal.size()) {
  throw new IllegalArgumentException(
   "Incompatible number of rows in the left operand of matrix-matrix multiplication.");
 }
 Matrix m = that.like();
 for (int col = 0; col < diagonal.size(); col++) {
  m.assignColumn(col, that.viewColumn(col).times(diagonal.getQuick(col)));
 }
 return m;
}

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

@Override
public Matrix timesRight(Matrix that) {
 if (that.numRows() != diagonal.size()) {
  throw new IllegalArgumentException("Incompatible number of rows in the right operand of matrix multiplication.");
 }
 Matrix m = that.like();
 for (int row = 0; row < diagonal.size(); row++) {
  m.assignRow(row, that.viewRow(row).times(diagonal.getQuick(row)));
 }
 return m;
}

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

@Test(expected = CardinalityException.class)
public void testTimesMatrixCardinality() {
 Matrix other = test.like(5, 8);
 test.times(other);
}

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

@Test
public void testLikeIntInt() {
 Matrix like = test.like(4, 4);
 assertSame("type", like.getClass(), test.getClass());
 assertEquals("rows", 4, like.rowSize());
 assertEquals("columns", 4, like.columnSize());
}

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

@Test
public void testLike() {
 Matrix like = test.like();
 assertSame("type", like.getClass(), test.getClass());
 assertEquals("rows", test.rowSize(), like.rowSize());
 assertEquals("columns", test.columnSize(), like.columnSize());
}

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

@Override
public Matrix matrixFactory(double[][] values) {
 Matrix base = new DenseMatrix(values);
 // for general tests, we just make a scrambled matrix and fill it
 // with the standard data.  Then we can test the details of the
 // row and/or column swapping separately.
 PivotedMatrix pm = new PivotedMatrix(base.like());
 pm.swap(0, 1);
 pm.swapRows(1, 2);
 pm.assign(base);
 return pm;
}

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

@Test
public void testLikeIntInt() {
 Matrix like = test.like(4, 4);
 assertTrue("type", like instanceof DenseMatrix);
 assertEquals("rows", 4, like.rowSize());
 assertEquals("columns", 4, like.columnSize());
}

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

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

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

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

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

@Test
public void testLike() {
 Matrix like = test.like();
 assertTrue("type", like instanceof DenseMatrix);
 assertEquals("rows", test.rowSize(), like.rowSize());
 assertEquals("columns", test.columnSize(), like.columnSize());
}

相关文章