Commit 30c526b4 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

varrayMinMaxSumMV: changed type of missval to T.

parent 10eef8a7
...@@ -49,7 +49,7 @@ size_t ...@@ -49,7 +49,7 @@ size_t
fieldMinMaxSumMV(const Field &field, double &min, double &max, double &sum) fieldMinMaxSumMV(const Field &field, double &min, double &max, double &sum)
{ {
if (field.memType == MemType::Float) if (field.memType == MemType::Float)
return varrayMinMaxSumMV(field.size, field.vec_f, field.missval, min, max, sum); return varrayMinMaxSumMV(field.size, field.vec_f, (float)field.missval, min, max, sum);
else else
return varrayMinMaxSumMV(field.size, field.vec_d, field.missval, min, max, sum); return varrayMinMaxSumMV(field.size, field.vec_d, field.missval, min, max, sum);
} }
......
...@@ -94,9 +94,10 @@ varrayMinMaxSum(const size_t len, const Varray<T> &array, double &rmin, double & ...@@ -94,9 +94,10 @@ varrayMinMaxSum(const size_t len, const Varray<T> &array, double &rmin, double &
*/ */
for (size_t i = 0; i < len; ++i) for (size_t i = 0; i < len; ++i)
{ {
if (array[i] < rmin) rmin = array[i]; const auto v = array[i];
if (array[i] > rmax) rmax = array[i]; if (v < rmin) rmin = v;
rsum += array[i]; if (v > rmax) rmax = v;
rsum += v;
} }
} }
...@@ -106,18 +107,19 @@ template void varrayMinMaxSum(const size_t len, const Varray<double> &array, dou ...@@ -106,18 +107,19 @@ template void varrayMinMaxSum(const size_t len, const Varray<double> &array, dou
template <typename T> template <typename T>
size_t size_t
varrayMinMaxSumMV(const size_t len, const Varray<T> &array, const double missval, double &rmin, double &rmax, double &rsum) varrayMinMaxSumMV(const size_t len, const Varray<T> &array, const T missval, double &rmin, double &rmax, double &rsum)
{ {
// rmin, rmax and rsum will be initialized in Info // rmin, rmax and rsum will be initialized in Info
size_t nvals = 0; size_t nvals = 0;
for (size_t i = 0; i < len; ++i) for (size_t i = 0; i < len; ++i)
{ {
if (!DBL_IS_EQUAL(array[i], missval)) const auto v = array[i];
if (!DBL_IS_EQUAL(v, missval))
{ {
if (array[i] < rmin) rmin = array[i]; if (v < rmin) rmin = v;
if (array[i] > rmax) rmax = array[i]; if (v > rmax) rmax = v;
rsum += array[i]; rsum += v;
nvals++; nvals++;
} }
} }
...@@ -129,7 +131,7 @@ varrayMinMaxSumMV(const size_t len, const Varray<T> &array, const double missval ...@@ -129,7 +131,7 @@ varrayMinMaxSumMV(const size_t len, const Varray<T> &array, const double missval
} }
// Explicit instantiation // Explicit instantiation
template size_t varrayMinMaxSumMV(const size_t len, const Varray<float> &array, const double missval, double &rmin, double &rmax, double &rsum); template size_t varrayMinMaxSumMV(const size_t len, const Varray<float> &array, const float missval, double &rmin, double &rmax, double &rsum);
template size_t varrayMinMaxSumMV(const size_t len, const Varray<double> &array, const double missval, double &rmin, double &rmax, double &rsum); template size_t varrayMinMaxSumMV(const size_t len, const Varray<double> &array, const double missval, double &rmin, double &rmax, double &rsum);
void void
...@@ -243,7 +245,7 @@ arrayNumMV(const size_t len, const double *restrict array, const double missval) ...@@ -243,7 +245,7 @@ arrayNumMV(const size_t len, const double *restrict array, const double missval)
template <typename T> template <typename T>
size_t size_t
varrayNumMV(const size_t len, const Varray<T> &array, const double missval) varrayNumMV(const size_t len, const Varray<T> &array, const T missval)
{ {
size_t nmiss = 0; size_t nmiss = 0;
...@@ -262,7 +264,7 @@ varrayNumMV(const size_t len, const Varray<T> &array, const double missval) ...@@ -262,7 +264,7 @@ varrayNumMV(const size_t len, const Varray<T> &array, const double missval)
} }
// Explicit instantiation // Explicit instantiation
template size_t varrayNumMV(const size_t len, const Varray<float> &array, const double missval); template size_t varrayNumMV(const size_t len, const Varray<float> &array, const float missval);
template size_t varrayNumMV(const size_t len, const Varray<double> &array, const double missval); template size_t varrayNumMV(const size_t len, const Varray<double> &array, const double missval);
MinMaxVal MinMaxVal
......
...@@ -120,7 +120,7 @@ template <typename T> ...@@ -120,7 +120,7 @@ template <typename T>
void varrayMinMaxSum(size_t len, const Varray<T> &array, double &rmin, double &rmax, double &rsum); void varrayMinMaxSum(size_t len, const Varray<T> &array, double &rmin, double &rmax, double &rsum);
template <typename T> template <typename T>
size_t varrayMinMaxSumMV(size_t len, const Varray<T> &array, double missval, double &rmin, double &rmax, double &rsum); size_t varrayMinMaxSumMV(size_t len, const Varray<T> &array, T missval, double &rmin, double &rmax, double &rsum);
void varrayMinMaxMean(size_t len, const Varray<double> &array, double &rmin, double &rmax, double &rmean); void varrayMinMaxMean(size_t len, const Varray<double> &array, double &rmin, double &rmax, double &rmean);
size_t varrayMinMaxMeanMV(size_t len, const Varray<double> &array, double missval, double &rmin, double &rmax, double &rmean); size_t varrayMinMaxMeanMV(size_t len, const Varray<double> &array, double missval, double &rmin, double &rmax, double &rmean);
...@@ -168,7 +168,7 @@ varrayCopy(const size_t len, const T &array1, T &array2) ...@@ -168,7 +168,7 @@ varrayCopy(const size_t len, const T &array1, T &array2)
size_t arrayNumMV(size_t len, const double *array, double missval); size_t arrayNumMV(size_t len, const double *array, double missval);
template <typename T> template <typename T>
size_t varrayNumMV(size_t len, const Varray<T> &array, double missval); size_t varrayNumMV(size_t len, const Varray<T> &array, T missval);
MinMaxVal varrayMinMax(size_t len, const Varray<double> &v); MinMaxVal varrayMinMax(size_t len, const Varray<double> &v);
MinMaxVal varrayMinMax(size_t len, const double *array); MinMaxVal varrayMinMax(size_t len, const double *array);
......
...@@ -191,7 +191,7 @@ size_t ...@@ -191,7 +191,7 @@ size_t
fieldNumMV(Field &field) fieldNumMV(Field &field)
{ {
if (field.memType == MemType::Float) if (field.memType == MemType::Float)
field.nmiss = varrayNumMV(field.size, field.vec_f, field.missval); field.nmiss = varrayNumMV(field.size, field.vec_f, (float)field.missval);
else else
field.nmiss = varrayNumMV(field.size, field.vec_d, field.missval); field.nmiss = varrayNumMV(field.size, field.vec_d, field.missval);
......
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