# HG changeset patch # User dbateman # Date 1194395281 0 # Node ID a018c140f8aa7114fff3c9e75e2804a07ada0525 # Parent f90a8188c9c28de1aeee6788ed987442af786b66 [project @ 2007-11-07 00:28:01 by dbateman] diff -r f90a8188c9c2 -r a018c140f8aa liboctave/ChangeLog --- a/liboctave/ChangeLog Wed Nov 07 00:24:12 2007 +0000 +++ b/liboctave/ChangeLog Wed Nov 07 00:28:01 2007 +0000 @@ -1,5 +1,11 @@ 2007-11-06 David Bateman + * intNDArray.cc (intNDArray intNDArray::sum (int) const): + New method. + * intNDarray.h (intNDArray sum (int) const): Declare it. + * boolNDArray.cc (boolNDArray boolNDArray::sum (int) const): + New method. + * boolNDarray.cc (boolNDArray sum (int) const): Declare it. * MArray-def.h (MARRAY_NORM_BODY): Scale frobenius norm by infinity norm to avoid issues of over- and underflow. From Rolf Fabian . diff -r f90a8188c9c2 -r a018c140f8aa liboctave/boolNDArray.cc --- a/liboctave/boolNDArray.cc Wed Nov 07 00:24:12 2007 +0000 +++ b/liboctave/boolNDArray.cc Wed Nov 07 00:28:01 2007 +0000 @@ -57,6 +57,12 @@ MX_ND_ANY_ALL_REDUCTION (MX_ND_ANY_EVAL (MX_ND_ANY_EXPR), false); } +boolNDArray +boolNDArray::sum (int dim) const +{ + MX_ND_REDUCTION (retval(result_idx) |= elem (iter_idx), true, boolNDArray); +} + boolNDArray boolNDArray::concat (const boolNDArray& rb, const Array& ra_idx) { diff -r f90a8188c9c2 -r a018c140f8aa liboctave/boolNDArray.h --- a/liboctave/boolNDArray.h Wed Nov 07 00:24:12 2007 +0000 +++ b/liboctave/boolNDArray.h Wed Nov 07 00:28:01 2007 +0000 @@ -66,6 +66,8 @@ boolNDArray all (int dim = -1) const; boolNDArray any (int dim = -1) const; + boolNDArray sum (int dim = -1) const; + boolNDArray concat (const boolNDArray& rb, const Array& ra_idx); boolNDArray& insert (const boolNDArray& a, octave_idx_type r, octave_idx_type c); diff -r f90a8188c9c2 -r a018c140f8aa liboctave/intNDArray.cc --- a/liboctave/intNDArray.cc Wed Nov 07 00:24:12 2007 +0000 +++ b/liboctave/intNDArray.cc Wed Nov 07 00:28:01 2007 +0000 @@ -222,6 +222,13 @@ return is; } +template +intNDArray +intNDArray::sum (int dim) const +{ + MX_ND_REDUCTION (retval(result_idx) += intNDArray::elem (iter_idx), 0, intNDArray); +} + /* ;;; Local Variables: *** ;;; mode: C++ *** diff -r f90a8188c9c2 -r a018c140f8aa liboctave/intNDArray.h --- a/liboctave/intNDArray.h Wed Nov 07 00:24:12 2007 +0000 +++ b/liboctave/intNDArray.h Wed Nov 07 00:28:01 2007 +0000 @@ -73,6 +73,8 @@ boolNDArray all (int dim = -1) const; boolNDArray any (int dim = -1) const; + intNDArray sum (int dim) const; + intNDArray squeeze (void) const { return intNDArray (MArrayN::squeeze ()); }