2d array arg, f( int m, int n, int a[m][n] ) with multi_arrays ?

Folks, how can I do the following with multi_arrays please ? void f( int m, int n, int a[m][n] ) // legal C99 ? dunno -- would be nice { ... a[j][k] = ... } ... int *a; // m*n ints, e.g. an image f( m, n, a ); thanks, cheers -- denis -- 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... Sent from the Boost - Users mailing list archive at Nabble.com.

Could you add some more details to your question. It's not clear at least for me. On Mon, Aug 10, 2009 at 6:25 PM, Denis-B <denis-bz-py@t-online.de> wrote:
Folks, how can I do the following with multi_arrays please ?
void f( int m, int n, int a[m][n] ) // legal C99 ? dunno -- would be nice { ... a[j][k] = ... } ... int *a; // m*n ints, e.g. an image f( m, n, a );
thanks, cheers -- denis -- 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... Sent from the Boost - Users mailing list archive at Nabble.com.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

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... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (2)
-
Anton Daneyko
-
Denis-B