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
fieldMinMaxSumMV(const Field &field, double &min, double &max, double &sum)
{
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
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 &
*/
for (size_t i = 0; i < len; ++i)
{
if (array[i] < rmin) rmin = array[i];
if (array[i] > rmax) rmax = array[i];
rsum += array[i];
const auto v = array[i];
if (v < rmin) rmin = v;
if (v > rmax) rmax = v;
rsum += v;
}
}
......@@ -106,18 +107,19 @@ template void varrayMinMaxSum(const size_t len, const Varray<double> &array, dou
template <typename 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
size_t nvals = 0;
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 (array[i] > rmax) rmax = array[i];
rsum += array[i];
if (v < rmin) rmin = v;
if (v > rmax) rmax = v;
rsum += v;
nvals++;
}
}
......@@ -129,7 +131,7 @@ varrayMinMaxSumMV(const size_t len, const Varray<T> &array, const double missval
}
// 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);
void
......@@ -243,7 +245,7 @@ arrayNumMV(const size_t len, const double *restrict array, const double missval)
template <typename 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;
......@@ -262,7 +264,7 @@ varrayNumMV(const size_t len, const Varray<T> &array, const double missval)
}
// 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);
MinMaxVal
......
......@@ -120,7 +120,7 @@ template <typename T>
void varrayMinMaxSum(size_t len, const Varray<T> &array, double &rmin, double &rmax, double &rsum);
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);
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)
size_t arrayNumMV(size_t len, const double *array, double missval);
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 double *array);
......
......@@ -191,7 +191,7 @@ size_t
fieldNumMV(Field &field)
{
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
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