Java Code Examples for cern.colt.matrix.DoubleFactory2D#dense()
The following examples show how to use
cern.colt.matrix.DoubleFactory2D#dense() .
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: Statistic.java From database with GNU General Public License v2.0 | 6 votes |
/** * Demonstrates usage of this class. */ public static void demo1() { double[][] values = { { 1, 2, 3 }, { 2, 4, 6 }, { 3, 6, 9 }, { 4, -8, -10 } }; DoubleFactory2D factory = DoubleFactory2D.dense; DoubleMatrix2D A = factory.make(values); System.out.println("\n\nmatrix="+A); System.out.println("\ncovar1="+covariance(A)); //System.out.println(correlation(covariance(A))); //System.out.println(distance(A,EUCLID)); //System.out.println(cern.colt.matrixpattern.Converting.toHTML(A.toString())); //System.out.println(cern.colt.matrixpattern.Converting.toHTML(covariance(A).toString())); //System.out.println(cern.colt.matrixpattern.Converting.toHTML(correlation(covariance(A)).toString())); //System.out.println(cern.colt.matrixpattern.Converting.toHTML(distance(A,EUCLID).toString())); }
Example 2
Source File: Statistic.java From database with GNU General Public License v2.0 | 6 votes |
/** * Demonstrates usage of this class. */ public static void demo2(int rows, int columns, boolean print) { System.out.println("\n\ninitializing..."); DoubleFactory2D factory = DoubleFactory2D.dense; DoubleMatrix2D A = factory.ascending(rows,columns); //double value = 1; //DoubleMatrix2D A = factory.make(rows,columns); //A.assign(value); System.out.println("benchmarking correlation..."); cern.colt.Timer timer = new cern.colt.Timer().start(); DoubleMatrix2D corr = correlation(covariance(A)); timer.stop().display(); if (print) { System.out.println("printing result..."); System.out.println(corr); } System.out.println("done."); }
Example 3
Source File: Statistic.java From database with GNU General Public License v2.0 | 6 votes |
/** * Demonstrates usage of this class. */ public static void demo3(VectorVectorFunction norm) { double[][] values = { { -0.9611052, -0.25421095 }, { 0.4308269, -0.69932648 }, { -1.2071029, 0.62030596 }, { 1.5345166, 0.02135884}, {-1.1341542, 0.20388430} }; System.out.println("\n\ninitializing..."); DoubleFactory2D factory = DoubleFactory2D.dense; DoubleMatrix2D A = factory.make(values).viewDice(); System.out.println("\nA="+A.viewDice()); System.out.println("\ndist="+distance(A,norm).viewDice()); }
Example 4
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 5
Source File: Statistic.java From jAudioGIT with GNU Lesser General Public License v2.1 | 6 votes |
/** * Demonstrates usage of this class. */ public static void demo1() { double[][] values = { { 1, 2, 3 }, { 2, 4, 6 }, { 3, 6, 9 }, { 4, -8, -10 } }; DoubleFactory2D factory = DoubleFactory2D.dense; DoubleMatrix2D A = factory.make(values); System.out.println("\n\nmatrix="+A); System.out.println("\ncovar1="+covariance(A)); //System.out.println(correlation(covariance(A))); //System.out.println(distance(A,EUCLID)); //System.out.println(cern.colt.matrixpattern.Converting.toHTML(A.toString())); //System.out.println(cern.colt.matrixpattern.Converting.toHTML(covariance(A).toString())); //System.out.println(cern.colt.matrixpattern.Converting.toHTML(correlation(covariance(A)).toString())); //System.out.println(cern.colt.matrixpattern.Converting.toHTML(distance(A,EUCLID).toString())); }
Example 6
Source File: Statistic.java From jAudioGIT with GNU Lesser General Public License v2.1 | 6 votes |
/** * Demonstrates usage of this class. */ public static void demo2(int rows, int columns, boolean print) { System.out.println("\n\ninitializing..."); DoubleFactory2D factory = DoubleFactory2D.dense; DoubleMatrix2D A = factory.ascending(rows,columns); //double value = 1; //DoubleMatrix2D A = factory.make(rows,columns); //A.assign(value); System.out.println("benchmarking correlation..."); cern.colt.Timer timer = new cern.colt.Timer().start(); DoubleMatrix2D corr = correlation(covariance(A)); timer.stop().display(); if (print) { System.out.println("printing result..."); System.out.println(corr); } System.out.println("done."); }
Example 7
Source File: Statistic.java From jAudioGIT with GNU Lesser General Public License v2.1 | 6 votes |
/** * Demonstrates usage of this class. */ public static void demo3(VectorVectorFunction norm) { double[][] values = { { -0.9611052, -0.25421095 }, { 0.4308269, -0.69932648 }, { -1.2071029, 0.62030596 }, { 1.5345166, 0.02135884}, {-1.1341542, 0.20388430} }; System.out.println("\n\ninitializing..."); DoubleFactory2D factory = DoubleFactory2D.dense; DoubleMatrix2D A = factory.make(values).viewDice(); System.out.println("\nA="+A.viewDice()); System.out.println("\ndist="+distance(A,norm).viewDice()); }
Example 8
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 9
Source File: BenchmarkMatrix.java From database with GNU General Public License v2.0 | 5 votes |
/** * Not yet documented. */ protected static DoubleFactory2D getFactory(String type) { DoubleFactory2D factory; if (type.equals("dense")) return DoubleFactory2D.dense; if (type.equals("sparse")) return DoubleFactory2D.sparse; if (type.equals("rowCompressed")) return DoubleFactory2D.rowCompressed; String s = "type="+type+" is unknown. Use one of {dense,sparse,rowCompressed}"; throw new IllegalArgumentException(s); }
Example 10
Source File: BigMatrixMultiplicationBenchmarking.java From tutorials with MIT License | 5 votes |
@Benchmark public Object coltMatrixMultiplication(BigMatrixProvider matrixProvider) { DoubleFactory2D doubleFactory2D = DoubleFactory2D.dense; DoubleMatrix2D firstMatrix = doubleFactory2D.make(matrixProvider.getFirstMatrix()); DoubleMatrix2D secondMatrix = doubleFactory2D.make(matrixProvider.getSecondMatrix()); Algebra algebra = new Algebra(); return algebra.mult(firstMatrix, secondMatrix); }
Example 11
Source File: MatrixMultiplicationBenchmarking.java From tutorials with MIT License | 5 votes |
@Benchmark public Object coltMatrixMultiplication(MatrixProvider matrixProvider) { DoubleFactory2D doubleFactory2D = DoubleFactory2D.dense; DoubleMatrix2D firstMatrix = doubleFactory2D.make(matrixProvider.getFirstMatrix()); DoubleMatrix2D secondMatrix = doubleFactory2D.make(matrixProvider.getSecondMatrix()); Algebra algebra = new Algebra(); return algebra.mult(firstMatrix, secondMatrix); }
Example 12
Source File: DoubleMatrix2DUnitTest.java From tutorials with MIT License | 5 votes |
@Test void givenTwoMatrices_whenMultiply_thenMultiplicatedMatrix() { DoubleFactory2D doubleFactory2D = DoubleFactory2D.dense; DoubleMatrix2D firstMatrix = doubleFactory2D.make( new double[][] { new double[] {1d, 5d}, new double[] {2d, 3d}, new double[] {1d ,7d} } ); DoubleMatrix2D secondMatrix = doubleFactory2D.make( new double[][] { new double[] {1d, 2d, 3d, 7d}, new double[] {5d, 2d, 8d, 1d} } ); DoubleMatrix2D expected = doubleFactory2D.make( new double[][] { new double[] {26d, 12d, 43d, 12d}, new double[] {17d, 10d, 30d, 17d}, new double[] {36d, 16d, 59d, 14d} } ); Algebra algebra = new Algebra(); DoubleMatrix2D actual = algebra.mult(firstMatrix, secondMatrix); assertThat(actual).isEqualTo(expected); }
Example 13
Source File: QRTest.java From database with GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) { // For COLT DoubleMatrix2D xmatrix,ymatrix,zmatrix; DoubleFactory2D myfactory; myfactory = DoubleFactory2D.dense; xmatrix = myfactory.make(8,2); ymatrix = myfactory.make(8,1); xmatrix.set(0,0,1); xmatrix.set(1,0,1); xmatrix.set(2,0,1); xmatrix.set(3,0,1); xmatrix.set(4,0,1); xmatrix.set(5,0,1); xmatrix.set(6,0,1); xmatrix.set(7,0,1); xmatrix.set(0,1,80); xmatrix.set(1,1,220); xmatrix.set(2,1,140); xmatrix.set(3,1,120); xmatrix.set(4,1,180); xmatrix.set(5,1,100); xmatrix.set(6,1,200); xmatrix.set(7,1,160); ymatrix.set(0,0,0.6); ymatrix.set(1,0,6.70); ymatrix.set(2,0,5.30); ymatrix.set(3,0,4.00); ymatrix.set(4,0,6.55); ymatrix.set(5,0,2.15); ymatrix.set(6,0,6.60); ymatrix.set(7,0,5.75); Algebra myAlgebra = new Algebra(); zmatrix = myAlgebra.solve(xmatrix,ymatrix); System.err.println(xmatrix); System.err.println(ymatrix); System.err.println(zmatrix); /* // For JAMA Matrix amatrix,bmatrix,cmatrix; amatrix = new Matrix(8,2); bmatrix = new Matrix(8,1); amatrix.set(0,0,1); amatrix.set(1,0,1); amatrix.set(2,0,1); amatrix.set(3,0,1); amatrix.set(4,0,1); amatrix.set(5,0,1); amatrix.set(6,0,1); amatrix.set(7,0,1); amatrix.set(0,1,80); amatrix.set(1,1,220); amatrix.set(2,1,140); amatrix.set(3,1,120); amatrix.set(4,1,180); amatrix.set(5,1,100); amatrix.set(6,1,200); amatrix.set(7,1,160); bmatrix.set(0,0,0.6); bmatrix.set(1,0,6.70); bmatrix.set(2,0,5.30); bmatrix.set(3,0,4.00); bmatrix.set(4,0,6.55); bmatrix.set(5,0,2.15); bmatrix.set(6,0,6.60); bmatrix.set(7,0,5.75); cmatrix = amatrix.solve(bmatrix); amatrix.print(8,5); bmatrix.print(8,5); cmatrix.print(8,5); */ }
Example 14
Source File: QRTest.java From jAudioGIT with GNU Lesser General Public License v2.1 | 4 votes |
public static void main(String args[]) { // For COLT DoubleMatrix2D xmatrix,ymatrix,zmatrix; DoubleFactory2D myfactory; myfactory = DoubleFactory2D.dense; xmatrix = myfactory.make(8,2); ymatrix = myfactory.make(8,1); xmatrix.set(0,0,1); xmatrix.set(1,0,1); xmatrix.set(2,0,1); xmatrix.set(3,0,1); xmatrix.set(4,0,1); xmatrix.set(5,0,1); xmatrix.set(6,0,1); xmatrix.set(7,0,1); xmatrix.set(0,1,80); xmatrix.set(1,1,220); xmatrix.set(2,1,140); xmatrix.set(3,1,120); xmatrix.set(4,1,180); xmatrix.set(5,1,100); xmatrix.set(6,1,200); xmatrix.set(7,1,160); ymatrix.set(0,0,0.6); ymatrix.set(1,0,6.70); ymatrix.set(2,0,5.30); ymatrix.set(3,0,4.00); ymatrix.set(4,0,6.55); ymatrix.set(5,0,2.15); ymatrix.set(6,0,6.60); ymatrix.set(7,0,5.75); Algebra myAlgebra = new Algebra(); zmatrix = myAlgebra.solve(xmatrix,ymatrix); System.err.println(xmatrix); System.err.println(ymatrix); System.err.println(zmatrix); /* // For JAMA Matrix amatrix,bmatrix,cmatrix; amatrix = new Matrix(8,2); bmatrix = new Matrix(8,1); amatrix.set(0,0,1); amatrix.set(1,0,1); amatrix.set(2,0,1); amatrix.set(3,0,1); amatrix.set(4,0,1); amatrix.set(5,0,1); amatrix.set(6,0,1); amatrix.set(7,0,1); amatrix.set(0,1,80); amatrix.set(1,1,220); amatrix.set(2,1,140); amatrix.set(3,1,120); amatrix.set(4,1,180); amatrix.set(5,1,100); amatrix.set(6,1,200); amatrix.set(7,1,160); bmatrix.set(0,0,0.6); bmatrix.set(1,0,6.70); bmatrix.set(2,0,5.30); bmatrix.set(3,0,4.00); bmatrix.set(4,0,6.55); bmatrix.set(5,0,2.15); bmatrix.set(6,0,6.60); bmatrix.set(7,0,5.75); cmatrix = amatrix.solve(bmatrix); amatrix.print(8,5); bmatrix.print(8,5); cmatrix.print(8,5); */ }