cern.colt.matrix.linalg.LUDecompositionQuick Java Examples

The following examples show how to use cern.colt.matrix.linalg.LUDecompositionQuick. 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 4 votes vote down vote up
/**
 */
public static void doubleTest23(int runs, int size, double nonZeroFraction, boolean dense) {
System.out.println("\n\n");
System.out.println("initializing...");
DoubleMatrix2D A, LU, I, Inv;
DoubleMatrix1D b, solved;

double mean = 5.0;
double stdDev = 3.0; 
cern.jet.random.Normal random = new cern.jet.random.Normal(mean, stdDev, new cern.jet.random.engine.MersenneTwister());

System.out.println("sampling...");
double value = 2;
if (dense) 
	A = Factory2D.dense.sample(size,size, value, nonZeroFraction);
else
	A = Factory2D.sparse.sample(size,size, value, nonZeroFraction);
b = A.like1D(size).assign(1);

//A.assign(random);
//A.assign(F.rint); // round
System.out.println("generating invertible matrix...");
Property.generateNonSingular(A);

//I = Factory2D.identity(size);

LU = A.like();
solved = b.like();
//Inv = Factory2D.make(size,size);

LUDecompositionQuick lu = new LUDecompositionQuick();

System.out.println("benchmarking assignment...");
cern.colt.Timer timer = new cern.colt.Timer().start();
LU.assign(A);
solved.assign(b);
timer.stop().display();

LU.assign(A);
lu.decompose(LU);

System.out.println("benchmarking LU...");
timer.reset().start();
for (int i=runs; --i >=0; ) {
	solved.assign(b);
	//Inv.assign(I);
	//lu.decompose(LU);
	lu.solve(solved);
	//lu.solve(Inv);
}
timer.stop().display();

//System.out.println("A="+A);
//System.out.println("LU="+LU);
//System.out.println("U="+lu.getU());
//System.out.println("L="+lu.getL());
System.out.println("done.");
	
}
 
Example #2
Source File: TestMatrix2D.java    From jAudioGIT with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 */
public static void doubleTest23(int runs, int size, double nonZeroFraction, boolean dense) {
System.out.println("\n\n");
System.out.println("initializing...");
DoubleMatrix2D A, LU, I, Inv;
DoubleMatrix1D b, solved;

double mean = 5.0;
double stdDev = 3.0; 
cern.jet.random.Normal random = new cern.jet.random.Normal(mean, stdDev, new cern.jet.random.engine.MersenneTwister());

System.out.println("sampling...");
double value = 2;
if (dense) 
	A = Factory2D.dense.sample(size,size, value, nonZeroFraction);
else
	A = Factory2D.sparse.sample(size,size, value, nonZeroFraction);
b = A.like1D(size).assign(1);

//A.assign(random);
//A.assign(F.rint); // round
System.out.println("generating invertible matrix...");
Property.generateNonSingular(A);

//I = Factory2D.identity(size);

LU = A.like();
solved = b.like();
//Inv = Factory2D.make(size,size);

LUDecompositionQuick lu = new LUDecompositionQuick();

System.out.println("benchmarking assignment...");
cern.colt.Timer timer = new cern.colt.Timer().start();
LU.assign(A);
solved.assign(b);
timer.stop().display();

LU.assign(A);
lu.decompose(LU);

System.out.println("benchmarking LU...");
timer.reset().start();
for (int i=runs; --i >=0; ) {
	solved.assign(b);
	//Inv.assign(I);
	//lu.decompose(LU);
	lu.solve(solved);
	//lu.solve(Inv);
}
timer.stop().display();

//System.out.println("A="+A);
//System.out.println("LU="+LU);
//System.out.println("U="+lu.getU());
//System.out.println("L="+lu.getL());
System.out.println("done.");
	
}