boost multi array dynamic size

M

marcomoeller

Hi,

I whant to write an function (ore overloading the class) which is able
to trace out an row of the Array. So the function becomes an array of
Dim n and returns one of Dim n-1.

something like:
template <class T, class B>
boost::multi_array<T, B - 1> * TraceOut(boost::multi_array<T, B> a,
int i){
//Summerize the values of a into a new array without to consider
different values in the i-th Row
}

I know that B-1 is not possible.. do you have any better idea?

THX


Marco
 
I

Ivan Vecerina

: I whant to write an function (ore overloading the class) which is able
: to trace out an row of the Array. So the function becomes an array of
: Dim n and returns one of Dim n-1.
:
: something like:
: template <class T, class B>
: boost::multi_array<T, B - 1> * TraceOut(boost::multi_array<T, B> a,
: int i){
: //Summerize the values of a into a new array without to consider
: different values in the i-th Row
: }
:
: I know that B-1 is not possible.. do you have any better idea?

The expression (B-1) is perfectly ok, if you correctly declare
B as an ordinal template parameter (not as a type).

Something like the following should work:
template< class T, std::size_t N >
boost::multi_array<T,N-1>
TraceOut( boost::multi_array<T,N> const& a, int i )
{ ... }

hth -Ivan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,197
Messages
2,571,038
Members
47,633
Latest member
BriannaLyk

Latest Threads

Top