This forum has been archived. All content is frozen. Please use KDE Discuss instead.

beginners trait q

Tags: None
(comma "," separated)
wjh
Registered Member
Posts
5
Karma
0
OS

beginners trait q

Sat May 05, 2012 3:42 pm
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.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: beginners trait q

Sun May 06, 2012 8:18 am
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) { ... }


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]