Boost logo

Boost Users :

Subject: Re: [Boost-users] 2d array arg, f( int m, int n, int a[m][n] ) with multi_arrays ?
From: Denis-B (denis-bz-py_at_[hidden])
Date: 2009-08-11 06:11:57


Anton Daneyko wrote:
>
> Could you add some more details to your question. It's not clear at least
> for me.
>

Sorry that wasn't clear: I want functions of 2d array args, whose sizes are
arguments too.
In the following I presumably need to
1) use index_gen to tell multi_array that A has extents Am x An
2) cast normal C arrays to multi_array args
Thanks

#include <boost/multi_array.hpp>
using namespace boost;

typedef multi_array< float, 2 > Array;
typedef multi_array_ref< float, 2 > Arrayref;
typedef const_multi_array_ref< float, 2 > Arrayconstref;
typedef multi_array_types::size_type siz;

    // 2d array args with runtime sizes: A[Am][An] -> a[am][an] ?
void arrayargs( Arrayconstref A, Arrayref a, siz Am, siz An, siz am, siz an
)
{
    // how say that A is Am x An ?
    int j = 0, k = 1;
    a[j][k] = A[j][k] / 4; // ...
}

int main( int argc, char* argv[] )
{
    int am = 100, an = 200;
    float A[am*2][an*2], a[am][an]; // vla

    arrayargs( A, a, am*2, an*2, am, an ); // how cast A, a ?
}

-- 
View this message in context: http://www.nabble.com/2d-array-arg%2C-f%28-int-m%2C-int-n%2C-int-a-m--n--%29-with-multi_arrays---tp24902846p24914877.html
Sent from the Boost - Users mailing list archive at Nabble.com.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net