[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: sum() behaving erratically?

**From**: |
Francesco Potorti` |

**Subject**: |
Re: sum() behaving erratically? |

**Date**: |
Thu, 7 Oct 2004 03:10:33 -0500 |

>*> If I let a=[1,2;3,4]; and then ask for sum(a), sum(a,1) and sum(a,2), I*
>*> get the answers*
>*>*
>*> 4 6 4 6 3*
>*> 7*
>*>*
>*> respectively. Now I let a=[1,2]; and do the same. I now get*
>*>*
>*> 3 1 2 3*
>*>*
>*> indicating that in the second case sum(a) != sum(a,1), in direct*
>*> violation of the documentation in the manual. Is this supposed to be*
>*> like this and didn't I understand things, or is it a bug? (Octave is*
>*> 2.1.57.)*
>*This is a case of bug-for-bug compatibility.*
In fact, it is a bug in the manual and the help. Here is a patch:
-- Built-in Function: sum (X, DIM)
Sum of elements along dimension DIM. If DIM is omitted, it
! defaults to 1 (column-wise sum).
! defaults to 1 (column-wise sum) unless the argument is a
+ vector, in which case the sum of elements is returned.
Or, one could specify "unless the argument is a row vector".
--
Francesco PotortÃ¬ (ricercatore) Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR Fax: +39 050 313 8091
via G. Moruzzi 1, I-56124 Pisa Email: address@hidden
Web: http://fly.isti.cnr.it/ Key: fly.isti.cnr.it/public.key
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------