I have a double pointer, store some data in it.
I want directly create a VectorXd on the pointer without copy. That is, the data stored in VectorXd is just the data stored in pointer. They are shared.
I know it is easy to create a VectorXd object then copy data into it from the pointer. I do not want the element by element copy happen in order to reduce copy overhead. It is already be proved be the performance bolttleneck in my application.
#include <Eigen/Core>
using namespace Eigen;
int main()
{
double *ptr = new double [100];
// fill something into pointer ...
VectorXd vector(ptr); // dicretely construct vector from pointer without data copy
// using vector for some other calculation... like matrix vector multiple
delete[] ptr;
return 0;
}
I apologize if it is a stupid problem. Thanks for your time.