octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Log2 and beta test failures


From: Jaroslav Hajek
Subject: Re: Log2 and beta test failures
Date: Tue, 6 May 2008 08:35:38 +0200

On Mon, May 5, 2008 at 5:26 PM, John W. Eaton <address@hidden> wrote:
>
> On  5-May-2008, Michael Goffioul wrote:
>
>  | I just recompiled development branch of octave (hg source pulled
>  | a few hours ago) and I notice the following test failures, related
>  | to log2 and beta:
>  |
>  |   ***** test
>  |  [f, e] = log2 ([0,-1; 2,-4; Inf,-Inf]);
>  |  assert (f, [0,-0.5; 0.5,-0.5; Inf,-Inf]);
>  |  assert (e, [0,1;2,3;0,0])
>  | !!!!! test failed
>  | error: assert (f,[0, -0.5; 0.5, -0.5; Inf, -Inf]) expected
>  |    0.00000  -0.50000
>  |    0.50000  -0.50000
>  |        Inf      -Inf
>  | but got
>  |    0.00000  -0.50000
>  |    0.50000  -0.50000
>  |        NaN       NaN
>  | NaNs don't match
>  |
>  |
>  |   ***** test
>  |  [f, e] = log2 (complex (zeros (3, 2), [0,-1; 2,-4; Inf,-Inf]));
>  |  assert (f, complex (zeros (3, 2), [0,-0.5; 0.5,-0.5; Inf,-Inf]));
>  |  assert (e, [0,1; 2,3; 0,0]);
>  | !!!!! test failed
>  | error: assert (f,complex (zeros (3, 2), [0, -0.5; 0.5, -0.5; Inf,
>  | -Inf])) expected
>  |    0.00000 + 0.00000i   0.00000 - 0.50000i
>  |    0.00000 + 0.50000i   0.00000 - 0.50000i
>  |    0.00000 +     Infi   0.00000 -     Infi
>  | but got
>  |    0.00000 + 0.00000i   0.00000 - 0.50000i
>  |    0.00000 + 0.50000i   0.00000 - 0.50000i
>  |        NaN -     NaNi       NaN -     NaNi
>  | NaNs don't match
>  |
>  |
>  |   ***** test
>  |  [v, i] = sort ([NaN, 1i, -1, Inf, 1, 1i]);
>  |  assert (v, [1, 1i, 1i, -1, Inf, NaN])
>  |  assert (i, [5, 2, 6, 3, 4, 1])
>  | !!!!! test failed
>  | error: assert (i,[5, 2, 6, 3, 4, 1]) expected
>  |    5   2   6   3   4   1
>  | but got
>  |    5   6   2   3   4   1
>  | values do not match
>  | shared variables {
>  |   m2 =
>  |
>  |      1   2
>  |      3   4
>  |
>  |   flo =  1.0000e-300
>  |   fhi =  1.0000e+300
>  | }
>  |
>  |   ***** test
>  |  a = 0.25 + (0:5) * 0.5;
>  |  tol = 10 * max (a) * eps;
>  |  assert (zeros (size (a)), beta (a, -a), tol)
>  |  assert (zeros (size (a)), beta (-a, a), tol)
>  | !!!!! test failed
>  | error: exception encountered in Fortran subroutine dlgams_
>  |
>  | Related to the beta function failure, I observe this, when I run the
>  | test in octave:
>  |
>  | octave.exe:3>  a = 0.25 + (0:5) * 0.5;
>  | octave.exe:4>  tol = 10 * max (a) * eps;
>  | octave.exe:5>  assert (zeros (size (a)), beta (a, -a), tol)
>  |  ***MESSAGE FROM ROUTINE DGAMMA IN LIBRARY SLATEC.
>  |  ***FATAL ERROR, PROG ABORTED, TRACEBACK REQUESTED
>  |  *  X IS 0
>  |  *  ERROR NUMBER = 4
>  |  *
>  |  ***END OF MESSAGE
>  |
>  |  ***JOB ABORT DUE TO FATAL ERROR.
>  | 0          ERROR MESSAGE SUMMARY
>  |  LIBRARY    SUBROUTINE MESSAGE START             NERR     LEVEL     COUNT
>  |  SLATEC     DGAMMA     X IS 0                       4         2         1
>  |
>  | error: exception encountered in Fortran subroutine dlgams_
>  | error: caught execution error in library function
>  | error: evaluating binary operator `-' near line 59, column 49
>  | error: evaluating argument list element number 1
>  | error: evaluating argument list element number 1
>  | error: evaluating assignment expression near line 59, column 10
>  | error: called from `beta' in file
>  | `D:\Software\VCLibs\local\share\octave\3.0.0+\m\specfun\beta.m'
>  |
>  | Michael.
>  |
>  | error: evaluating argument list element number 2
>
>  With GCC 4.2.3 I notice the following failure, but only if I compile
>  without -O:
>
>      ***** assert(log2(complex(0,Inf)), Inf + log2(i));
>   !!!!! test failed
>   error: assert (log2 (complex (0, Inf)),Inf + log2 (i)) expected
>   Inf + 2.266i
>   but got
>   Inf - NaNi
>   NaNs don't match
>
>  With the default options (-g -O2) the test succeeds.  I don't have a
>  solution for this problem, and I can't easily debug the problem with
>  the Windows build.
>
>  jwe
>

can this be a bug in GCC?
I've just tried this test program:
#include <iostream>
#include <complex>
#include <math.h>

typedef std::complex<double> Complex;

int main()
{
  double inf = 1./0., nan = -0./0.;
  Complex a(0,inf);
  std::cout << a / 3.0 << '\n';
}

with g++ 4.2.1.
Compiled without any options, I get
(nan,inf)

Compiled with -O2, I get
(0,inf)

which seems bad. It seems that in the former case the operator /
(std::complex<double>, double) is not used. OTOH, given the C99
pseudo-standard for complex numbers, I think that both results are
complex infinities, so perhaps both are acceptable (?). Any thoughts?

Intel C++ 10.0 gives consistently (0,inf) regardless of optimization level.

I don't have other g++ versions or compilers to try. Ben, Michael, can
you try this fragment with your configurations? I don't see any
obvious bug in the xlog2 mappers, so I guess this may be the cause.

If this is the case, I think we can temporarily disable the Inf and
NaN tests, and I'll visit GCC bugzilla for this.

cheers,

-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]