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

bad_alloc when transpose().eval() is called

Tags: None
(comma "," separated)
bjohnson
Registered Member
Posts
2
Karma
0
I am a bit of a newb at this so please bear with me. I am transposing and multiplying matrices that are 40k rows and 785 columns in size and I get a bad_alloc error. I don't think it is a problem with memory on my system since it gets up to 80% memory usage and that is it at its peak. I am using Visual Studio to debug and when the exception is thrown the call stack is
Code: Select all
delta1 = a1.transpose().eval()*d2;
where a1 is a 40k by 785 dense matrix and d2 is a 40k by 530 dense matrix. From there the call goes to DenseBase
Code: Select all
EIGEN_STRONG_INLINE EvalReturnType eval() const
    {
      // Even though MSVC does not honor strong inlining when the return type
      // is a dynamic matrix, we desperately need strong inlining for fixed
      // size types on MSVC.
      return typename internal::eval<Derived>::type(derived());
    }
and then from Memory.h
Code: Select all
inline void throw_std_bad_alloc()
{
  #ifdef EIGEN_EXCEPTIONS
    throw std::bad_alloc();


Can people help me or point me in the right direction?
Thank you for your time.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
I believe you're running out of memory.

btw, the eval is not needed here, and you can even save one more temporary with noalias:

delta1.noalias() = a1.transpose()*d2;
bjohnson
Registered Member
Posts
2
Karma
0
Thanks!


Bookmarks



Who is online

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