本文整理汇总了Java中org.jblas.DoubleMatrix.dup方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleMatrix.dup方法的具体用法?Java DoubleMatrix.dup怎么用?Java DoubleMatrix.dup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jblas.DoubleMatrix
的用法示例。
在下文中一共展示了DoubleMatrix.dup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recursivePCA
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
public DoubleMatrix recursivePCA(DoubleMatrix A) {
DoubleMatrix C = A.dup();
while(C.columns > 3) {
int dim = (C.columns / 2) + 1;
logger.info("C.col = "+C.columns);
logger.info("dim = "+dim);
C = pca(C, dim);
save("C(dim="+dim+")", C);
}
return C;
}
示例2: computeDerivatives
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
@Override
public void computeDerivatives(double h, double[] ql, double[] dql)
throws MaxCountExceededException, DimensionMismatchException {
int tsPointCurrent = ts.getTimePoint(tsTimes0-h, tsPointLast);
tsPointLast = tsPointCurrent;
DoubleMatrix Y = ts.getYs()[tsPointCurrent];
DoubleMatrix F = ts.getFs()[tsPointCurrent];
DoubleMatrix G = ts.getGs()[tsPointCurrent];
if (forgiveY) Y.maxi(1.0); else Y.maxi(MIN_Y);
int i;
for(i=0; i < numStatesSQ; i++) qdata[i] = ql[i];
DoubleMatrix Q = new DoubleMatrix(numStates,numStates,qdata);
DoubleMatrix Qnorm = Q.dup();
Qnorm.diviRowVector(Q.columnSums());
DoubleMatrix A = Qnorm.mmul(A0);
A.divi(A.sum()); // normalised
A.muli(sumA0); // sum of A = sum(A0)
//A = A.mul(sumA0).div(A.sum());
DoubleMatrix a = A.div(Y); // column vector
// DoubleMatrix dQ = new DoubleMatrix(numStates,numStates,dql);
double dL = 0;
DoubleMatrix FG = F.add(G);
double accum;
int k,l,z;
i=0;
for (z = 0; z < numStates; z++){
for (k = 0; k < numStates; k++){
accum = 0;
for(l=0; l < numStates; l++) {
if (k != l) {
if (Q.get(l,z) > 0) {
accum += FG.get(k,l) * Q.get(l,z)/ Math.max(Q.get(l,z), Y.get(l));
}
if (Q.get(k,z) > 0) {
accum -= FG.get(l,k) * Q.get(k,z)/ Math.max(Q.get(k,z), Y.get(k));
}
}
if (Q.get(k,z) > 0) {
accum -= F.get(k,l) * a.get(l) * Q.get(k,z)/ Math.max(Q.get(k,z), Y.get(k));
}
}
//dQ.put(k,z,accum);
dql[i++] = accum;
}
}
for (k= 0; k < numStates; k++){
for (l =0 ; l < numStates; l++){
if (k == l && A.get(k) >= 1. ){
dL += (A.get(k) / Y.get(k)) * ((A.get(k)-1.) / Y.get(k)) * F.get(k,l) ;
} else {
dL += a.get(k) * a.get(l) * F.get(k,l);
}
}
}
dL = Math.max(dL, 0.);
dql[numStatesSQ] = dL;
}