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: Ben Abbott
Subject: Re: Log2 and beta test failures
Date: Mon, 05 May 2008 12:33:26 -0700

On Monday, May 05, 2008, at 11:38AM, "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
>

I'm using gcc 4.3 as well with -O3 and see the same test failure that John sees 
with -O.

I don't see the others, which Michael encountered (later I'll try building with 
-O2 to see if the log2 feature goes away).

Regarding the log2 feature, I noticed log gives the expected result

octave:12> log(complex(0,inf))
ans = Inf + 1.571i

and that 

octave:13> log(complex(0,inf))/log(2)
ans = Inf - NaNi

gives a result consistent with log2. I assume that the "log(2)" is being 
treated as a complex number?

I'm not proficient in c/c++, but I suspect the log2 feature originates in 
lo-mappers.cc

Complex
xlog2 (const Complex& x)
{
#if defined (M_LN2)
  static double ln2 = M_LN2;
#else
  static double ln2 = log (2);
#endif

  return std::log (x) / ln2;
}

Might the return be modified to something like 

y = log(x);
return std:: complex(real(y)/ln2, imag(y)/ln2);

Ben


reply via email to

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