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


Java SparseVector.plusEqualsSparse方法代码示例

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


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

示例1: testBinaryVector

import cc.mallet.types.SparseVector; //导入方法依赖的package包/类
public void testBinaryVector ()
{
	SparseVector binary1 = new SparseVector (idxs, null, idxs.length, idxs.length,
																					 false, false, false);
	SparseVector binary2 = new SparseVector (idx2, null, idx2.length, idx2.length,
																					false, false, false);

	assertEquals (3, binary1.dotProduct (binary2), 0.0001);
	assertEquals (3, binary2.dotProduct (binary1), 0.0001);

	assertEquals (15.0, binary1.dotProduct (s1), 0.0001);
	assertEquals (15.0, s1.dotProduct (binary1), 0.0001);

	assertEquals (9.0, binary2.dotProduct (s1), 0.0001);
	assertEquals (9.0, s1.dotProduct (binary2), 0.0001);

	SparseVector dblVec = (SparseVector) s1.cloneMatrix ();
	dblVec.plusEqualsSparse (binary1);
	checkAnswer (dblVec, new double[] { 2, 3, 4, 5, 6 });

	SparseVector dblVec2 = (SparseVector) s1.cloneMatrix ();
	dblVec2.plusEqualsSparse (binary2);
	checkAnswer (dblVec2, new double[] { 2, 2, 4, 4, 6 });
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:25,代码来源:TestSparseVector.java

示例2: testPlusEquals

import cc.mallet.types.SparseVector; //导入方法依赖的package包/类
public void testPlusEquals ()
{
	SparseVector s = (SparseVector) s1.cloneMatrix ();
	s.plusEqualsSparse (s2, 2.0);
	checkAnswer (s, new double[] { 3, 5, 7, 6, 7 }); 

	SparseVector s2p = new SparseVector
										 (new int[] { 13 },
											new double[] { 0.8 });
	s.plusEqualsSparse (s2p, 1.0);
	checkAnswer (s, new double[] { 3, 5, 7, 6.8, 7 }); 

	SparseVector s3p = new SparseVector
										 (new int[] { 14 },
											new double[] { 0.8 });
	s.plusEqualsSparse (s3p, 1.0);
	checkAnswer (s, new double[] { 3, 5, 7, 6.8, 7 }); 		// verify s unchanged

	SparseVector s4 = new SparseVector
										(new int[] { 7, 14, 15 },
										 new double[] { 0.2, 0.8, 1.2 });
	s.plusEqualsSparse (s4, 1.0);
	checkAnswer (s, new double[] { 3, 5, 7.2, 6.8, 8.2 });	

	SparseVector s5 = new SparseVector (new int[] { 7 }, new double[] { 0.2 });
	s5.plusEqualsSparse (s1);
	for (int i = 0; i < s5.numLocations(); i++) {
    assertEquals (7, s5.indexAtLocation (i));
    assertEquals (3.2, s5.valueAtLocation (i), 0.0);
	}

	SparseVector s6 = new SparseVector (new int[] { 7 }, new double[] { 0.2 });
	s6.plusEqualsSparse (s1, 3.5);
	for (int i = 0; i < s6.numLocations(); i++) {
    assertEquals (7, s6.indexAtLocation (i));
    assertEquals (10.7, s6.valueAtLocation (i), 0.0);
	}
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:39,代码来源:TestSparseVector.java

示例3: 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


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