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);
There does appear to be a hint that I can use my own allocator, but
it is far from clear how I go about doing this. For example coming up
with an Allocator function that doesn't allocate but instead uses
existing memory.
class MyAllocator : public GeneralAllocator {
double *TheMemory;
public:
MyAllocator(double *p) {
TheMemory = p;
}
allocate() {}
};
matrix