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

x33g5p2x  于2022-02-03 转载在 其他  
字(1.4k)|赞(0)|评价(0)|浏览(72)

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

WeightedVector.project介绍

暂无

代码示例

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

public static WeightedVector project(Vector v, Vector projection) {
 return project(v, projection, INVALID_INDEX);
}

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

@Test
public void testProjection() {
 Vector v1 = new DenseVector(10).assign(Functions.random());
 WeightedVector v2 = new WeightedVector(v1, v1, 31);
 assertEquals(v1.dot(v1), v2.getWeight(), 1.0e-13);
 assertEquals(31, v2.getIndex());
 Matrix y = new DenseMatrix(10, 4).assign(Functions.random());
 Matrix q = new QRDecomposition(y.viewPart(0, 10, 0, 3)).getQ();
 Vector nullSpace = y.viewColumn(3).minus(q.times(q.transpose().times(y.viewColumn(3))));
 WeightedVector v3 = new WeightedVector(q.viewColumn(0).plus(q.viewColumn(1)), nullSpace, 1);
 assertEquals(0, v3.getWeight(), 1.0e-13);
 Vector qx = q.viewColumn(0).plus(q.viewColumn(1)).normalize();
 WeightedVector v4 = new WeightedVector(qx, q.viewColumn(0), 2);
 assertEquals(Math.sqrt(0.5), v4.getWeight(), 1.0e-13);
 WeightedVector v5 = WeightedVector.project(q.viewColumn(0), qx);
 assertEquals(Math.sqrt(0.5), v5.getWeight(), 1.0e-13);
}

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

public static WeightedVector project(Vector v, Vector projection) {
 return project(v, projection, INVALID_INDEX);
}

相关文章