|
|
@ -36,6 +36,7 @@ |
|
|
#include "PrismSparseGlob.h"
|
|
|
#include "PrismSparseGlob.h"
|
|
|
#include "jnipointer.h"
|
|
|
#include "jnipointer.h"
|
|
|
#include "prism.h"
|
|
|
#include "prism.h"
|
|
|
|
|
|
#include "Measures.h"
|
|
|
#include "ExportIterations.h"
|
|
|
#include "ExportIterations.h"
|
|
|
#include <memory>
|
|
|
#include <memory>
|
|
|
#include <new>
|
|
|
#include <new>
|
|
|
@ -88,8 +89,10 @@ jboolean forwards // forwards or backwards? |
|
|
double time_taken, time_for_setup, time_for_iters; |
|
|
double time_taken, time_for_setup, time_for_iters; |
|
|
// misc
|
|
|
// misc
|
|
|
int i, j, fb, l, h, iters; |
|
|
int i, j, fb, l, h, iters; |
|
|
double d, x, sup_norm, kb, kbt; |
|
|
|
|
|
|
|
|
double d, kb, kbt; |
|
|
bool done; |
|
|
bool done; |
|
|
|
|
|
// measure for convergence termination check
|
|
|
|
|
|
MeasureSupNorm measure(term_crit == TERM_CRIT_RELATIVE); |
|
|
|
|
|
|
|
|
// exception handling around whole function
|
|
|
// exception handling around whole function
|
|
|
try { |
|
|
try { |
|
|
@ -214,7 +217,7 @@ jboolean forwards // forwards or backwards? |
|
|
time_for_setup = (double)(stop - start2)/1000; |
|
|
time_for_setup = (double)(stop - start2)/1000; |
|
|
start2 = stop; |
|
|
start2 = stop; |
|
|
start3 = stop; |
|
|
start3 = stop; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// start iterations
|
|
|
// start iterations
|
|
|
iters = 0; |
|
|
iters = 0; |
|
|
done = false; |
|
|
done = false; |
|
|
@ -224,7 +227,7 @@ jboolean forwards // forwards or backwards? |
|
|
|
|
|
|
|
|
iters++; |
|
|
iters++; |
|
|
|
|
|
|
|
|
sup_norm = 0.0; |
|
|
|
|
|
|
|
|
measure.reset(); |
|
|
|
|
|
|
|
|
// store local copies of stuff
|
|
|
// store local copies of stuff
|
|
|
double *non_zeros; |
|
|
double *non_zeros; |
|
|
@ -282,11 +285,7 @@ jboolean forwards // forwards or backwards? |
|
|
} |
|
|
} |
|
|
// compute norm for convergence
|
|
|
// compute norm for convergence
|
|
|
// (note we must do this inside the loop because we only store one vector for sor/gauss-seidel)
|
|
|
// (note we must do this inside the loop because we only store one vector for sor/gauss-seidel)
|
|
|
x = fabs(d - soln[i]); |
|
|
|
|
|
if (term_crit == TERM_CRIT_RELATIVE) { |
|
|
|
|
|
x /= d; |
|
|
|
|
|
} |
|
|
|
|
|
if (x > sup_norm) sup_norm = x; |
|
|
|
|
|
|
|
|
measure.measure(soln[i], d); |
|
|
// set vector element
|
|
|
// set vector element
|
|
|
soln[i] = d; |
|
|
soln[i] = d; |
|
|
} |
|
|
} |
|
|
@ -295,13 +294,13 @@ jboolean forwards // forwards or backwards? |
|
|
iterationExport->exportVector(soln, n, 0); |
|
|
iterationExport->exportVector(soln, n, 0); |
|
|
|
|
|
|
|
|
// check convergence
|
|
|
// check convergence
|
|
|
if (sup_norm < term_crit_param) { |
|
|
|
|
|
|
|
|
if (measure.value() < term_crit_param) { |
|
|
done = true; |
|
|
done = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// print occasional status update
|
|
|
// print occasional status update
|
|
|
if ((util_cpu_time() - start3) > UPDATE_DELAY) { |
|
|
if ((util_cpu_time() - start3) > UPDATE_DELAY) { |
|
|
PS_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, (term_crit == TERM_CRIT_RELATIVE)?"relative ":"", sup_norm); |
|
|
|
|
|
|
|
|
PS_PrintToMainLog(env, "Iteration %d: max %sdiff=%f", iters, measure.isRelative()?"relative ":"", measure.value()); |
|
|
PS_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); |
|
|
PS_PrintToMainLog(env, ", %.2f sec so far\n", ((double)(util_cpu_time() - start2)/1000)); |
|
|
start3 = util_cpu_time(); |
|
|
start3 = util_cpu_time(); |
|
|
} |
|
|
} |
|
|
|