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

Big Matrix Index problem

Tags: None
(comma "," separated)
ymorinrivest
Registered Member
Posts
6
Karma
0

Big Matrix Index problem

Tue Oct 16, 2012 3:46 am
Hey guys,

I have a big matrix that is not sparse, has 3 column and a lot of rows ( a lot = >> max(int)). Looking at the doc and reading around, i decided to change my index type to unsigned int ( to go from a max of 2,147,483,647 to a max of 4,294,967,295) :

Code: Select all
#define EIGEN_DEFAULT_DENSE_INDEX_TYPE unsigned int


That worked fine because in the _init2 functino of PlainObjectBase, i previously had negative row ( because of the int overflow) and with the change, i have the good number.

The only problem now is with the function internal::check_rows_cols_for_overflow, it computes a max number of row assuming that the type is signed, so the change of index type doesn't change anything for this function.

Code: Select all
  Index max_index = (size_t(1) << (8 * sizeof(Index) - 1)) - 1; // assume Index is signed
  bool error = (rows < 0  || cols < 0)  ? true
             : (rows == 0 || cols == 0) ? false
                                        : (rows > max_index / cols);


Is this a normal behaviour, or it's something I didn't understand (Why would an index be signed anyway ??)

I'll try using a map object to a pointer for now, but i am curious to see what you think about it.

Cheers
manuels
Registered Member
Posts
47
Karma
0

Re: Big Matrix Index problem

Tue Oct 16, 2012 9:56 am
I guess there should be something like
Code: Select all
Index max_index = std::numeric_limits<Index>::max();
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Big Matrix Index problem

Tue Oct 16, 2012 6:37 pm
The index type is indeed assumed to be signed, I'm not sure everything will work if that's not the case, even if we use std::numeric_limits<Index>::max() here. The rational is that loosing 1 bit is not a big deal because if someone need sizes larger than 2^31, then better moving to long int. By default, we use std::ptrdiff_t. Since you are having troubles I guess you are running on a 32 bit system ?
ymorinrivest
Registered Member
Posts
6
Karma
0

Re: Big Matrix Index problem

Wed Oct 17, 2012 12:06 am
I am on a 64 bits machine, but our software is still only in 32 bits


Bookmarks



Who is online

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