Commit 663a964a authored by Andrey Filippov's avatar Andrey Filippov

Testing parallel Cholesky

parent 54367395
This diff is collapsed.
......@@ -12,6 +12,7 @@ import java.util.HashSet;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import com.elphel.imagej.common.CholeskyLDLTMulti;
import com.elphel.imagej.common.DoubleGaussianBlur;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.jp4.JP46_Reader_camera;
......@@ -21,6 +22,7 @@ import com.elphel.imagej.tileprocessor.QuadCLT;
import com.elphel.imagej.tileprocessor.TileNeibs;
import com.elphel.imagej.tileprocessor.TileProcessor;
import Jama.CholeskyDecomposition;
import Jama.Matrix;
import ij.IJ;
import ij.ImagePlus;
......@@ -1852,6 +1854,21 @@ public class VegetationLMA {
System.out.println("JtJ + lambda*diag(JtJ");
wjtjlambda.print(18, 6);
}
Matrix jty = (new Matrix(last_jt_decimated)).times(y_minus_fx_weighted);
Matrix mdelta = null; // jtjl_inv.times(jty);
boolean use_cholesky = true; // false;
double matrix_start_time = ((double) System.nanoTime()) * 1E-9;
if (use_cholesky) {
try {
mdelta = (new CholeskyDecomposition(wjtjlambda)).solve(jty);
} catch (RuntimeException e) {
rslt[1] = true;
if (debug_level > -2) {
System.out.println("Singular Matrix!");
}
return rslt;
}
} else { // old way - inverse() using LU
Matrix jtjl_inv = null;
try {
jtjl_inv = wjtjlambda.inverse(); // check for errors
......@@ -1867,16 +1884,32 @@ public class VegetationLMA {
System.out.println("(JtJ + lambda*diag(JtJ).inv()");
jtjl_inv.print(18, 6);
}
//last_jt has NaNs
// Matrix jty = (new Matrix(this.last_jt)).times(y_minus_fx_weighted);
Matrix jty = (new Matrix(last_jt_decimated)).times(y_minus_fx_weighted);
//last_jt has NaNs
// Matrix jty = (new Matrix(last_jt_decimated)).times(y_minus_fx_weighted);
if (debug_level>2) {
System.out.println("Jt * (y-fx)");
jty.print(18, 6);
}
mdelta = jtjl_inv.times(jty);
}
if (debug_level>-2) {
System.out.println("lmaStep(): Matrix inverted in "+((((double) System.nanoTime()) * 1E-9)-matrix_start_time)+
", used "+(use_cholesky? "Cholesky":"LU"));
}
Matrix mdelta = jtjl_inv.times(jty);
//
/*
CholeskyDecomposition choleskyDecomposition = new CholeskyDecomposition(wjtjlambda);
CholeskyLDLTMulti choleskyLDLTMulti = new CholeskyLDLTMulti(wjtjlambda);
Matrix mdelta_cholesky = choleskyDecomposition.solve(jty);
Matrix mdelta_cholesky_multi = choleskyLDLTMulti.solve(jty);
*/
CholeskyLDLTMulti.testCholesky(
wjtjlambda, // Matrix wjtjlambda,
jty);
if (debug_level>2) {
System.out.println("mdelta");
mdelta.print(18, 6);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment