本文整理汇总了Java中cern.colt.matrix.DoubleMatrix1D.index方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleMatrix1D.index方法的具体用法?Java DoubleMatrix1D.index怎么用?Java DoubleMatrix1D.index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cern.colt.matrix.DoubleMatrix1D
的用法示例。
在下文中一共展示了DoubleMatrix1D.index方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: zMult
import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
public DoubleMatrix1D zMult(DoubleMatrix1D y, DoubleMatrix1D z, double alpha, double beta, final boolean transposeA) {
int m = rows;
int n = columns;
if (transposeA) {
m = columns;
n = rows;
}
boolean ignore = (z==null);
if (z==null) z = new DenseDoubleMatrix1D(m);
if (!(this.isNoView && y instanceof DenseDoubleMatrix1D && z instanceof DenseDoubleMatrix1D)) {
return super.zMult(y,z,alpha,beta,transposeA);
}
if (n != y.size() || m > z.size())
throw new IllegalArgumentException("Incompatible args: "+ ((transposeA ? viewDice() : this).toStringShort()) +", "+y.toStringShort()+", "+z.toStringShort());
if (!ignore) z.assign(cern.jet.math.Functions.mult(beta/alpha));
DenseDoubleMatrix1D zz = (DenseDoubleMatrix1D) z;
final double[] zElements = zz.elements;
final int zStride = zz.stride;
final int zi = z.index(0);
DenseDoubleMatrix1D yy = (DenseDoubleMatrix1D) y;
final double[] yElements = yy.elements;
final int yStride = yy.stride;
final int yi = y.index(0);
if (yElements==null || zElements==null) throw new InternalError();
forEachNonZero(
new cern.colt.function.IntIntDoubleFunction() {
public double apply(int i, int j, double value) {
if (transposeA) { int tmp=i; i=j; j=tmp; }
zElements[zi + zStride*i] += value * yElements[yi + yStride*j];
//z.setQuick(row,z.getQuick(row) + value * y.getQuick(column));
//System.out.println("["+i+","+j+"]-->"+value);
return value;
}
}
);
if (alpha!=1) z.assign(cern.jet.math.Functions.mult(alpha));
return z;
}
示例2: zMult
import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
public DoubleMatrix1D zMult(DoubleMatrix1D y, DoubleMatrix1D z, double alpha, double beta, final boolean transposeA) {
int m = rows;
int n = columns;
if (transposeA) {
m = columns;
n = rows;
}
boolean ignore = (z==null);
if (z==null) z = new DenseDoubleMatrix1D(m);
if (!(this.isNoView && y instanceof DenseDoubleMatrix1D && z instanceof DenseDoubleMatrix1D)) {
return super.zMult(y,z,alpha,beta,transposeA);
}
if (n != y.size() || m > z.size())
throw new IllegalArgumentException("Incompatible args: "+ ((transposeA ? viewDice() : this).toStringShort()) +", "+y.toStringShort()+", "+z.toStringShort());
if (!ignore) z.assign(cern.jet.math.Functions.mult(beta/alpha));
DenseDoubleMatrix1D zz = (DenseDoubleMatrix1D) z;
final double[] zElements = zz.elements;
final int zStride = zz.stride;
final int zi = z.index(0);
DenseDoubleMatrix1D yy = (DenseDoubleMatrix1D) y;
final double[] yElements = yy.elements;
final int yStride = yy.stride;
final int yi = y.index(0);
if (yElements==null || zElements==null) throw new InternalError();
this.elements.forEachPair(
new cern.colt.function.IntDoubleProcedure() {
public boolean apply(int key, double value) {
int i = key/columns;
int j = key%columns;
if (transposeA) { int tmp=i; i=j; j=tmp; }
zElements[zi + zStride*i] += value * yElements[yi + yStride*j];
//System.out.println("["+i+","+j+"]-->"+value);
return true;
}
}
);
/*
forEachNonZero(
new cern.colt.function.IntIntDoubleFunction() {
public double apply(int i, int j, double value) {
if (transposeA) { int tmp=i; i=j; j=tmp; }
zElements[zi + zStride*i] += value * yElements[yi + yStride*j];
//z.setQuick(row,z.getQuick(row) + value * y.getQuick(column));
//System.out.println("["+i+","+j+"]-->"+value);
return value;
}
}
);
*/
if (alpha!=1) z.assign(cern.jet.math.Functions.mult(alpha));
return z;
}