#2493: CarpetLib's minval and maxval always return first element
Reporter:Roland Haas
Status:new
Milestone:
Version:development version
Type:bug
Priority:major
Component:Carpet

Changes (by Roland Haas):

title:CarpetLib's minval and maxval always return first element (was CarpetLib''s minval and maxval always return first element)

This code:

ivect tst;
for(int i = 0 ; i < 3 ; i++)
  tst[i] = 3-i;
std::cerr<<"tst: "<<tst<<" minval: "<<minval(tst)<<"\n";

outputs:

tst: [3,2,1] minval: 3

and as far as I an tell this is due to the DECLARE_REDUCTION_FUNCTION_1 macro used in

DECLARE_REDUCTION_FUNCTION_1(minval, a[0], min, ID)

which assumes that max behaves like *= i.e. accumulates. See vect_helpers.hh:

#define DECLARE_REDUCTION_FUNCTION_1(fn, init, op, final)                      \
  }                                                                            \
  namespace CarpetLib_vect 

--
Ticket URL: https://bitbucket.org/einsteintoolkit/tickets/issues/2493/carpetlibs-minval-and-maxval-always-return