Boost logo

Ublas :

Subject: Re: [ublas] Initializing a 3D matrix
From: Nasos Iliopoulos (nasos_i_at_[hidden])
Date: 2014-09-11 11:02:51

The code you just wrote should probably be:

boost::array< matrix<double>,5> function f
matrix<double> l,m,n,o,p;

boost::array< matrix<double>,5> t={l,m,n,o,p};
return t;

I would say just replace matrix<double> with boost multi-dimensional array.

Also depending on your compiler the previous might not be optimal (as
indicated in a previous post I made). Hence also consider using a reference:

typedef boost::multi_array<double, 3> md_array_type;
typedef boost::array<md_array_type, 5> collection_type;

function f( collection_type &collection )
md_array_type & l = collection[0];
md_array_type & m = collection[1];
// Do whatever with l, m... as those can be used as regular
mult-dimensional arrays in here.


and call like:

collection_type mda_collection;

f ( md_collection );

// now md_collection has been modified from function f.

Please post any further question regarding multi-dimensional arrays to
the general boost mailing list because they are out of context here.


On 09/11/2014 10:51 AM, sanann wrote:
> Thank you very much it has helped me a lot, and i now have what i need. i
> have used it for quite a wide extent before coming to a major problem.
> my case previously was that i used boost ublas matrix in a function whose
> output i could put into a boost array and use it as a function.
> function f
> {
> matrix<double>l,m,n,o,p;
> boost::array<f,5>t={l,m,n,o,p};
> return t;
> }
> now i would like to do the same for 3D matrices which i generated using
> boost multi_array. do you know any possible way to send the 3d arrays from a
> function into another piece of code
> --
> View this message in context:
> Sent from the Boost - uBLAS mailing list archive at
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> Sent to: athanasios.iliopoulos.ctr.gr_at_[hidden]