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 10:23:45 +0200

On Wed, Oct 8, 2008 at 9:39 AM, Zbigniew Komarnicki <address@hidden> wrote:
> Hello again :-)
>
> I would like to start writing a such package. After reading your and Soren
> hints, i thing that it can be created for example as new object (as for
> example a cell; writing e.g A=cell(1,10) give us a cell array with given size
> [1,10]). Now i think, that we can create a new object for example
>
> B=array([-3,3],[2,5])
>
> and we get "normal matrix/array" but with additional property within this
> object as:
> min_idx_1=-3 , max_idx_1=3
> min_idx_2= 2 , max_idx_2=5
>
> These indices of course internally can be stored as linked list in C++ or
> dynamically created array. It will be depends from the dimension of such
> array, for example:
> C=array([-2,10],[0,3],[1,7])  % 3-dimensional array
> so the indices will be
> min_idx_1=-2 , max_idx_1=10
> min_idx_2= 0 , max_idx_2=3
> min_idx_3= 0 , max_idx_3=7
>
>
> Writing B=array([-3,3],[2,5]) will be obligatory to create such object. To
> create normal matrix (or vector if 1 dimension array) we should use for
> example such calling:
> D=matrix(B);   % or in function call e.g:  my_func(matrix(B));
>
> and this calling will be create normal matrix 1 index based as normal matrix
> in octave, so we will be get
> D(1:7,1:4)
>
> I don't know that it will be OK, e.g that will be effective (fast execution)
> and simple in using to the end user giving him only two simple functions
> (constructors) such as:
> * "array" - to create object with arbitrary indices
> * "matrix" - to go back to normal object without arbitrary indices, but the
> standard one (as now in octave starting from 1)
>
> Of course we can add additionally functions for example to deal with indices
> (in order to creating new object to have the same size or not), e.g.
>
> [min_max_indices]=getarrayindices(B)
> then we will obtain
> min_max_indices=
> -3 3
> 2 5
>
> where, 'min_max_indices' can be e.g cell array, or  as above a matrix
> min_max_indices =
> {
>  [1,1] = -3
>  [2,1] =  2
>  [1,2] =  3
>  [2,2] =  5
> }
>
>
> Then we can create e.g:
> F=array(min_max_indices)
>
> Function 'size':
> s=size(B)
> s=
> 7 4
>
> Function 'type':
> type('B')
> B is variable array with
> min_max_indices=
> dim1: -3 3
> dim2: 2 5
>
> And many other additional functions which will be usefull.
>
> What do you think about such proposition? We do not need hold strictly
> definition of Fortran array. I only give it as an example.
>
> Creating 'view' is to complicated to me, and I suppose it will be also to
> complicated to other inexperience users.
> I prefer simple functions, as simple as possible.
>
> What do you think? It have a sense, what I propose?
>

I don't think that names "array" and "matrix" are a good idea. I'd
prefer something like "setbounds", "unsetbounds" to emphasize what the
functions are doing. Otherwise, this should be simple to achieve using
the OO stuff. I guess overriding a couple more functions like "find",
"min", and "max" may do some good.

>
> Thank you for your time.
>
> Best wishes,
> Zbigniew
>
>



-- 
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]