help-octave
[Top][All Lists]
Advanced

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

Re: negative indexing of matrix or general access


From: Jaroslav Hajek
Subject: Re: negative indexing of matrix or general access
Date: Wed, 8 Oct 2008 08:35:55 +0200

On Wed, Oct 8, 2008 at 8:31 AM, Søren Hauberg <address@hidden> wrote:
> ons, 08 10 2008 kl. 07:58 +0200, skrev Jaroslav Hajek:
>> On Tue, Oct 7, 2008 at 10:33 PM, Zbigniew Komarnicki <address@hidden> wrote:
>> > Hello,
>> >
>> > is possible to write a class in OCT file by which I will can make the
>> > following access by negative index to a matrix or general access for
>> > arbitrary index . For example
>> >
>> >
>> > % this will be create a matrix with zero values (for example by calling a
>> > % constructor in C++ code in OCT file)
>> > % or
>> > % inserting zero values to such matrix (by operator=)
>> > A(-3:3, 2:5) = 0
>>
>> For this to work, you need to modify Octave itself, a package can't
>> override Octave's behaviour like that. A package would at least need a
>> special object constructor, like
>> A = nbizeros(-3:3, 2:5);
>> Afterwards, you could happily write
>> A(-2:2, 3:5) = whatever
>
> Can't you do this with the object system in the development sources? You
> just have to override the functions for the () operator (I think they're
> called 'subs'-something...).
>

Certainly you can. Overriding subsindex and subsasgn should suffice.
However, you will end up with something else than what Fortran 95
allows, as I have explained.
If you mean ensuring that
A(-3:3, 2:5) = 0
works, where A has not been defined; you can't do that.

-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

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