help-octave
[Top][All Lists]
Advanced

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

arrays of objects.


From: ernst
Subject: arrays of objects.
Date: Mon, 04 Feb 2013 22:25:34 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120825 Thunderbird/15.0

Hi all,
I want to make octave use another kind of number
(just think of intervals, rationals, continued fractions.....) almost
like using the builtin types.
To this end, i have a class pn and constructor invocation like pn(3.4).

This already works quite well, I can do some basic programming works in
octave
using my own numbers.
I can even use vectors and matrices: [pn(2) pn3); pn(4) pn(5)] works.

BUT: I have problems with higher dimensional objects.
One example is arrayfun:
On the one hand side,  a=arrayfun(@pn,rand(2,3,4)) seem to work,
on the other hand, arrayfun(@doubleValue,a) does not work,
raising

"error: can't perform indexing operations for class type",

although doubleValue(pn(3)) does the correct conversion to double as
expected.

I tried with arrayfun with doubles and with chars, both work well.
Does it make sense, not to allow general classes?
How does Matlab react?? (i dont have one, because it is too expensive).

The alternative would be, to provide array-indexing for my class, but i
think, this makes no sense,
because i just want to use the indexing provided by octave.
I have the idea it must be like for java or c, where array indexing
is not needed to be implemented for each type.

Help very much apprechiated.

greetings,

Ernst


reply via email to

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