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

Checking for nan/inf

Tags: None
(comma "," separated)
LanternRouge
Registered Member
Posts
1
Karma
0
OS

Checking for nan/inf

Mon Oct 18, 2010 6:03 pm
Hi!

I would like to use std::isnan() and std::isinf() or equivalent to check for NaNs and Infs in a Eigen::Matrix<>.

Ideally, I would like to be able to do something like:

Matrix< ... > m ;

...

std::cout << "Number of NaNs : " << ( isnan( m.array() ) ).count ) << std::endl ;

Or, to use something like MATLAB's synatx: m( isnan( m ) ) = 0 ;

Is the best approach to add a new function/functor like the support for the math functions cos, sin, etc.?

I did RTFM but didn't find anything relevant.

Thanks!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Checking for nan/inf

Tue Oct 19, 2010 11:22 am
yes, the best approach is to:

1 - write the respective functor (if you are familiar with STL you can build it using STL mechanism, or have a look at the Eigen/src/Cor/Functors.h file for the examples)
2 - add such functions just like abs()


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient