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


Java DoubleMatrix.dot方法代码示例

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


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

示例1: doFiniteSizeCorrections

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
private void doFiniteSizeCorrections(Node alphaNode, DoubleMatrix pAlpha) {
	DoubleMatrix p, AminusP;
	int numExtant = stateProbabilities.getNumExtant();    	
	int alphaIdx =  stateProbabilities.getLineageIndex(alphaNode.getNr());
	
	DoubleMatrix A = stateProbabilities.getLineageStateSum();
	double sum;    	
	// traverse all extant lineages
	for(int lineIdx=0; lineIdx < numExtant; lineIdx++) {
		if (lineIdx!=alphaIdx) {
			p = stateProbabilities.getStateProbsFromIndex(lineIdx);
			AminusP = A.sub(p);
			AminusP.maxi(1e-12);
			// rterm = p_a / clamp(( A - p_u), 1e-12, INFINITY );
		    DoubleMatrix rterm = pAlpha.div(AminusP);
		    //rho = A / clamp(( A - p_u), 1e-12, INFINITY );
		    DoubleMatrix rho = A.div(AminusP);
            //lterm = dot( rho, p_a); //
		    double lterm = rho.dot(pAlpha);
            //p_u = p_u % clamp((lterm - rterm), 0., INFINITY) ;
		    rterm.rsubi(lterm);
		    //rterm.subi(lterm);
		    //rterm.muli(-1);
		    rterm.maxi(0.0);
		    // p = p.muli(rterm); 
		    sum = p.dot(rterm);
		    if (sum > 0) {  // update p
		    	p.muli(rterm); // in-place element-wise multiplication,
		    	p.divi(sum);  // in-pace normalisation
		    }
		}   		
	}
	
}
 
开发者ID:mrc-ide,项目名称:PhyDyn,代码行数:35,代码来源:STreeLikelihood.java

示例2: testBigCorrelation

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
@Test
public void testBigCorrelation() {
    Random.seed(43);
    DoubleMatrix mat = DoubleMatrix.rand(20000, 5);
    mat.muli(4.3);
    ITable bigTable = BlasConversions.toTable(mat);
    String[] colNames = bigTable.getSchema().getColumnNames();
    IDataSet<ITable> dataset = TestTables.makeParallel(bigTable, 10);

    PCACorrelationSketch fcs = new PCACorrelationSketch(colNames);
    CorrMatrix cm = dataset.blockingSketch(fcs);

    // Construct the correlation matrix that we compare against by using pure JBLAS.
    DoubleMatrix cmCheck = new DoubleMatrix(colNames.length, colNames.length);
    DoubleMatrix means = mat.columnMeans();
    DoubleMatrix sigmas = MatrixFunctions.sqrt(
            mat.subRowVector(means).mul(mat.subRowVector(means)).columnMeans()
    );
    for (int i = 0; i < cmCheck.columns; i++) {
        DoubleMatrix c1 = mat.get(new AllRange(), i);
        for (int j = 0; j < cmCheck.rows; j++) {
            DoubleMatrix c2 = mat.get(new AllRange(), j);
            double corr = c1.dot(c2) / mat.rows;
            corr -= means.get(i) * means.get(j);
            corr /= sigmas.get(i) * sigmas.get(j);
            cmCheck.put(i, j, corr);
            cmCheck.put(j, i, corr);
        }
    }
    for (int i = 0; i < cm.getCorrelationMatrix().length; i++) {
        double[] row = cm.getCorrelationMatrix()[i];
        for (int j = 0; j < row.length; j++) {
            double actual = cm.getCorrelationMatrix()[i][j];
            double expected = cmCheck.get(i, j);
            Assert.assertEquals(expected, actual, 1e-5);
        }
    }
}
 
开发者ID:vmware,项目名称:hillview,代码行数:39,代码来源:CorrelationTest.java

示例3: distance

import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
public static double distance(DoubleMatrix x, DoubleMatrix y)
{
    return 1 - (x.dot(y) / (x.norm2() * y.norm2()));
}
 
开发者ID:rdspring1,项目名称:LSH_DeepLearning,代码行数:5,代码来源:CosineDistance.java


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