octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem with sum (...)


From: John W. Eaton
Subject: Re: problem with sum (...)
Date: Tue, 06 Nov 2007 12:54:40 -0500

On  5-Nov-2007, David Bateman wrote:

| In any case consider the attached patch that adds this
| functionality to "sum"..

I applied the patch for OPERATORS/op-bm-bm.cc but not the other part
because it doesn't seem to implement the correctly functionality.
If I'm understanding correctly, your patch computes the sum using
doubles internally, then casts the result back to the original type.
That's not quite the same as doing the sum in the native type, which
is what the Matlab docs say they are doing.  For example, with the
saturation rules for integer arithmetic, Matlab computes

  sum (int8 ([127, 10, -20]), 'native')
  == (127 + 10) + -20
  == 127 + -20
  == 107

but with your patch, we get 117 because the saturation limit is only
applied at the end instead of after each operation.

Note that with 'native' it is critical to sum the elements in a
specific order.  Ugh.

| Perhaps the other data reduction operators
| should also include this functionality?

Hmm.  Maybe only if it is needed for compatibility.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]