Re: [eigen] is MAP oneway ? (urgent) |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
On 24 Jun, Helmut Jarausch wrote:
> Hi,
>
> I have to write a function which is called by code which is
> written in C-style (though compiled with g++).
> It delivers me data in a C-array (double*) and expects me
> to modify this.
>
> When I tried the following example, I was a bit surprised.
> So, what does MAP do?
>
>
> #include <iostream>
> using std::cerr; using std::endl;
> #include <Eigen/Core>
> // import most common Eigen types
> USING_PART_OF_NAMESPACE_EIGEN
>
> int main() {
> double data[4] = {1, 2, 3, 4};
>
> VectorXd D = Eigen::Map<VectorXd>(data,4);
> cerr << "D before : " << D << endl;
> data[1]= 7;
> cerr << "D after : " << D << endl; // nothing has changed
> }
>
>
> So, do I have to copy all data from D.data() back to data?
>
> Is there something like "overlaying" an Eigen-Vector onto some raw
> C-array?
>
> Many thanks for a quick hint,
> Helmut.
>
Sorry for replying to my own email.
I've forgotten to tell you that I also need the otherway round
add in the above code
D[1]= 17;
cerr << "data[1] now: " << data[1] << endl;
--
Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany