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

64 bit integers

Tags: None
(comma "," separated)
renorm
Registered Member
Posts
31
Karma
0

64 bit integers

Sun Jun 13, 2010 6:39 pm
Does Eigen support 64 bit integer? I want to use fixed vectors of 64 bit integers to implement fast dot product, but this code doesn't compile. Any thought?

Code: Select all
#include <Eigen/Core>
typedef unsigned long long  UInt64;

int main() {
    Eigen::Matrix<UInt64, 1, 4> a, b;
    a << 1, 2, 3, 4;
    b << 4, 6, 7, 8;
    UInt64 result = a.dot(b);
}
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: 64 bit integers

Sun Jun 13, 2010 7:19 pm
Yes. I recommend using the devel branch for that, it sure works, while I don't remember if that was officially supported in 2.0.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
renorm
Registered Member
Posts
31
Karma
0

Re: 64 bit integers

Sun Jun 20, 2010 12:18 pm
Thanks for the answer. I have another question.
What is the construction/destruction cost of the matrix class? How does it compared to std::vector with the same number of elements. My code needs to create very large number of small matrices and vectors, fill them with data and perform basic linear algebra with them. I can either use std::vector, boost::array or some handcrafted structure and implements basic linear algebra myself or use Eigen's fixed size matrix class. Does alignment requirement increase the contraction cost? In my case memory is not an issue, because objects don't accumulate. Also, does matrix class perform range checking? I prefer it doesn't, because it would slow down my code considerably.
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: 64 bit integers

Sun Jun 20, 2010 2:41 pm
Since you are specifying sizes at compile-time (1x4 in your example), the construction/destruction cost is exactly zero. The alignment doesn't have any runtime cost: it is just a requirement that we pass to the compiler using __attribute__ or __declspec depending on your compiler. If you were using dynamic-size matrices (e.g. Matrix<T,Dynamic,...>) then of course the constructor/destructor would allocate/deallocate the array on the heap.

Yes, Eigen does perform range checking on every operation, using assert(). If you want to disable that, just define NDEBUG (disable assert globally) or EIGEN_NO_DEBUG (disable only Eigen asserts) before including Eigen headers.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
renorm
Registered Member
Posts
31
Karma
0

Re: 64 bit integers

Mon Jun 21, 2010 2:52 am
Thanks. That was very helpful.


Bookmarks



Who is online

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