help-octave
[Top][All Lists]
Advanced

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

Re: arrays of objects.


From: Juan Pablo Carbajal
Subject: Re: arrays of objects.
Date: Mon, 4 Feb 2013 22:33:58 +0100

On Mon, Feb 4, 2013 at 10:25 PM, ernst <address@hidden> wrote:
>
> 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
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave

Can't tell what is the issue without more information, but based on my
own experinece with cellfun, the old class style is not woring very
well inside those functions. Is as if one would need to declare these
functions "friend functions" as in C++.

Though I can be completely off, not knowing exactly what is your
issue. Maybe you can upload your code to Agora?


reply via email to

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