本文整理汇总了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
}
}
}
}
示例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);
}
}
}
示例3: distance
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
public static double distance(DoubleMatrix x, DoubleMatrix y)
{
return 1 - (x.dot(y) / (x.norm2() * y.norm2()));
}