[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: log2 replacement
From: |
Jaroslav Hajek |
Subject: |
Re: log2 replacement |
Date: |
Tue, 29 Apr 2008 21:10:00 +0200 |
On Tue, Apr 29, 2008 at 8:40 PM, Jaroslav Hajek <address@hidden> wrote:
>
> On Tue, Apr 29, 2008 at 8:19 PM, John W. Eaton <address@hidden> wrote:
> > On 25-Apr-2008, Jaroslav Hajek wrote:
> >
> > | hello,
> > |
> > | please consider the attached changeset.
> > | The current log2 behaviour with two outputs (`[f, e] = log2(x)') is
> > | inconsistent with Matlab in a number of cases, (x = Inf, x = NaN) or
> > | just plain wrong (x = realmax). Also, on most of the systems the
> > | 2-output version can be mapped directly to frexp (a C89 function),
> > | which is probably what Matlab also does. I have implemented the
> > | single-output log2 as a mapper for octave_value (aka log, log10 etc),
> > | and the two-output version as an overload in liboctave/lo-mappers.cc
> > | with a replacement if frexp is not detected. The DEFUN is in
> > | DLD-FUNCTIONS rather than mappers.cc directly, because it is not a
> > | simple mapper and thus did not seem to fit "aesthetically" to
> > | mappers.cc (but that can be easily changed).
> > |
> > | Note that the 2-output version is also extended beyond matlab
> > | behaviour for complex input - while matlab ignores the imaginary part
> > | (with a warning), this new version gives the result with f complex,
> > | satisfying 1/2 <= abs(f) < 1, e integer - because it makes good sense
> > | also for complex numbers.
> >
> > With this patch, I see the following error with make check:
> >
> > src/DLD-FUNCTIONS/hex2num.cc ........................... PASS 2/2
> > src/DLD-FUNCTIONS/log2.cc .............................. PASS 0/2
> FAIL 2
> > src/DLD-FUNCTIONS/lookup.cc ............................ PASS 16/16
> > src/DLD-FUNCTIONS/lsode.cc ............................. PASS 5/5
> > src/DLD-FUNCTIONS/luinc.cc ............................. PASS 2/2
> > src/DLD-FUNCTIONS/matrix_type.cc ....................... PASS 51/51
> > src/DLD-FUNCTIONS/max.cc ............................... PASS 12/12
> > src/DLD-FUNCTIONS/qr.cc ................................ PASS 21/21
> > src/DLD-FUNCTIONS/quad.cc .............................. PASS 6/6
> > src/DLD-FUNCTIONS/rand.cc .............................. PASS 57/57
> > src/DLD-FUNCTIONS/regexp.cc ............................ PASS 81/81
> > src/DLD-FUNCTIONS/time.cc .............................. PASS 13/13
> > src/DLD-FUNCTIONS/tsearch.cc ........................... PASS 6/6
> > src/data.cc ............................................ PASS 98/98
> > src/mappers.cc ......................................... PASS 7/7
> > src/ov-fcn-handle.cc ...................................panic:
> Segmentation fault -- stopping myself...
> > make[2]: *** [check] Segmentation fault
> > make[2]: Leaving directory `/scratch/jwe/build/octave-tmp/test'
> > make[1]: *** [check] Error 2
> > make[1]: Leaving directory `/scratch/jwe/build/octave-tmp'
> > make: *** [check] Error 2
> >
> > Does it work properly for you?
> >
> > jwe
> >
>
> Umm, I think it did. I'll check again against the newest sources.
>
>
>
> --
> RNDr. Jaroslav Hajek
> computing expert
> Aeronautical Research and Test Institute (VZLU)
> Prague, Czech Republic
> url: www.highegg.matfyz.cz
>
OK, now I get the failure as well. Further I discovered a typo
(triggered only when HAVE_FREXP is undefined). I'll investigate this
and resubmit eventually.
regards,
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz