|   Registered Member   
 | 
							Hi, I need to swap some large Eigen matrices (many times), say matrices m1 and m2. Using the standard c++ swap(m1,m2) works fine, but is slow because it does a copy. When I use Eigen's swap routine m1.swap(m2), it works on small test cases, but becomes wrong for large matrices and many swaps! The only possible explanation I have is that in order to use fftw, I allocate with fftw_malloc 
 and then map to eigen 
 I also use #define EIGEN_DEFAULT_TO_ROW_MAJOR because fftw expects row-major format. Could the mapping be a problem, and is there a way to solve this? | 
|   Moderator   
 | 
							m1.swap(m2) with m1 and m2 Eigen::Matrix<> objects of the same type with "Dynamic" sizes does a fast shallow copy, i.e., only swap the pointers. Perhaps you tried with fixed size objects??
						 | 
|   Registered Member   
 | 
							youre right, I was mixing some fixed-size objects, and the problem is not the eigen swap at all. sorry, and thanks for your help!
						 | 
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]
 
		 
		 
		 
		