|
From: | Rik |
Subject: | [Octave-bug-tracker] [bug #42583] log2() returns inaccurate result for many integer powers of 2, unlike Matlab |
Date: | Thu, 19 Jun 2014 15:24:26 +0000 |
User-agent: | Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0 |
Follow-up Comment #5, bug #42583 (project octave): This is likely to be a problem with 1) cross-compiling, 2) the availibility of a log2 function in the C library, or 3) Cygwin's implementation of log2. For efficiency, Octave tries to map log2 to the local C library function which is usually a better choice than trying to calculate it ourselves. The code is in liboctave/numeric/lo-mappers.cc. double xlog2 (double x) { #if defined (HAVE_LOG2) return log2 (x); #else #if defined (M_LN2) static double ln2 = M_LN2; #else static double ln2 = log (2); #endif return log (x) / ln2; #endif } If I check my config.h file I see that HAVE_LOG2 is defined to 1 so glibc has the log2 function. How did you get Octave for cygwin? Is this a native build or a cross-compiled build? If it is a cross-compiled build using the MXE framework then it may be that the tools could not determine whether the end system would have log2 in libc and so undefined HAVE_LOG2. Another possibility is that the log2 function on cygwin is just broken. The gnulib project has replacement functions for ones that are known to have compatibility problems between platforms. If I look at log2 (https://www.gnu.org/software/gnulib/manual/html_node/log2.html) I see that Cygwin is listed. This function returns slightly wrong values for exact powers of 2 on some platforms: Cygwin 1.7.9. _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?42583> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/
[Prev in Thread] | Current Thread | [Next in Thread] |