Boost logo

Ublas :

Subject: Re: [ublas] interpreting ublas::vector as a matrix?
From: Thomas Klimpel (Thomas.Klimpel_at_[hidden])
Date: 2011-12-08 10:47:16


Hi Oswin,

how about

#define BOOST_UBLAS_SHALLOW_ARRAY_ADAPTOR
#include <boost/numeric/ublas/matrix.hpp>

   boost::numeric::ublas::matrix<std::complex<double>, boost::numeric::ublas::column_major,
      boost::numeric::ublas::shallow_array_adaptor<std::complex<double> > > vv(10, 10,
      boost::numeric::ublas::shallow_array_adaptor<std::complex<double> > (100, &v(0)));

more or less, but I hope you get the idea.

Regards,
Thomas

> -----Original Message-----
> From: ublas-bounces_at_[hidden] [mailto:ublas-
> bounces_at_[hidden]] On Behalf Of Oswin Krause
> Sent: Thursday, December 08, 2011 1:26 PM
> To: ublas_at_[hidden]
> Subject: [ublas] interpreting ublas::vector as a matrix?
>
>
> Hi list,
>
> is there an easy way to interpret the contents of a vector as a matrix?
>
> e.g. like that for a 10 times 10 matrix and a vector with 100 elements:
> first row = v(0)...v(9)
> second row = v(11)...v(19)
> ...
> nth row = v(90)...v(99)
>
> I would like not to copy the vector into a matrix since the call to new
> plus
> copying of the elements into a matrix could easily exceed the runtime
> of
> the whole function.
>
> Is there maybe an adaptor I could use? Or could I just change a tiny
> bit
> of another adaptor to make this work?
>
> Greetings,
> Oswin
>
>
>
>
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: thomas.klimpel_at_[hidden]