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

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

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

Matrix.assignColumn介绍

[英]Assign the other vector values to the column of the receiver
[中]将其他向量值分配给接收器的列

代码示例

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

@Override
public Matrix assignRow(int row, Vector other) {
 m.assignColumn(row,other);
 return this;
}

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

/**
 * Assign the other vector values to the column of the receiver
 *
 * @param column the int row to assign
 * @param other  a Vector
 * @return the modified receiver
 * @throws org.apache.mahout.math.CardinalityException
 *          if the cardinalities differ
 */
@Override
public Matrix assignColumn(int column, Vector other) {
 // note the reversed pivoting for other
 return base.assignColumn(columnPivot[column], new PermutedVectorView(other, rowUnpivot, rowPivot));
}

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

@Test(expected = CardinalityException.class)
public void testAssignColumnCardinality() {
 double[] data = {2.1, 3.2};
 test.assignColumn(1, new DenseVector(data));
}

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

@Test(expected = CardinalityException.class)
public void testAssignColumnCardinality() {
 double[] data = {2.1, 3.2};
 test.assignColumn(1, new DenseVector(data));
}

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

@Override
public void setQuick(int index, double value) {
 Vector v = rowToColumn ? matrix.viewColumn(index) : matrix.viewRow(index);
 if (v == null) {
  v = newVector(numCols);
  if (rowToColumn) {
   matrix.assignColumn(index, v);
  } else {
   matrix.assignRow(index, v);
  }
 }
 v.setQuick(transposeOffset, value);
}

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

@Test
public void testAssignColumn() {
 double[] data = {2.1, 3.2, 4.3};
 test.assignColumn(1, new DenseVector(data));
 assertEquals("test[0][1]", 2.1, test.getQuick(0, 1), EPSILON);
 assertEquals("test[1][1]", 3.2, test.getQuick(1, 1), EPSILON);
 assertEquals("test[2][1]", 4.3, test.getQuick(2, 1), EPSILON);
}

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

@Test
public void testAssignColumn() {
 double[] data = {2.1, 3.2, 4.3};
 test.assignColumn(1, new DenseVector(data));
 assertEquals("test[0][1]", 2.1, test.getQuick(0, 1), EPSILON);
 assertEquals("test[1][1]", 3.2, test.getQuick(1, 1), EPSILON);
 assertEquals("test[2][1]", 4.3, test.getQuick(2, 1), EPSILON);
}

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

@Override
public Matrix assignRow(int row, Vector other) {
 m.assignColumn(row,other);
 return this;
}

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

/**
 * Assign the other vector values to the column of the receiver
 *
 * @param column the int row to assign
 * @param other  a Vector
 * @return the modified receiver
 * @throws org.apache.mahout.math.CardinalityException
 *          if the cardinalities differ
 */
@Override
public Matrix assignColumn(int column, Vector other) {
 // note the reversed pivoting for other
 return base.assignColumn(columnPivot[column], new PermutedVectorView(other, rowUnpivot, rowPivot));
}

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

/**
 * Assign the other vector values to the column of the receiver
 *
 * @param column the int row to assign
 * @param other  a Vector
 * @return the modified receiver
 * @throws org.apache.mahout.math.CardinalityException
 *          if the cardinalities differ
 */
@Override
public Matrix assignColumn(int column, Vector other) {
 // note the reversed pivoting for other
 return base.assignColumn(columnPivot[column], new PermutedVectorView(other, rowUnpivot, rowPivot));
}

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

@Test(expected = CardinalityException.class)
public void testAssignColumnCardinality() {
 double[] data = {2.1, 3.2};
 test.assignColumn(1, new DenseVector(data));
}

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

@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: cloudera/mahout

@Test(expected = CardinalityException.class)
public void testAssignColumnCardinality() {
 double[] data = {2.1, 3.2};
 test.assignColumn(1, new DenseVector(data));
}

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

@Override
public void setQuick(int index, double value) {
 Vector v = rowToColumn ? matrix.viewColumn(index) : matrix.viewRow(index);
 if (v == null) {
  v = newVector(numCols);
  if (rowToColumn) {
   matrix.assignColumn(index, v);
  } else {
   matrix.assignRow(index, v);
  }
 }
 v.setQuick(transposeOffset, value);
}

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

@Override
public void setQuick(int index, double value) {
 Vector v = rowToColumn ? matrix.viewColumn(index) : matrix.viewRow(index);
 if (v == null) {
  v = newVector(numCols);
  if (rowToColumn) {
   matrix.assignColumn(index, v);
  } else {
   matrix.assignRow(index, v);
  }
 }
 v.setQuick(transposeOffset, value);
}

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

@Test
public void testAssignColumn() {
 double[] data = {2.1, 3.2, 4.3};
 test.assignColumn(1, new DenseVector(data));
 assertEquals("test[0][1]", 2.1, test.getQuick(0, 1), EPSILON);
 assertEquals("test[1][1]", 3.2, test.getQuick(1, 1), EPSILON);
 assertEquals("test[2][1]", 4.3, test.getQuick(2, 1), EPSILON);
}

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

@Test
public void testAssignColumn() {
 double[] data = {2.1, 3.2, 4.3};
 test.assignColumn(1, new DenseVector(data));
 assertEquals("test[0][1]", 2.1, test.getQuick(0, 1), EPSILON);
 assertEquals("test[1][1]", 3.2, test.getQuick(1, 1), EPSILON);
 assertEquals("test[2][1]", 4.3, test.getQuick(2, 1), EPSILON);
}

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

@Test
public void testOmegaTRightMultiply() {
 final Random rnd = RandomUtils.getRandom();
 final long seed = rnd.nextLong();
 final int n = 2000;
 final int kp = 100;
 final Omega omega = new Omega(seed, kp);
 final Matrix materializedOmega = new DenseMatrix(n, kp);
 for (int i = 0; i < n; i++)
  for (int j = 0; j < kp; j++)
   materializedOmega.setQuick(i, j, omega.getQuick(i, j));
 Vector xi = new DenseVector(n);
 xi.assign(new DoubleFunction() {
  @Override
  public double apply(double x) {
   return rnd.nextDouble() * 100;
  }
 });
 Vector s_o = omega.mutlithreadedTRightMultiply(xi);
 Matrix xiVector = new DenseMatrix(n, 1);
 xiVector.assignColumn(0, xi);
 Vector s_o_control = materializedOmega.transpose().times(xiVector).viewColumn(0);
 assertEquals(0, s_o.minus(s_o_control).aggregate(Functions.PLUS, Functions.ABS), 1e-10);
 System.out.printf("s_omega=\n%s\n", s_o);
 System.out.printf("s_omega_control=\n%s\n", s_o_control);
}

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

mx.assignColumn(i, mx.viewColumn(i).times(svalues.getQuick(i)));

相关文章