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

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

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

Matrix.plus介绍

[英]Return a new matrix containing the sum of each value of the recipient and the argument
[中]返回一个新的矩阵,其中包含接收者和参数的每个值之和

代码示例

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

public Vector solve(Vector ratings) {
 return solve(YtransposeY.plus(getYtransponseCuMinusIYPlusLambdaI(ratings)), getYtransponseCuPu(ratings));
}

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

@Test(expected = CardinalityException.class)
public void testPlusMatrixCardinality() {
 test.plus(test.transpose());
}

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

@Test(expected = CardinalityException.class)
public void testPlusMatrixCardinality() {
 test.plus(test.transpose());
}

代码示例来源: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 testPlusDouble() {
 Matrix value = test.plus(4.53);
 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] + 4.53, value.getQuick(row, col), EPSILON);
  }
 }
}

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

@Test
public void testPlusDouble() {
 Matrix value = test.plus(4.53);
 for (int row = 0; row < test.rowSize(); row++) {
  for (int col = 0; col < test.columnSize(); col++) {
   assertEquals("value[" + row + "][" + col + ']',
     values[row][col] + 4.53, value.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 + 1][col + 1] * 2, value.getQuick(row, col), EPSILON);
  }
 }
}

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

@Test
public void testBasics() {
 Matrix a = new DenseSymmetricMatrix(new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, false);
 System.out.println(a.toString());
 assertEquals(0, a.viewDiagonal().minus(new DenseVector(new double[]{1, 5, 8, 10})).norm(1), 1.0e-10);
 assertEquals(0, a.viewPart(0, 3, 1, 3).viewDiagonal().minus(
   new DenseVector(new double[]{2, 6, 9})).norm(1), 1.0e-10);
 assertEquals(4, a.get(0, 3), 1.0e-10);
 System.out.println(a);
 Matrix m = new DenseMatrix(4, 4).assign(a);
 assertEquals(0, m.minus(a).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
 System.out.println(m);
 assertEquals(0, m.transpose().times(m).minus(a.transpose().times(a)).aggregate(
   Functions.PLUS, Functions.ABS), 1.0e-10);
 System.out.println(a.plus(a));
 assertEquals(0, m.plus(m).minus(a.plus(a)).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
}

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

@Test
public void testBasics() {
 Matrix a = new UpperTriangular(new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, false);
 assertEquals(0, a.viewDiagonal().minus(new DenseVector(new double[]{1, 5, 8, 10})).norm(1), 1.0e-10);
 assertEquals(0, a.viewPart(0, 3, 1, 3).viewDiagonal().minus(
   new DenseVector(new double[]{2, 6, 9})).norm(1), 1.0e-10);
 assertEquals(4, a.get(0, 3), 1.0e-10);
 print(a);
 Matrix m = new DenseMatrix(4, 4).assign(a);
 assertEquals(0, m.minus(a).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
 print(m);
 assertEquals(0, m.transpose().times(m).minus(a.transpose().times(a)).aggregate(
   Functions.PLUS, Functions.ABS), 1.0e-10);
 assertEquals(0, m.plus(m).minus(a.plus(a)).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
}

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

@Test
public void testBasics() {
 DiagonalMatrix a = new DiagonalMatrix(new double[]{1, 2, 3, 4});
 assertEquals(0, a.viewDiagonal().minus(new DenseVector(new double[]{1, 2, 3, 4})).norm(1), 1.0e-10);
 assertEquals(0, a.viewPart(0, 3, 0, 3).viewDiagonal().minus(
  new DenseVector(new double[]{1, 2, 3})).norm(1), 1.0e-10);
 assertEquals(4, a.get(3, 3), 1.0e-10);
 Matrix m = new DenseMatrix(4, 4);
 m.assign(a);
 assertEquals(0, m.minus(a).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
 assertEquals(0, m.transpose().times(m).minus(a.transpose().times(a)).aggregate(
  Functions.PLUS, Functions.ABS), 1.0e-10);
 assertEquals(0, m.plus(m).minus(a.plus(a)).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
 m = new DenseMatrix(new double[][]{{1, 2, 3, 4}, {5, 6, 7, 8}});
 assertEquals(100, a.timesLeft(m).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
 assertEquals(100, a.times(m.transpose()).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
}

代码示例来源:origin: org.apache.mahout/mahout-mrlegacy

/**
 * Update the weight matrices with given matrices.
 * 
 * @param matrices The weight matrices, must be the same dimension as the
 *          existing matrices.
 */
public void updateWeightMatrices(Matrix[] matrices) {
 for (int i = 0; i < matrices.length; ++i) {
  Matrix matrix = weightMatrixList.get(i);
  weightMatrixList.set(i, matrix.plus(matrices[i]));
 }
}

代码示例来源:origin: org.apache.mahout/mahout-core

/**
 * Update the weight matrices with given matrices.
 * 
 * @param matrices The weight matrices, must be the same dimension as the
 *          existing matrices.
 */
public void updateWeightMatrices(Matrix[] matrices) {
 for (int i = 0; i < matrices.length; ++i) {
  Matrix matrix = this.weightMatrixList.get(i);
  this.weightMatrixList.set(i, matrix.plus(matrices[i]));
 }
}

代码示例来源:origin: org.apache.mahout/mahout-math

public Vector solve(Vector ratings) {
 return solve(YtransposeY.plus(getYtransponseCuMinusIYPlusLambdaI(ratings)), getYtransponseCuPu(ratings));
}

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

public Vector solve(Vector ratings) {
 return solve(YtransposeY.plus(YtransponseCuMinusIYPlusLambdaI(ratings)), YtransponseCuPu(ratings));
}

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

@Test(expected = CardinalityException.class)
public void testPlusMatrixCardinality() {
 test.plus(test.transpose());
}

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

@Test(expected = CardinalityException.class)
public void testPlusMatrixCardinality() {
 test.plus(test.transpose());
}

代码示例来源:origin: cloudera/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: cloudera/mahout

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

代码示例来源:origin: cloudera/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 + 1][col + 1] * 2, value.getQuick(row, col), EPSILON);
  }
 }
}

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

@Test
public void testPlusDouble() {
 Matrix value = test.plus(4.53);
 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] + 4.53, value.getQuick(row, col), EPSILON);
  }
 }
}

相关文章