[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
overloading functions (Was: Indirect Addressing Question)
From: |
adler |
Subject: |
overloading functions (Was: Indirect Addressing Question) |
Date: |
Thu, 15 Nov 2001 22:15:57 -0500 (EST) |
On Wed, 14 Nov 2001, Paul Kienzle wrote:
> Andy, is there is sparse sum function?
I've just uploaded spsum.m to octave-forge.
It should be pretty fast as an *.m file - but I may
get around to doing it in *.cc later.
In the meantime, I have a question/bug report
For column vectors, the direction parameter of sum
allows control of the direction
octave-2.1.34:37> sum( [1 2 3]' )
ans = 6
octave-2.1.34:38> sum( [1 2 3]',1 )
ans = 6
octave-2.1.34:39> sum( [1 2 3]',2 )
ans =
1
2
3
However, this is not the case for row vectors.
octave-2.1.34:34> sum( [1 2 3] )
ans = 6
octave-2.1.34:35> sum( [1 2 3],1 )
ans = 6
octave-2.1.34:36> sum( [1 2 3],2 )
ans = 6
In other words sum(x) == sum(x,1).
Is this a bug?
> Anyone want to take a shot at modifying the interpreter so that you can
> overload functions for user-defined types?
This would be a _good thing_.
My suspicion is that this would be hard. You really need
quite a lot of OO infrastructure to this king of
function overloading. Matlab syntax and semantics don't
support this king of stuff.
I would really like this feature though, maybe someone can
think of a way to make it work.
> An alternative would be to replace the builtin function sum with a new one
> from sparse/sum.cc which tests if the type is sparse and if not calls
> the builtin sum function, but Octave won't support that either. Besides,
> it is even ickier.
I've just added is_sparse, is_real_sparse, is_complex_sparse
for anyone who wants to try something like this.
_______________________________________
Andy Adler, address@hidden
-------------------------------------------------------------
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
-------------------------------------------------------------
- Indirect Addressing Question, Etienne Grossmann, 2001/11/14
- Re: Indirect Addressing Question, Mirek Kwasniak, 2001/11/14
- Re: Indirect Addressing Question, Paul Kienzle, 2001/11/14
- overloading functions (Was: Indirect Addressing Question),
adler <=
- Re: overloading functions (Was: Indirect Addressing Question), Paul Kienzle, 2001/11/16
- Re: overloading functions (Was: Indirect Addressing Question), John W. Eaton, 2001/11/16
- Re: overloading functions (Was: Indirect Addressing Question), adler, 2001/11/16
- Re: overloading functions, Paul Kienzle, 2001/11/20
- semantics of sum, prod, cumsum etc., adler, 2001/11/22
- Re: Indirect Addressing Question, adler, 2001/11/15