use double precision for large summations, #4408
This commit is contained in:
parent
fc751a0cce
commit
e69952d654
@ -42,7 +42,8 @@ float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), fl
|
|||||||
}
|
}
|
||||||
|
|
||||||
//s is preconditionment of r. Without, direct to r.
|
//s is preconditionment of r. Without, direct to r.
|
||||||
float *s = r, rs = 0.0f;
|
float *s = r;
|
||||||
|
double rs = 0.0; // use double precision for large summations
|
||||||
|
|
||||||
if(Preconditioner != nullptr) {
|
if(Preconditioner != nullptr) {
|
||||||
s = new float[n];
|
s = new float[n];
|
||||||
@ -77,7 +78,7 @@ float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), fl
|
|||||||
|
|
||||||
for(iterate = 0; iterate < MaximumIterates; iterate++) {
|
for(iterate = 0; iterate < MaximumIterates; iterate++) {
|
||||||
//Get step size alpha, store ax while at it.
|
//Get step size alpha, store ax while at it.
|
||||||
float ab = 0.0f;
|
double ab = 0.0; // use double precision for large summations
|
||||||
Ax(ax, d, Pass);
|
Ax(ax, d, Pass);
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel for reduction(+:ab)
|
#pragma omp parallel for reduction(+:ab)
|
||||||
@ -94,7 +95,7 @@ float *SparseConjugateGradient(void Ax(float *Product, float *x, void *Pass), fl
|
|||||||
ab = rs / ab;
|
ab = rs / ab;
|
||||||
|
|
||||||
//Update x and r with this step size.
|
//Update x and r with this step size.
|
||||||
float rms = 0.0;
|
double rms = 0.0; // use double precision for large summations
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel for reduction(+:rms)
|
#pragma omp parallel for reduction(+:rms)
|
||||||
#endif
|
#endif
|
||||||
|
@ -70,7 +70,7 @@ void ImProcFunctions::PF_correct_RT(LabImage * src, LabImage * dst, double radiu
|
|||||||
gaussianBlur (src->b, tmp1->b, src->W, src->H, radius);
|
gaussianBlur (src->b, tmp1->b, src->W, src->H, radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
float chromave = 0.0f;
|
double chromave = 0.0; // use double precision for large summations
|
||||||
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel
|
#pragma omp parallel
|
||||||
@ -382,7 +382,7 @@ void ImProcFunctions::PF_correct_RTcam(CieImage * src, CieImage * dst, double ra
|
|||||||
gaussianBlur (srbb, tmbb, src->W, src->H, radius);
|
gaussianBlur (srbb, tmbb, src->W, src->H, radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
float chromave = 0.0f;
|
double chromave = 0.0; // use double precision for large summations
|
||||||
|
|
||||||
#ifdef __SSE2__
|
#ifdef __SSE2__
|
||||||
|
|
||||||
@ -1042,7 +1042,7 @@ void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, double radius
|
|||||||
|
|
||||||
|
|
||||||
// begin chroma badpixels
|
// begin chroma badpixels
|
||||||
float chrommed = 0.f;
|
double chrommed = 0.0; // use double precision for large summations
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel for reduction(+:chrommed)
|
#pragma omp parallel for reduction(+:chrommed)
|
||||||
#endif
|
#endif
|
||||||
@ -1646,7 +1646,7 @@ void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, double radius
|
|||||||
|
|
||||||
if(mode == 3) {
|
if(mode == 3) {
|
||||||
// begin chroma badpixels
|
// begin chroma badpixels
|
||||||
float chrommed = 0.f;
|
double chrommed = 0.0; // use double precision for large summations
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel for reduction(+:chrommed)
|
#pragma omp parallel for reduction(+:chrommed)
|
||||||
#endif
|
#endif
|
||||||
|
@ -2002,8 +2002,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw
|
|||||||
hist16Q.clear();
|
hist16Q.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
float sum = 0.f;
|
double sum = 0.0; // use double precision for large summations
|
||||||
// float sumQ = 0.f;
|
|
||||||
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
const int numThreads = min (max (width * height / 65536, 1), omp_get_max_threads());
|
const int numThreads = min (max (width * height / 65536, 1), omp_get_max_threads());
|
||||||
@ -2023,7 +2022,6 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pw
|
|||||||
hist16Qthr.clear();
|
hist16Qthr.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// #pragma omp for reduction(+:sum,sumQ)
|
|
||||||
#pragma omp for reduction(+:sum)
|
#pragma omp for reduction(+:sum)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1271,7 +1271,7 @@ void ImProcFunctions::Aver( float * RESTRICT DataList, int datalen, float &aver
|
|||||||
|
|
||||||
//find absolute mean
|
//find absolute mean
|
||||||
int countP = 0, countN = 0;
|
int countP = 0, countN = 0;
|
||||||
float averaP = 0.f, averaN = 0.f;
|
double averaP = 0.0, averaN = 0.0; // use double precision for large summations
|
||||||
|
|
||||||
float thres = 5.f;//different fom zero to take into account only data large enough
|
float thres = 5.f;//different fom zero to take into account only data large enough
|
||||||
max = 0.f;
|
max = 0.f;
|
||||||
@ -1332,7 +1332,7 @@ void ImProcFunctions::Aver( float * RESTRICT DataList, int datalen, float &aver
|
|||||||
void ImProcFunctions::Sigma( float * RESTRICT DataList, int datalen, float averagePlus, float averageNeg, float &sigmaPlus, float &sigmaNeg)
|
void ImProcFunctions::Sigma( float * RESTRICT DataList, int datalen, float averagePlus, float averageNeg, float &sigmaPlus, float &sigmaNeg)
|
||||||
{
|
{
|
||||||
int countP = 0, countN = 0;
|
int countP = 0, countN = 0;
|
||||||
float variP = 0.f, variN = 0.f;
|
double variP = 0.0, variN = 0.0; // use double precision for large summations
|
||||||
float thres = 5.f;//different fom zero to take into account only data large enough
|
float thres = 5.f;//different fom zero to take into account only data large enough
|
||||||
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
@ -1687,7 +1687,7 @@ void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float *
|
|||||||
float contrast = cp.contrast;
|
float contrast = cp.contrast;
|
||||||
float multL = (float)contrast * (maxl - 1.f) / 100.f + 1.f;
|
float multL = (float)contrast * (maxl - 1.f) / 100.f + 1.f;
|
||||||
float multH = (float) contrast * (maxh - 1.f) / 100.f + 1.f;
|
float multH = (float) contrast * (maxh - 1.f) / 100.f + 1.f;
|
||||||
double avedbl = 0.f; // use double precision for big summations
|
double avedbl = 0.0; // use double precision for large summations
|
||||||
float max0 = 0.f;
|
float max0 = 0.f;
|
||||||
float min0 = FLT_MAX;
|
float min0 = FLT_MAX;
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ float calculateGradients (Array2Df* H, Array2Df* G, int k, bool multithread)
|
|||||||
const int width = H->getCols();
|
const int width = H->getCols();
|
||||||
const int height = H->getRows();
|
const int height = H->getRows();
|
||||||
const float divider = pow ( 2.0f, k + 1 );
|
const float divider = pow ( 2.0f, k + 1 );
|
||||||
float avgGrad = 0.0f;
|
double avgGrad = 0.0; // use double precision for large summations
|
||||||
|
|
||||||
#pragma omp parallel for reduction(+:avgGrad) if(multithread)
|
#pragma omp parallel for reduction(+:avgGrad) if(multithread)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user