Boost logo

Ublas :

Subject: Re: [ublas] Problems with identity_matrix<> / lu_substitute()
From: Marco Guazzone (marco.guazzone_at_[hidden])
Date: 2009-10-09 03:06:05


On Thu, Oct 8, 2009 at 8:03 PM, <Pietro.Mele_at_[hidden]> wrote:
> I have a problem compiling this code when instead of a numerical constant I
> use a variable or a const int as a size parameter to
> B(identity_matrix<float>(size)).
> And even when it compiles using the numerical value, it runs only with
> values in the 1-4 range. A 5 will make it crash (Floating exception).
>
> Thank you for your help.
>
> Pietro
>
>
> #include ...
> using namespace boost::numeric::ublas;
>
> int main()
> {
>     int size = 4;
>
> //    matrix<float>  A(4, 4),
> B(identity_matrix<float>(4));                     // OK with 1, 2, 3, 4.
> Crash with 5, 6, ... (Floating exception)
>     matrix<float>  A(size, size),  B(identity_matrix<float>(size));
> // I will get a compile time error here ***, even if size is a const int

Try to use a vector instead of a matrix for B.

See the attached code for an example.
Compiled with GCC 4.4.1 + Boost 1.37:
  $ g++ -Wall -Wextra -ansi -pedantic -o pietro pietro.cpp

No warning from compiler output.

Cheers,

-- Marco