Boost logo

Boost Users :

From: François Duranleau (duranlef_at_[hidden])
Date: 2006-11-07 12:02:30


On Tue, 7 Nov 2006, Edward Grace wrote:

> Dear All,
>
> Is it possible to adapt e.g. a pointer to double in to a
> ublas::matrix<double>, or construct a matrix from a pointer to double?
>
> I have used the Blitz++ libraries, with those it is possible to use
> storage allocated elsewhere.
>
> This is to allow the painless interface of my code with legacy C
> code. I would like to do something like the following:
>
> using namespace boost::numeric::ublas;
>
>
> double *p;
> p = new double[100];
>
> .... Fill p[*] with data
>
> // Construct a 10x10 matrix using externally allocated storage.
> matrix<double> A(10,10,p);
[...]
> Help!! Is there a way to do this?

You could write your own storage class (see the Storage concept in the
uBLAS documentation) which is an adaptor for a pointer and you can assign
set the pointer via the data() member function of matrix<double>.

-- 
François Duranleau
LIGUM, Université de Montréal
"There are as many truths as there are people."
                                           - from _Neon Genesis Evangelion_

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