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

x33g5p2x  于2022-02-01 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(98)

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

Vector.isDense介绍

[英]true if this implementation should be considered dense -- that it explicitly represents every value
[中]如果这个实现应该被认为是稠密的——它显式地表示每个值

代码示例

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

/**
 * @return true iff this implementation should be considered dense -- that it explicitly
 *         represents every value
 */
@Override
public boolean isDense() {
 return vector.isDense();
}

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

@Override
public boolean isDense() {
 return delegate.isDense();
}

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

@Override
public boolean isDense() {
 return vector.isDense();
}

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

@Override
public boolean isDense() {
 return delegate.isDense();
}

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

public static byte flags(Vector vector, boolean laxPrecision) {
 boolean dense = vector.isDense();
 boolean sequential = vector.isSequentialAccess();
 boolean named = vector instanceof NamedVector;
 return (byte) ((dense ? FLAG_DENSE : 0)
     | (sequential ? FLAG_SEQUENTIAL : 0)
     | (named ? FLAG_NAMED : 0)
     | (laxPrecision ? FLAG_LAX_PRECISION : 0));
}

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

@Override
public boolean isValid(Vector x, Vector y, DoubleDoubleFunction f) {
 return x.isAddConstantTime() && !x.isDense();
}

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

@Override
public boolean isValid(Vector x, Vector y, DoubleDoubleFunction f) {
 return !x.isAddConstantTime() && !y.isDense();
}

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

@Override
public boolean isValid(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc) {
 return x.isSequentialAccess() && y.isSequentialAccess() && !x.isDense() && !y.isDense();
}

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

@Override
public boolean isValid(Vector x, Vector y, DoubleDoubleFunction f) {
 return !x.isAddConstantTime() && !x.isDense();
}

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

@Override
public boolean isValid(Vector x, Vector y, DoubleDoubleFunction f) {
 return x.isAddConstantTime() && !y.isDense();
}

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

@Override
public boolean isValid(Vector x, Vector y, DoubleDoubleFunction f) {
 return x.isSequentialAccess() && y.isSequentialAccess() && x.isAddConstantTime()
   && !x.isDense() && !y.isDense();
}

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

@Override
public boolean isValid(Vector x, Vector y, DoubleDoubleFunction f) {
 return x.isSequentialAccess() && y.isSequentialAccess() && !x.isAddConstantTime() && !x.isDense() && !y.isDense();
}

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

@Override
public boolean isValid(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc) {
 return (fa.isAssociativeAndCommutative() || x.isSequentialAccess())
   && !x.isDense();
}

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

@Override
public boolean isValid(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc) {
 return (fa.isAssociativeAndCommutative() || y.isSequentialAccess())
   && !y.isDense();
}

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

/**
 * Subclasses must override to return an appropriately sparse or dense result
 *
 * @param rows    the row cardinality
 * @param columns the column cardinality
 * @return a Matrix
 */
@Override
protected Matrix matrixLike(int rows, int columns) {
 if (vector.isDense()) {
  return new DenseMatrix(rows, columns);
 } else {
  return new SparseRowMatrix(rows, columns);
 }
}

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

private static Vector createOptimizedCopy(Vector vector) {
 Vector result;
 if (vector.isDense()) {
  result = vector.like().assign(vector, Functions.SECOND_LEFT_ZERO);
 } else {
  result = vector.clone();
 }
 return result;
}

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

@Override
public double dot(Vector x) {
 if (!x.isDense()) {
  return super.dot(x);
 } else {
  int size = x.size();
  if (values.length != size) {
   throw new CardinalityException(values.length, size);
  }
  double sum = 0;
  for (int n = 0; n < size; n++) {
   sum += values[n] * x.getQuick(n);
  }
  return sum;
 }
}

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

@Test
public void testViewDenseSparseReporting() {
 Matrix m = new SparseMatrix(1000, 1000);
 m.set(1, 1, 33.0);
 Matrix mt = Matrices.transposedView(m);
 assertTrue(mt.viewColumn(0).isDense() == m.viewRow(0).isDense());
 assertTrue(mt.viewRow(0).isDense() == m.viewColumn(0).isDense());
 m = new DenseMatrix(10,10);
 m.set(1, 1, 33.0);
 mt = Matrices.transposedView(m);
 assertTrue(mt.viewColumn(0).isDense());
 assertTrue(mt.viewRow(0).isDense());
}

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

private static void createStubs(Vector v, Vector realV) {
 expect(v.getLookupCost())
   .andStubReturn(realV instanceof SequentialAccessSparseVector
     ? Math.round(Math.log(1000)) : realV.getLookupCost());
 expect(v.getIteratorAdvanceCost())
   .andStubReturn(realV.getIteratorAdvanceCost());
 expect(v.isAddConstantTime())
   .andStubReturn(realV.isAddConstantTime());
 expect(v.isSequentialAccess())
   .andStubReturn(realV.isSequentialAccess());
 expect(v.isDense())
   .andStubReturn(realV.isDense());
 expect(v.getNumNondefaultElements())
   .andStubReturn(realV.isDense() ? realV.size() : 1000);
 expect(v.size())
   .andStubReturn(realV.size());
}

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

private static void createStubs(Vector v, Vector realV) {
 expect(v.getLookupCost())
   .andStubReturn(realV instanceof SequentialAccessSparseVector
     ? Math.round(Math.log(1000)) : realV.getLookupCost());
 expect(v.getIteratorAdvanceCost())
   .andStubReturn(realV.getIteratorAdvanceCost());
 expect(v.isAddConstantTime())
   .andStubReturn(realV.isAddConstantTime());
 expect(v.isSequentialAccess())
   .andStubReturn(realV.isSequentialAccess());
 expect(v.isDense())
   .andStubReturn(realV.isDense());
 expect(v.getNumNondefaultElements())
   .andStubReturn(realV.isDense() ? realV.size() : 1000);
 expect(v.size())
   .andStubReturn(realV.size());
}

相关文章