diff options
author | Erik Schnetter <schnetter@gmail.com> | 2013-05-20 09:12:30 -0500 |
---|---|---|
committer | Erik Schnetter <schnetter@gmail.com> | 2013-05-20 09:12:30 -0500 |
commit | b694764659c6bfedc9e5aeb375635526f8db36e3 (patch) | |
tree | d5d5d3b9b6e6b139cf0029dc7c0d0f8867a53420 | |
parent | 0694b5d4b8caec8a2c5abb0680f2362581e88402 (diff) |
CarpetLib: Change meaning of vect::count to count true (non-zero) elements
Change count() from counting all elements, which is already done by size(), to counting true (non-zero) elements, which is what Fortran's count() does as well.
-rw-r--r-- | Carpet/CarpetLib/src/vect.hh | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Carpet/CarpetLib/src/vect.hh b/Carpet/CarpetLib/src/vect.hh index 0bbaddf6b..95840b17c 100644 --- a/Carpet/CarpetLib/src/vect.hh +++ b/Carpet/CarpetLib/src/vect.hh @@ -457,11 +457,11 @@ DECLARE_REDUCTION_OPERATOR_1 (sum,0,+=,id) DECLARE_REDUCTION_OPERATOR_2 (dot ,0,+=,*,id ) DECLARE_REDUCTION_OPERATOR_2 (hypot,0,+=,*,sqrt) -/** Count the number of elements in the vector. */ +/** Count the number of true (non-zero) elements in the vector. */ template<typename T,int D> inline int count (const vect<T,D>& a) { - return D; + return sum(a != T(0)); } /** Return the size (number of elements) of the vector. */ |