[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Allocating N-dimensional Array in C++
From: |
Søren Hauberg |
Subject: |
Re: Allocating N-dimensional Array in C++ |
Date: |
Sun, 07 Mar 2010 15:08:10 -0800 |
søn, 07 03 2010 kl. 21:43 +0100, skrev Jaroslav Hajek:
> On Sun, Mar 7, 2010 at 7:34 PM, Søren Hauberg <address@hidden> wrote:
> > 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.
You mean the 'sizeof' trick, right?
> But the constructor could be potentially useful, so why not. It should
> be trivial, if you want to do it.
How about the attached changeset? With this, I can do
octave_idx_type tmp_size [] = {4, 5, 6, 7};
const dim_vector size (tmp_size, 4);
Array<double> A (size, 0);
I was a bit confused about the use of the 'explicit' keyword in the
other constructors. I thought this keyword only made a difference for
constructors with one input argument, but I see it is used with all
constructors.
Søren
dim-vector.changeset
Description: Text document
- Allocating N-dimensional Array in C++, Søren Hauberg, 2010/03/06
- Re: Allocating N-dimensional Array in C++, Carlo de Falco, 2010/03/06
- Re: Allocating N-dimensional Array in C++, Jaroslav Hajek, 2010/03/06
- Re: Allocating N-dimensional Array in C++, Søren Hauberg, 2010/03/07
- Re: Allocating N-dimensional Array in C++, Jaroslav Hajek, 2010/03/07
- Re: Allocating N-dimensional Array in C++,
Søren Hauberg <=
- Re: Allocating N-dimensional Array in C++, Jaroslav Hajek, 2010/03/08
- Re: Allocating N-dimensional Array in C++, Søren Hauberg, 2010/03/08
- Re: Allocating N-dimensional Array in C++, John W. Eaton, 2010/03/15
- Re: Allocating N-dimensional Array in C++, Jaroslav Hajek, 2010/03/17
- Re: Allocating N-dimensional Array in C++, John W. Eaton, 2010/03/18
- Re: Allocating N-dimensional Array in C++, Søren Hauberg, 2010/03/19