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

Eigen Matrix size overflow?

Tags: None
(comma "," separated)
surle
Registered Member
Posts
7
Karma
0

Eigen Matrix size overflow?

Fri Apr 11, 2014 10:30 am
Does the Eigen library check for matrix size overflow?

I see there's a function called check_rows_cols_for_overflow(), but does Eigen check the product of rows*cols too?

If rows*cols happen to be large than 65536 x 65536, this will overflow size_t's max. limit of 2^32 for 32-bit systems.

Like in here:

Code: Select all
// CholmodSupport.h
  cholmod_dense res;
  res.nrow   = mat.rows();
  res.ncol   = mat.cols();
  res.nzmax  = res.nrow * res.ncol;      // size_t overflow??


Or here:
Code: Select all
    inline Index rows() const { return derived().rows(); }
    inline Index cols() const { return derived().cols(); }
    inline Index size() const { return rows() * cols(); }      // size_t overflow?


Which might explain why Eigen library is crashing on me when I try to solve a 100k x 100k system.
100k x 100k is not a valid number for a 32-bit application.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Eigen Matrix size overflow?

Sat Apr 12, 2014 8:19 pm
good catch! did you made a patch? thanks.
surle
Registered Member
Posts
7
Karma
0

Re: Eigen Matrix size overflow?

Sun Apr 13, 2014 4:17 am
Sorry, false alarm. It looks like check_rows_cols_for_overflow() checks for overflow for all kinds
of signed arithmetic, including multiplication. But, I don't understand why my code was allowed to
continue after creating such large sparse matrices. It should have asserted. It may be just a limited memory issue.


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], rblackwell