.
This commit is contained in:
parent
82ca023f6b
commit
724db25c51
@ -24888,27 +24888,28 @@ namespace cimg_library_suffixed {
|
||||
**/
|
||||
CImg<Tdouble> get_stats(const unsigned int variance_method=1) const {
|
||||
if (is_empty()) return CImg<doubleT>();
|
||||
const T *const p_end = end(), *pm = _data, *pM = _data;
|
||||
double S = 0, S2 = 0, P = 1;
|
||||
const ulongT siz = size();
|
||||
T m = *pm, M = *pM;
|
||||
const longT off_end = (longT)siz;
|
||||
double S = 0, S2 = 0, P = 1;
|
||||
longT offm = 0, offM = 0;
|
||||
T m = *_data, M = m;
|
||||
|
||||
cimg_pragma_openmp(parallel reduction(+:S,S2) reduction(*:P) cimg_openmp_if(siz>=131072)) {
|
||||
const T *lpm = _data, *lpM = _data;
|
||||
T lm = *lpm, lM = *lpM;
|
||||
longT loffm = 0, loffM = 0;
|
||||
T lm = *_data, lM = lm;
|
||||
cimg_pragma_openmp(for)
|
||||
for (const T *ptrs = _data; ptrs<p_end; ++ptrs) {
|
||||
const T val = *ptrs;
|
||||
for (longT off = 0; off<off_end; ++off) {
|
||||
const T val = _data[off];
|
||||
const double _val = (double)val;
|
||||
if (val<lm) { lm = val; lpm = ptrs; }
|
||||
if (val>lM) { lM = val; lpM = ptrs; }
|
||||
if (val<lm) { lm = val; loffm = off; }
|
||||
if (val>lM) { lM = val; loffM = off; }
|
||||
S+=_val;
|
||||
S2+=_val*_val;
|
||||
P*=_val;
|
||||
}
|
||||
cimg_pragma_openmp(critical(get_stats)) {
|
||||
if (lm<m || (lm==m && lpm<pm)) { m = lm; pm = lpm; }
|
||||
if (lM>M || (lM==M && lpM<pM)) { M = lM; pM = lpM; }
|
||||
if (lm<m || (lm==m && loffm<offm)) { m = lm; offm = loffm; }
|
||||
if (lM>M || (lM==M && loffM<offM)) { M = lM; offM = loffM; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -24921,8 +24922,8 @@ namespace cimg_library_suffixed {
|
||||
int
|
||||
xm = 0, ym = 0, zm = 0, cm = 0,
|
||||
xM = 0, yM = 0, zM = 0, cM = 0;
|
||||
contains(*pm,xm,ym,zm,cm);
|
||||
contains(*pM,xM,yM,zM,cM);
|
||||
contains(_data[offm],xm,ym,zm,cm);
|
||||
contains(_data[offM],xM,yM,zM,cM);
|
||||
return CImg<Tdouble>(1,14).fill((double)m,(double)M,mean_value,variance_value,
|
||||
(double)xm,(double)ym,(double)zm,(double)cm,
|
||||
(double)xM,(double)yM,(double)zM,(double)cM,
|
||||
|
Loading…
Reference in New Issue
Block a user