Java Code Examples for cern.colt.matrix.DoubleMatrix1D#like()
The following examples show how to use
cern.colt.matrix.DoubleMatrix1D#like() .
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: TestMatrix2D.java From database with GNU General Public License v2.0 | 6 votes |
/** */ public static void doubleTest28() { double[] data={1,2,3,4,5,6}; double[][] arrMatrix = { { 1, 2, 3, 4, 5, 6}, { 2, 3, 4, 5, 6, 7} }; DoubleFactory2D f = DoubleFactory2D.dense; DoubleMatrix1D vector = new DenseDoubleMatrix1D(data); DoubleMatrix2D matrix = f.make(arrMatrix); DoubleMatrix1D res = vector.like(matrix.rows()); matrix.zMult(vector,res); System.out.println(res); }
Example 2
Source File: TestMatrix2D.java From database with GNU General Public License v2.0 | 6 votes |
/** */ public static void doubleTest28(DoubleFactory2D f) { double[] data={1,2,3,4,5,6}; double[][] arrMatrix = { { 1, 2, 3, 4, 5, 6}, { 2, 3, 4, 5, 6, 7} }; DoubleMatrix1D vector = new DenseDoubleMatrix1D(data); DoubleMatrix2D matrix = f.make(arrMatrix); DoubleMatrix1D res = vector.like(matrix.rows()); matrix.zMult(vector,res); System.out.println(res); }
Example 3
Source File: SeqBlas.java From database with GNU General Public License v2.0 | 6 votes |
public void dsymv(boolean isUpperTriangular, double alpha, DoubleMatrix2D A, DoubleMatrix1D x, double beta, DoubleMatrix1D y) { if (isUpperTriangular) A = A.viewDice(); Property.DEFAULT.checkSquare(A); int size = A.rows(); if (size != x.size() || size!=y.size()) { throw new IllegalArgumentException(A.toStringShort() + ", " + x.toStringShort() + ", " + y.toStringShort()); } DoubleMatrix1D tmp = x.like(); for (int i = 0; i < size; i++) { double sum = 0; for (int j = 0; j <= i; j++) { sum += A.getQuick(i,j) * x.getQuick(j); } for (int j = i + 1; j < size; j++) { sum += A.getQuick(j,i) * x.getQuick(j); } tmp.setQuick(i, alpha * sum + beta * y.getQuick(i)); } y.assign(tmp); }
Example 4
Source File: TestMatrix2D.java From jAudioGIT with GNU Lesser General Public License v2.1 | 6 votes |
/** */ public static void doubleTest28() { double[] data={1,2,3,4,5,6}; double[][] arrMatrix = { { 1, 2, 3, 4, 5, 6}, { 2, 3, 4, 5, 6, 7} }; DoubleFactory2D f = DoubleFactory2D.dense; DoubleMatrix1D vector = new DenseDoubleMatrix1D(data); DoubleMatrix2D matrix = f.make(arrMatrix); DoubleMatrix1D res = vector.like(matrix.rows()); matrix.zMult(vector,res); System.out.println(res); }
Example 5
Source File: TestMatrix2D.java From jAudioGIT with GNU Lesser General Public License v2.1 | 6 votes |
/** */ public static void doubleTest28(DoubleFactory2D f) { double[] data={1,2,3,4,5,6}; double[][] arrMatrix = { { 1, 2, 3, 4, 5, 6}, { 2, 3, 4, 5, 6, 7} }; DoubleMatrix1D vector = new DenseDoubleMatrix1D(data); DoubleMatrix2D matrix = f.make(arrMatrix); DoubleMatrix1D res = vector.like(matrix.rows()); matrix.zMult(vector,res); System.out.println(res); }
Example 6
Source File: SeqBlas.java From jAudioGIT with GNU Lesser General Public License v2.1 | 6 votes |
public void dsymv(boolean isUpperTriangular, double alpha, DoubleMatrix2D A, DoubleMatrix1D x, double beta, DoubleMatrix1D y) { if (isUpperTriangular) A = A.viewDice(); Property.DEFAULT.checkSquare(A); int size = A.rows(); if (size != x.size() || size!=y.size()) { throw new IllegalArgumentException(A.toStringShort() + ", " + x.toStringShort() + ", " + y.toStringShort()); } DoubleMatrix1D tmp = x.like(); for (int i = 0; i < size; i++) { double sum = 0; for (int j = 0; j <= i; j++) { sum += A.getQuick(i,j) * x.getQuick(j); } for (int j = i + 1; j < size; j++) { sum += A.getQuick(j,i) * x.getQuick(j); } tmp.setQuick(i, alpha * sum + beta * y.getQuick(i)); } y.assign(tmp); }
Example 7
Source File: SeqBlas.java From database with GNU General Public License v2.0 | 5 votes |
public void dtrmv(boolean isUpperTriangular, boolean transposeA, boolean isUnitTriangular, DoubleMatrix2D A, DoubleMatrix1D x) { if (transposeA) { A = A.viewDice(); isUpperTriangular = !isUpperTriangular; } Property.DEFAULT.checkSquare(A); int size = A.rows(); if (size != x.size()) { throw new IllegalArgumentException(A.toStringShort() + ", " + x.toStringShort()); } DoubleMatrix1D b = x.like(); DoubleMatrix1D y = x.like(); if (isUnitTriangular) { y.assign(1); } else { for (int i = 0; i < size; i++) { y.setQuick(i, A.getQuick(i,i)); } } for (int i = 0; i < size; i++) { double sum = 0; if (!isUpperTriangular) { for (int j = 0; j < i; j++) { sum += A.getQuick(i,j) * x.getQuick(j); } sum += y.getQuick(i) * x.getQuick(i); } else { sum += y.getQuick(i) * x.getQuick(i); for (int j = i + 1; j < size; j++) { sum += A.getQuick(i,j) * x.getQuick(j); } } b.setQuick(i,sum); } x.assign(b); }
Example 8
Source File: SeqBlas.java From jAudioGIT with GNU Lesser General Public License v2.1 | 5 votes |
public void dtrmv(boolean isUpperTriangular, boolean transposeA, boolean isUnitTriangular, DoubleMatrix2D A, DoubleMatrix1D x) { if (transposeA) { A = A.viewDice(); isUpperTriangular = !isUpperTriangular; } Property.DEFAULT.checkSquare(A); int size = A.rows(); if (size != x.size()) { throw new IllegalArgumentException(A.toStringShort() + ", " + x.toStringShort()); } DoubleMatrix1D b = x.like(); DoubleMatrix1D y = x.like(); if (isUnitTriangular) { y.assign(1); } else { for (int i = 0; i < size; i++) { y.setQuick(i, A.getQuick(i,i)); } } for (int i = 0; i < size; i++) { double sum = 0; if (!isUpperTriangular) { for (int j = 0; j < i; j++) { sum += A.getQuick(i,j) * x.getQuick(j); } sum += y.getQuick(i) * x.getQuick(i); } else { sum += y.getQuick(i) * x.getQuick(i); for (int j = i + 1; j < size; j++) { sum += A.getQuick(i,j) * x.getQuick(j); } } b.setQuick(i,sum); } x.assign(b); }