lsdavies
lsdavies

Reputation: 327

Armadillo Matrix Dimensions Initialisation Incorrect

Briefly, I try to init a matrix as follows:

struct MyClass {
  arma::mat _mymat;
};

MyClass::MyClass() : 
_mymat(0,0)
{
}

but in the VS2010 debugger, the properties are

{n_rows=0 n_cols=14829735428352901220 n_elem=7925840 ... }

Later I try to set the dimensions again to 3x3, but then the properties change to

{n_rows=3435973836 n_cols=3435973836 n_elem=3435973836 ... }

and when I use MyClass._mymat in multiplication the program throws an exception at runtime complaining that the matrix dimensions are not equal.

The platform is VS2010, 64-bit with armadillo 4.200

I have also tried this with previous versions of Armadillo to the same effect.

This error does not occur under Win32 32-bit.

Upvotes: 0

Views: 189

Answers (1)

lsdavies
lsdavies

Reputation: 327

I found the answer.

TL;DR: ARMA_64BIT_WORD was not defined for the source file I was using, but it was defined for other object files, thus creating an unstable mix of 32-bit and 64-bit word sizes in the Armadillo library.

The simple fix was to add ARMA_64BIT_WORD as a preprocessor macro in the configuration properties for the project.

Upvotes: 1

Related Questions