| 
					
							 Registered Member  
						
					
  | 
				
					 
							Hi,  
						
						I am trying to understand a compling error with this simple code: 
 The above code does not compile, so I have to write like this: 
 My questions is why the first code does not compile and the second code works.... I did search the forum but cannot find helpful information. The long compiling errors are pasted below: g++ -MMD -ggdb -O0 -D__STDC_LIMIT_MACROS -c Skat.cpp -I../libsrc -I../third/eigen -I../third/gsl/include Skat.cpp: In member function ‘int Skat::Fit(Vector&, Vector&, Matrix&, Matrix&, Vector&)’: Skat.cpp:44:53: error: no match for ‘operator-’ in ‘((Eigen::MatrixBase<Eigen::Matrix<float, -0x00000000000000001, 1> >*)(& v))->Eigen::MatrixBase<Derived>::asDiagonal [with Derived = Eigen::Matrix<float, -0x00000000000000001, 1>]() - Eigen::MatrixBase<Derived>::operator/(const Scalar&) const [with Derived = Eigen::GeneralProduct<Eigen::Matrix<float, -0x00000000000000001, 1>, Eigen::Transpose<Eigen::Matrix<float, -0x00000000000000001, 1> >, 2>, typename Eigen::internal::traits<T>::Scalar = float, Eigen::MatrixBase<Derived>::Scalar = float]((* &((Eigen::DenseBase<Eigen::Matrix<float, -0x00000000000000001, 1> >*)(& v))->Eigen::DenseBase<Derived>::sum [with Derived = Eigen::Matrix<float, -0x00000000000000001, 1>, typename Eigen::internal::traits<T>::Scalar = float]()))’ make: *** [Skat.o] Error 1  | 
			
| 
					
							 Moderator  
						
					
  | 
				
					 
							This is because diagonal_matrix - dense_matrix is not a supported operator yet. Recall that v.asDiagonal() returns an expression of a diagonal matrix, not a dense matrix. Thanks to the upcoming 'evaluators', we will soon be able to automatically evaluate your initial expression as: 
						
						P0 = v * v.transpose() / (-v.sum()); P0.diagonal() += v; which is more efficient than your second approach.  | 
			
| 
					
							 Registered Member  
						
					
  | 
				
Registered users: Baidu [Spider], Bing [Bot], Google [Bot]