Strange behaviour of dnrm2

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Strange behaviour of dnrm2

Tommi Höynälänmaa-2

I'm using C++ and liboctave for programming. When I use
Matrix::lssolve for matrices given later in this message my C++
program gives false results even though command "mxa \ vb" works fine
in the Octave interpreter. The reason for the error is that BLAS
routine dnrm2 gives false results with standalone C++/liboctave
programs. When I wrote a straightforward new implementation of dnrm2
and used it in LAPACK routine dgelsd and related routines it uses
(dlarfg) the C++ program works fine.

Do you have any ideas what causes this odd behaviour of dnrm2?

Here are the data related to the problem:

Transpose of matrix mxa:
 3.78747328e-01 6.15598195e-01 -2.12642466e-01
 -6.31470042e-01 -4.58710267e-01 3.25932094e-01
 4.16414109e-01 8.57567983e-01 -2.30755742e-01
 -7.71191378e-01 -4.77492379e-01 3.73749213e-01
 3.08556589e-01 9.57954304e-01 -1.54454618e-01
 -6.44709339e-01 -3.93357908e-01 2.57604318e-01
 1.03613286e-01 6.82662608e-01 -1.32539061e-02
 -1.85413030e-01 -2.68019260e-01 -1.99123602e-04
 4.60539214e-02 2.42391026e-01 1.26683620e-02
 -4.07899449e-02 -1.10488243e-01 -1.30623915e-02

Vector vb:
 5.41261246e-01
 -2.39142126e-01
 3.32586634e-01

The incorrect result given by my own C++ code:
-5.8581
-0.58179
-0.47031
0.58659
0.255
-0.67744
1.1909
-1.9028
0.8787
-0.73683

The correct result from the Octave interpreter:
-1.25208
0.63698   
-1.40674
-0.14942
-0.70077
-2.07986
0.86212
-3.12159
1.08984
-1.11036

     - Tommi Höynälänmaa

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Strange behaviour of dnrm2

Mike Miller-4
On Mon, Dec 26, 2016 at 13:53:47 +0200, Tommi Höynälänmaa wrote:

> I'm using C++ and liboctave for programming. When I use
> Matrix::lssolve for matrices given later in this message my C++
> program gives false results even though command "mxa \ vb" works fine
> in the Octave interpreter. The reason for the error is that BLAS
> routine dnrm2 gives false results with standalone C++/liboctave
> programs. When I wrote a straightforward new implementation of dnrm2
> and used it in LAPACK routine dgelsd and related routines it uses
> (dlarfg) the C++ program works fine.
>
> Do you have any ideas what causes this odd behaviour of dnrm2?

I'm sure people would be happy to help, or at least try to reproduce, if
you could provide your C++ code sample to make it a bit easier.

--
mike

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Strange behaviour of dnrm2

Tommi Höynälänmaa-2


26.12.2016, 20:21, Mike Miller kirjoitti:

> On Mon, Dec 26, 2016 at 13:53:47 +0200, Tommi Höynälänmaa wrote:
>> I'm using C++ and liboctave for programming. When I use
>> Matrix::lssolve for matrices given later in this message my C++
>> program gives false results even though command "mxa \ vb" works fine
>> in the Octave interpreter. The reason for the error is that BLAS
>> routine dnrm2 gives false results with standalone C++/liboctave
>> programs. When I wrote a straightforward new implementation of dnrm2
>> and used it in LAPACK routine dgelsd and related routines it uses
>> (dlarfg) the C++ program works fine.
>>
>> Do you have any ideas what causes this odd behaviour of dnrm2?
>
> I'm sure people would be happy to help, or at least try to reproduce, if
> you could provide your C++ code sample to make it a bit easier.
>

The reason for the bug was a static library containing an erroneous
redefinition of function dnrm2.

      - Tommi H.

Loading...