当前位置: 首页>>代码示例>>Java>>正文


Java SparseVector.dotProduct方法代码示例

本文整理汇总了Java中cc.mallet.types.SparseVector.dotProduct方法的典型用法代码示例。如果您正苦于以下问题:Java SparseVector.dotProduct方法的具体用法?Java SparseVector.dotProduct怎么用?Java SparseVector.dotProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cc.mallet.types.SparseVector的用法示例。


在下文中一共展示了SparseVector.dotProduct方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: distance

import cc.mallet.types.SparseVector; //导入方法依赖的package包/类
public double distance( SparseVector a, int hashCodeA,
												SparseVector b, int hashCodeB) {		
	Double cachedA = (Double) hash.get (new Integer (hashCodeA)); 
	Double cachedB = (Double) hash.get (new Integer (hashCodeB));
	if (a == null || b == null)
		return 1.0;
	if (cachedA == null) {
		cachedA = new Double (a.dotProduct (a));
			hash.put (new Integer (hashCodeA), cachedA);
	}
	if (cachedB == null) {
		cachedB = new Double (b.dotProduct (b));
		hash.put (new Integer (hashCodeB), cachedB);
	}
	double ab = a.dotProduct (b);
	
	if (cachedA == null || cachedB == null) {
		throw new IllegalStateException ("cachedValues null");
	}
 	double ret = a.dotProduct (b) / Math.sqrt (cachedA.doubleValue()*cachedB.doubleValue());
	return 1.0 - ret;
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:23,代码来源:NormalizedDotProductMetric.java

示例2: testDenseSparseVector

import cc.mallet.types.SparseVector; //导入方法依赖的package包/类
public void testDenseSparseVector ()
{
	SparseVector svDense = new SparseVector (null, dbl3);
	double sdot = svDense.dotProduct (svDense);
	double ddot = d1.dotProduct (d1);
	assertEquals (sdot, ddot, 0.0001);

	svDense.plusEqualsSparse (s1);
	checkAnswer (svDense, new double[] { 2.0, 2.5, 3.0, 5.7, 3.5,
																			 5.6, 0,   3,   0,   0,
																			 0,   0,   0,   4,   0,
																			 5, });

	svDense.plusEqualsSparse (s1, 2.0);
	checkAnswer (svDense, new double[] { 2.0, 2.5, 3.0, 7.7, 3.5,
																			 9.6, 0,   9,   0,   0,
																			 0,   0,   0,   12,   0,
																			 15, });
	
	double[] dbl4 = new double [dbl3.length + 1];
	for (int i = 0; i < dbl4.length; i++) dbl4[i] = 2.0;
	SparseVector sv4 = new SparseVector (null, dbl4);
	svDense.plusEqualsSparse (sv4);
	checkAnswer (svDense, new double[] { 4.0,  4.5,    5.0,  9.7,   5.5,
																			 11.6, 2.0,   11.0,  2.0,   2.0,
																			 2,   2,   2,   14,   2.0,
																			 17, });
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:29,代码来源:TestSparseVector.java

示例3: testExtendedDotProduct

import cc.mallet.types.SparseVector; //导入方法依赖的package包/类
public void testExtendedDotProduct () {
	SparseVector v1 = new SparseVector (null, dbl3);
	SparseVector vInf = new SparseVector (null, dbl4);
	double dp = v1.dotProduct (vInf);
	assertTrue (!Double.isNaN(dp));
	dp = vInf.dotProduct (v1);
	assertTrue (!Double.isNaN(dp));
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:9,代码来源:TestSparseVector.java


注:本文中的cc.mallet.types.SparseVector.dotProduct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。