Registered Member
|
I want to write a generic function to produce a formatted dump of matrix content (for debugging), so the function needs to know whether a matrix is holding a simple integer, a complex double or whatever (I'm just using standard numeric types).
I vaguely know this is something to do with traits, but I'm new to this area of programming. Can someone quickly tell me the syntax for a switch test that will do this? Sorry for lowering the tone! But thanks for any help. |
Moderator
|
typename MatrixType::Scalar gives you the underlying scalar type, then you can either rely on template specialization, or use std::limits, our our NumTraits<Scalar>::IsComplex (check the NumTraits.h file to see what you can get), or even if(Eigen::internal::is_same<Scalar,std::complex<float> >::value) { ... }
|
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]