Skip to content
GitLab
    • Why GitLab
    • Pricing
    • Contact Sales
    • Explore
  • Why GitLab
  • Pricing
  • Contact Sales
  • Explore
  • Sign in
  • Get free trial
  • libeigenlibeigen
  • eigeneigen
  • Issues
  • #859

Eigen exp() returns Inf instead of NaN

Submitted by Marco Inacio

Assigned to Nobody

Link to original bugzilla bug (#859)
Version: 3.2
Operating system: Linux

Description

Whenever there is a NaN value inside an array, exp() will return an Inf instead of NaN.

Example bellow:

#include <iostream>
#include <limits>
#include <Eigen/Dense>

int main(){
double nan = std::numeric_limits<double>::quiet_NaN();

Eigen::MatrixXd m1(3,3);  
m1 << 10, 1.5, 3.2,  
      nan, 10, 4.1,  
      0.1, 4.1, 10;  
       
Eigen::MatrixXd m2(3,3);  
Eigen::ArrayXXd a1(3,3);  

//Has bug  
m2 = m1.array().exp().matrix();  
std::cout << m2 << std::endl << std::endl;  
  
//Has bug  
a1 = m1.array().exp();  
std::cout << a1 << std::endl << std::endl;  

//Output:  
//22026.5 4.48169 24.5325  
//inf 22026.5 60.3403  
//1.10517 60.3403 22026.5  
//  
//22026.5 4.48169 24.5325  
//inf 22026.5 60.3403  
//1.10517 60.3403 22026.5  

  



//Now, some other calls, just for comparison:  
a1 = m1.array();  
std::cout << a1 << std::endl << std::endl;    
    
for (int i; i < m1.size(); i++)  
  std::cout << std::exp(m1(i)) << std::endl;  
  
std::cout << std::endl;  

m2 = m1.array().log().matrix();  
std::cout << m2 << std::endl << std::endl;  
  
a1 = m1.array().log();  
std::cout << a1 << std::endl << std::endl;  

}

Blocking

#558 (closed)

Edited Dec 05, 2019 by Eigen Bugzilla
Assignee
Assign to
Time tracking