Java Code Examples for cern.colt.matrix.DoubleMatrix1D#index()
The following examples show how to use
cern.colt.matrix.DoubleMatrix1D#index() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TridiagonalDoubleMatrix2D.java From database with GNU General Public License v2.0 | 4 votes |
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; }
Example 2
Source File: SparseDoubleMatrix2D.java From database with GNU General Public License v2.0 | 4 votes |
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; }
Example 3
Source File: TridiagonalDoubleMatrix2D.java From jAudioGIT with GNU Lesser General Public License v2.1 | 4 votes |
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; }
Example 4
Source File: SparseDoubleMatrix2D.java From jAudioGIT with GNU Lesser General Public License v2.1 | 4 votes |
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; }