mikera.vectorz.impl.ZeroVector.createNew()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(1.5k)|赞(0)|评价(0)|浏览(89)

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

ZeroVector.createNew介绍

暂无

代码示例

代码示例来源:origin: net.mikera/vectorz

@Override
public AVector select(int... order) {
  for (int i: order) {
    checkIndex(i);
  }
  int n = order.length;
  if (n == length) return this;
  return createNew(n);
}

代码示例来源:origin: mikera/vectorz

@Override
public AVector select(int... order) {
  for (int i: order) {
    checkIndex(i);
  }
  int n = order.length;
  if (n == length) return this;
  return createNew(n);
}

代码示例来源:origin: mikera/vectorz

@Test public void testArithmetic() {
  SparseColumnMatrix M=SparseColumnMatrix.create(3, 3);
  Vector v=Vector.of(-1,2,3);
  M.replaceColumn(1, v);
  assertEquals(4, M.elementSum(), 0.01);
  assertEquals(14, M.elementSquaredSum(), 0.01);
  assertEquals(-1, M.elementMin(), 0.01);
  assertEquals(3, M.elementMax(), 0.01);
  assertEquals(3, M.nonZeroCount());
  SparseRowMatrix N = SparseRowMatrix.create(3,3);
  v=Vector.of(4,5,6);
  N.replaceRow(1, v);
  M.add(N);                     // test add
  M.swapColumns(0,1);			// test swapColumns
  assertEquals(7, M.get(1,0), 0.01);
  SparseColumnMatrix M1 = SparseColumnMatrix.create(3, 3);
  Vector v1=Vector.of(-1,2,3);
  M1.replaceColumn(1, v1);
  int[] index = {0,2};
  double[] data = {7,8};
  SparseColumnMatrix M2 = SparseColumnMatrix.create(Vector.of(0,1,2),SparseIndexedVector.wrap(3, index, data),ZeroVector.createNew(3));
  M2.validate();
  
  M1.add(M2);                 // test adding SparseColumnMatrix
  assertEquals(2, M1.get(1,1), 0.01);
}

相关文章