本文整理了Java中org.apache.mahout.math.Vector.getNumNondefaultElements()
方法的一些代码示例,展示了Vector.getNumNondefaultElements()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.getNumNondefaultElements()
方法的具体详情如下:
包路径:org.apache.mahout.math.Vector
类名称:Vector
方法名:getNumNondefaultElements
[英]Return the number of values in the recipient which are not the default value. For instance, for a sparse vector, this would be the number of non-zero values.
[中]返回收件人中非默认值的值数。例如,对于稀疏向量,这将是非零值的数量。
代码示例来源:origin: apache/mahout
/** Return the number of values in the recipient */
@Override
public int getNumNondefaultElements() {
return vector.getNumNondefaultElements();
}
代码示例来源:origin: apache/mahout
@Override
public int[] getNumNondefaultElements() {
int[] result = new int[2];
result[COL] = columnVectors.length;
for (int col = 0; col < columnSize(); col++) {
result[ROW] = Math.max(result[ROW], columnVectors[col]
.getNumNondefaultElements());
}
return result;
}
代码示例来源:origin: apache/mahout
@Override
public int[] getNumNondefaultElements() {
int[] result = new int[2];
result[ROW] = rowVectors.length;
for (int row = 0; row < rowSize(); row++) {
result[COL] = Math.max(result[COL], rowVectors[row].getNumNondefaultElements());
}
return result;
}
代码示例来源:origin: apache/mahout
@Override
public double estimateCost(Vector x, Vector y, DoubleDoubleFunction f) {
return Math.min(x.getNumNondefaultElements() * x.getIteratorAdvanceCost(),
y.getNumNondefaultElements() * y.getIteratorAdvanceCost());
}
代码示例来源:origin: apache/mahout
@Override
public double estimateCost(Vector x, Vector y, DoubleDoubleFunction f) {
return Math.max(x.getNumNondefaultElements() * x.getIteratorAdvanceCost(),
y.getNumNondefaultElements() * y.getIteratorAdvanceCost());
}
代码示例来源:origin: apache/mahout
@Override
public double estimateCost(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc) {
return Math.min(x.getNumNondefaultElements() * x.getIteratorAdvanceCost(),
y.getNumNondefaultElements() * y.getIteratorAdvanceCost());
}
代码示例来源:origin: apache/mahout
@Override
public double estimateCost(Vector x, Vector y, DoubleDoubleFunction f) {
return Math.max(x.getNumNondefaultElements() * x.getIteratorAdvanceCost(),
y.getNumNondefaultElements() * y.getIteratorAdvanceCost());
}
代码示例来源:origin: apache/mahout
@Override
public double estimateCost(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc) {
return Math.max(x.getNumNondefaultElements() * x.getIteratorAdvanceCost(),
y.getNumNondefaultElements() * y.getIteratorAdvanceCost());
}
代码示例来源:origin: apache/mahout
@Override
public int[] getNumNondefaultElements() {
int[] result = new int[2];
result[ROW] = rowVectors.size();
for (Vector row : rowVectors.values()) {
result[COL] = Math.max(result[COL], row.getNumNondefaultElements());
}
return result;
}
代码示例来源:origin: apache/mahout
@Override
public double estimateCost(Vector x, Vector y, DoubleDoubleFunction fa, DoubleDoubleFunction fc) {
return Math.max(x.getNumNondefaultElements() * x.getIteratorAdvanceCost() * y.getLookupCost(),
y.getNumNondefaultElements() * y.getIteratorAdvanceCost() * x.getLookupCost());
}
代码示例来源:origin: apache/mahout
@Override
public double estimateCost(Vector x, Vector y, DoubleDoubleFunction f) {
return Math.max(x.getNumNondefaultElements() * x.getIteratorAdvanceCost() * y.getLookupCost(),
y.getNumNondefaultElements() * y.getIteratorAdvanceCost() * x.getLookupCost());
}
代码示例来源:origin: apache/mahout
@Override
public double estimateCost(Vector x, Vector y, DoubleDoubleFunction f) {
return Math.max(x.getNumNondefaultElements() * x.getIteratorAdvanceCost() * y.getLookupCost(),
y.getNumNondefaultElements() * y.getIteratorAdvanceCost() * x.getLookupCost());
}
@Override
代码示例来源:origin: apache/mahout
public RandomAccessSparseVector(Vector other) {
this(other.size(), other.getNumNondefaultElements());
for (Element e : other.nonZeroes()) {
values.put(e.index(), e.get());
}
}
代码示例来源:origin: apache/mahout
@Test
public void testViewRow() {
Vector row = test.viewRow(1);
assertEquals("row size", 2, row.getNumNondefaultElements());
}
代码示例来源:origin: apache/mahout
@Test
public void testViewColumn() {
Vector column = test.viewColumn(1);
assertEquals("row size", 3, column.getNumNondefaultElements());
}
代码示例来源:origin: apache/mahout
@Override
public Vector times(Vector that) {
if (size != that.size()) {
throw new CardinalityException(size, that.size());
}
if (this.getNumNondefaultElements() <= that.getNumNondefaultElements()) {
return createOptimizedCopy(this).assign(that, Functions.MULT);
} else {
return createOptimizedCopy(that).assign(this, Functions.MULT);
}
}
代码示例来源:origin: apache/mahout
@Test
public void testViewColumn() {
Vector column = test.viewColumn(1);
assertEquals("row size", 3, column.getNumNondefaultElements());
int i = 0;
for (double x : new double[]{3.3, 5.5, 7.7}) {
assertEquals(x, column.get(i++), 0);
}
}
代码示例来源:origin: apache/mahout
@Test
public void testViewPart() throws Exception {
Vector part = test.viewPart(1, 2);
assertEquals("part size", 2, part.getNumNondefaultElements());
for (int i = 0; i < part.size(); i++) {
assertEquals("part[" + i + ']', values[OFFSET + i + 1], part.get(i), EPSILON);
}
}
代码示例来源:origin: apache/mahout
@Test
public void testViewPart() {
Vector part = test.viewPart(1, 2);
assertEquals("part size", 2, part.getNumNondefaultElements());
for (int i = 0; i < part.size(); i++) {
assertEquals("part[" + i + ']', test.get(i+1), part.get(i), EPSILON);
}
}
代码示例来源:origin: apache/mahout
@Test
public void testViewRow() {
Vector row = test.viewRow(1);
assertEquals("row size", 2, row.getNumNondefaultElements());
//create a matrix with an unassigned row 0
Matrix matrix = new SparseMatrix(1, 1);
Vector view = matrix.viewRow(0);
final double value = 1.23;
view.assign(value);
//test whether the update in the view is reflected in the matrix
assertEquals("Matrix value", view.getQuick(0), matrix.getQuick(0, 0), EPSILON);
}
内容来源于网络,如有侵权,请联系作者删除!