Reply to topic

how to construct one complex matrix from two simple matrix

silent_missile
Registered Member
Posts
7
Karma
0
OS
hello

I have 2 MatrixXd, and I hope to construct one MatrixXcd from them, how can I realize it?

I checked the manual, but couldn't find.

It's easy to read in numbers for a simple MatrixXd, but I couldn't find similar way to input data into a complex MatrixXcd, did I miss something?
Dee33
Registered Member
Posts
54
Karma
0
OS
loop over the values of the matrix and use std::complex
Code: Select all
complexmat.coeffRef(i,j) = std::complex(Real, Imag)
User avatar ggael
Moderator
Posts
2194
Karma
15
OS
there is a more direct solution:

Code: Select all
MatrixXd r, i;
// ...
MatrixXcd c;
c.resizeLike(r);
c.real() = r;
c.imag() = i;

 
Reply to topic

Bookmarks



Who is online

Registered users: Abdelrahman Magdy, Baidu [Spider], Bing [Bot], colomar, cylverbak, edmael, Exabot [Bot], Google [Bot], google01103, jeanliu, ken300, koriun, Majestic-12 [Bot], MSNbot Media, navalgupte, paulus3005, psbot [Picsearch], robinh, scummos, Sentynel, TheraHedwig, tshearer, Uri_Herrera, vascobasque, wolfi323, Yahoo [Bot]