help-octave
[Top][All Lists]
Advanced

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

Re: Allocating N-dimensional Array in C++


From: Jaroslav Hajek
Subject: Re: Allocating N-dimensional Array in C++
Date: Sun, 7 Mar 2010 21:43:14 +0100

On Sun, Mar 7, 2010 at 7:34 PM, Søren Hauberg <address@hidden> wrote:
> søn, 07 03 2010 kl. 05:49 +0100, skrev Jaroslav Hajek:
>> On Sat, Mar 6, 2010 at 7:53 PM, Søren Hauberg <address@hidden> wrote:
>> > Hi All
>> >
>> > I can't seem to figure out how to use 'dim_vector' in C++ (using the
>> > development sources). Say, I want to create a 4 dimensional array of
>> > size 1x7x3x2, then I would have thought I should do something like
>> >
>> >    dim_vector size (4, 1);
>>
>> This is a direct constructor for 2D dim-vector. Use
>>
>> dim_vector size = dim_vector::alloc (4);
>
> Okay, thanks. How do you feel about having an API for creating higher
> dimensional dim_vector's that would look something like this
>
>  const octave_idx_type tmp_size [] = {1, 7, 3, 2};
>  const dim_vector size (tmp_size, sizeof (tmp_size));
>
> ? To me, the current approach seems a bit tedious when working with more
> than 3 dimensions.
>

You can do the above trick only with constant sizes anyway, so it
doesn't seem much useful to me.
But the constructor could be potentially useful, so why not. It should
be trivial, if you want to do it.

regards

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
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]