Re: [PATCH] c99 math func log2
On Sun, 2008-08-31 at 12:12 +0200, H.Heinold wrote: > Hi, > > I actual found a program that is using log2, so I would be glad > if this function would be integrated. The program is inside qt-embedded-4.4.1 > and compiling is failing with this line: > > qpf2.cpp:(.text+0x26d8): undefined reference to `log2' Just curious. What does this program do? -nc ___ uClibc mailing list uClibc@uclibc.org http://busybox.net/cgi-bin/mailman/listinfo/uclibc
Re: [PATCH] c99 math func log2
Hi, I actual found a program that is using log2, so I would be glad if this function would be integrated. The program is inside qt-embedded-4.4.1 and compiling is failing with this line: qpf2.cpp:(.text+0x26d8): undefined reference to `log2' I have attached a patch which should working against latest svn head. If the patch is okay I will open a bug report too. -- Bye Henning Index: uClibc/test/math/libm-test.inc === --- uClibc.orig/test/math/libm-test.inc 2008-07-25 11:03:24.0 +0200 +++ uClibc/test/math/libm-test.inc 2008-08-28 10:54:29.714525665 +0200 @@ -3414,7 +3414,6 @@ } -#if 0 static void log2_test (void) { @@ -3444,7 +3443,6 @@ END (log2); } -#endif static void @@ -4967,9 +4965,7 @@ log_test (); log10_test (); log1p_test (); -#if 0 log2_test (); -#endif logb_test (); modf_test (); ilogb_test (); Index: uClibc/libm/Makefile.in === --- uClibc.orig/libm/Makefile.in 2008-07-25 11:03:27.0 +0200 +++ uClibc/libm/Makefile.in 2008-08-28 10:54:29.714525665 +0200 @@ -62,7 +62,7 @@ libm_CSRC := \ e_acos.c e_acosh.c e_asin.c e_atan2.c e_atanh.c e_cosh.c \ e_exp.c e_fmod.c e_gamma.c e_gamma_r.c e_hypot.c e_j0.c \ - e_j1.c e_jn.c e_lgamma.c e_lgamma_r.c e_log.c e_log10.c \ + e_j1.c e_jn.c e_lgamma.c e_lgamma_r.c e_log.c e_log2.c e_log10.c \ e_pow.c e_remainder.c e_rem_pio2.c e_scalb.c e_sinh.c \ e_sqrt.c k_cos.c k_rem_pio2.c k_sin.c k_standard.c k_tan.c \ s_asinh.c s_atan.c s_cbrt.c s_ceil.c s_copysign.c s_cos.c \ @@ -73,7 +73,7 @@ s_tanh.c s_trunc.c w_acos.c w_acosh.c w_asin.c w_atan2.c w_atanh.c \ w_cabs.c w_cosh.c w_drem.c w_exp.c w_fmod.c w_gamma.c w_gamma_r.c \ w_hypot.c w_j0.c w_j1.c w_jn.c w_lgamma.c w_lgamma_r.c \ - w_log.c w_log10.c w_pow.c w_remainder.c w_scalb.c w_sinh.c \ + w_log.c w_log2.c w_log10.c w_pow.c w_remainder.c w_scalb.c w_sinh.c \ w_sqrt.c fpmacros.c nan.c carg.c s_llrint.c FL_MOBJ := \ acosf.o acoshf.o asinf.o asinhf.o atan2f.o atanf.o atanhf.o cbrtf.o \ @@ -89,10 +89,10 @@ libm_CSRC := \ w_acos.c w_asin.c s_atan.c w_atan2.c s_ceil.c s_cos.c \ w_cosh.c w_exp.c s_fabs.c s_floor.c w_fmod.c s_frexp.c \ - s_ldexp.c w_log.c w_log10.c s_modf.c w_pow.c s_sin.c \ + s_ldexp.c w_log.c w_log2.c w_log10.c s_modf.c w_pow.c s_sin.c \ w_sinh.c w_sqrt.c s_tan.c s_tanh.c \ s_expm1.c s_scalbn.c s_copysign.c e_acos.c e_asin.c e_atan2.c \ - k_cos.c e_cosh.c e_exp.c e_fmod.c e_log.c e_log10.c e_pow.c \ + k_cos.c e_cosh.c e_exp.c e_fmod.c e_log.c e_log2.c e_log10.c e_pow.c \ k_sin.c e_sinh.c e_sqrt.c k_tan.c e_rem_pio2.c k_rem_pio2.c \ s_finite.c # We'll add sqrtf to avoid problems with libstdc++ Index: uClibc/libm/w_log2.c === --- /dev/null 1970-01-01 00:00:00.0 + +++ uClibc/libm/w_log2.c 2008-08-28 10:58:48.676013259 +0200 @@ -0,0 +1,33 @@ +/* + * wrapper log2(X) + */ + +#include "math.h" +#include "math_private.h" + +libm_hidden_proto(log2) +#ifdef __STDC__ + double log2(double x) /* wrapper log */ +#else + double log2(x) /* wrapper log */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_log2 (x); +#else + double z; + z = __ieee754_log2 (x); + if (_LIB_VERSION == _IEEE_ || __isnan (x)) return z; + if (x <= 0.0) +{ + if (x == 0.0) + return __kernel_standard (x, x, 48); /* log2 (0) */ + else + return __kernel_standard (x, x, 49); /* log2 (x < 0) */ +} + else +return z; +#endif +} +libm_hidden_def(log2) Index: uClibc/libm/e_log2.c === --- /dev/null 1970-01-01 00:00:00.0 + +++ uClibc/libm/e_log2.c 2008-08-28 10:54:29.717859030 +0200 @@ -0,0 +1,130 @@ +/* Adapted for log2 by Ulrich Drepper <[EMAIL PROTECTED]>. */ +/* + * + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + */ + +/* __ieee754_log2(x) + * Return the logarithm to base 2 of x + * + * Method : + * 1. Argument Reduction: find k and f such that + * x = 2^k * (1+f), + * where sqrt(2)/2 < 1+f < sqrt(2) . + * + * 2. Approximation of log(1+f). + * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) + * = 2s + 2/3 s**3 + 2/5 s**5 + ., + * = 2s + s*R + * We use a special Reme algorithm on [0,0.1716] to generate + * a polynomial of degree 14 to approximate R The maximum error + * of this polynomial approximation is bounded by 2**-58.45. In + * other words, + * 2 4 6 8 10 12 14 + * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s + * (the
Re: [PATCH] c99 math func log2
On Sun, 2008-01-06 at 01:45 -0500, Mike Frysinger wrote: > On Wednesday 31 October 2007, Natanael Copa wrote: > > Here is a patch for the c99 math func log2(). If this gets applied I > > will look into the other c99 math funcs as well. > > is this function actually needed by something ? the current working policy > has been to merge C99 functions really only on demand ... > -mike No, its not needed by anything afaik. I dropped adding math funcs since it seems like the missing are (almost) never used. -nc ___ uClibc mailing list uClibc@uclibc.org http://busybox.net/cgi-bin/mailman/listinfo/uclibc
Re: [PATCH] c99 math func log2
On Wednesday 31 October 2007, Natanael Copa wrote: > Here is a patch for the c99 math func log2(). If this gets applied I > will look into the other c99 math funcs as well. is this function actually needed by something ? the current working policy has been to merge C99 functions really only on demand ... -mike signature.asc Description: This is a digitally signed message part. ___ uClibc mailing list uClibc@uclibc.org http://busybox.net/cgi-bin/mailman/listinfo/uclibc
Re: [PATCH] c99 math func log2
On Wednesday 07 November 2007, Bernhard Fischer wrote: > If we can subsummize some or individual funcs depending one a certain > standard, then all is well (see bsd-compat in e.g. network or others). > If they are non-standard but just serve as glibc-compat, then please > state so both in configury as in help-text and resubmit accordingly. for math functions, the groupings currently are: - all functions required by C99 - POSIX/IEEE 1003.1b-1993 functions i imagine we should add standard options: - float wrappers (what we have now -- all float funcs just call double funcs) - float versions (actually import the float variations) the only other piece would be a way to provide a custom list of desired math functions ... shouldnt be terribly hard for libm actually seeing as how most files are 1 func per file ... -mike signature.asc Description: This is a digitally signed message part. ___ uClibc mailing list uClibc@uclibc.org http://busybox.net/cgi-bin/mailman/listinfo/uclibc
Re: [PATCH] c99 math func log2
Bernhard Fischer wrote: > On Wed, Oct 31, 2007 at 02:32:48PM +0100, Carmelo AMOROSO wrote: > >> Natanael Copa wrote: >> >>> Hi, >>> >>> Here is a patch for the c99 math func log2(). If this gets applied I >>> will look into the other c99 math funcs as well. >>> >>> exp2 >>> fdim >>> fma >>> fmax >>> fmin >>> nearbyint >>> nexttoward >>> remquo >>> scalbln >>> tgamma >>> trunc >>> >>> I dont know how to use the test suite. Looks like test-double is just >>> disabled and I never managed to get the test suite to pass. I would be >>> thankful if someone could give me a hint. >>> >>> -nc >>> >>> >> Hi Natanael, >> I usually run the testsuite. I'll try to integrate your patch in my code >> and check the tests. >> I'll keep you informed. >> > > Any status update, Carmelo? > not yet... a bit busy in other stuff currently. Hope to be back in the next weeks. > It would be nice if any function would be exercised in the testsuite, > especially new ones. > may glibc testsuite already cover these? > Does it make sense to make some or all of the functions listed above > configurable (separately or on block)? Opinions? > Configurable is good... if the size increase it not so big, may be worth to add all in block. Cheers, Carmelo > > ___ uClibc mailing list uClibc@uclibc.org http://busybox.net/cgi-bin/mailman/listinfo/uclibc
Re: [PATCH] c99 math func log2
On Wed, 2007-11-07 at 19:56 +0100, Bernhard Fischer wrote: > On Wed, Oct 31, 2007 at 02:32:48PM +0100, Carmelo AMOROSO wrote: > >Natanael Copa wrote: > >> Hi, > >> > >> Here is a patch for the c99 math func log2(). If this gets applied I > >> will look into the other c99 math funcs as well. > >> > >> exp2 > >> fdim > >> fma > >> fmax > >> fmin > >> nearbyint > >> nexttoward > >> remquo > >> scalbln > >> tgamma > >> trunc > >> > >> I dont know how to use the test suite. Looks like test-double is just > >> disabled and I never managed to get the test suite to pass. I would be > >> thankful if someone could give me a hint. > >> > >> -nc > >> > >Hi Natanael, > >I usually run the testsuite. I'll try to integrate your patch in my code > >and check the tests. > >I'll keep you informed. > > Any status update, Carmelo? > > It would be nice if any function would be exercised in the testsuite, > especially new ones. > > Does it make sense to make some or all of the functions listed above > configurable (separately or on block)? Opinions? I noticed that there are not really any programs using log2. It would be nice if we could get sorted out which of the funcs that are really used and should be prioritized. -nc ___ uClibc mailing list uClibc@uclibc.org http://busybox.net/cgi-bin/mailman/listinfo/uclibc
Re: [PATCH] c99 math func log2
On Thu, Nov 08, 2007 at 12:01:56AM +0100, Natanael Copa wrote: > >On Wed, 2007-11-07 at 19:56 +0100, Bernhard Fischer wrote: >> On Wed, Oct 31, 2007 at 02:32:48PM +0100, Carmelo AMOROSO wrote: >> >Natanael Copa wrote: >> >> Hi, >> >> >> >> Here is a patch for the c99 math func log2(). If this gets applied I >> >> will look into the other c99 math funcs as well. >> >> >> >> exp2 >> >> fdim >> >> fma >> >> fmax >> >> fmin >> >> nearbyint >> >> nexttoward >> >> remquo >> >> scalbln >> >> tgamma >> >> trunc >> >> >> >> I dont know how to use the test suite. Looks like test-double is just >> >> disabled and I never managed to get the test suite to pass. I would be >> >> thankful if someone could give me a hint. >> >> >> >> -nc >> >> >> >Hi Natanael, >> >I usually run the testsuite. I'll try to integrate your patch in my code >> >and check the tests. >> >I'll keep you informed. >> >> Any status update, Carmelo? >> >> It would be nice if any function would be exercised in the testsuite, >> especially new ones. >> >> Does it make sense to make some or all of the functions listed above >> configurable (separately or on block)? Opinions? > >I noticed that there are not really any programs using log2. It would be >nice if we could get sorted out which of the funcs that are really used >and should be prioritized. If we can subsummize some or individual funcs depending one a certain standard, then all is well (see bsd-compat in e.g. network or others). If they are non-standard but just serve as glibc-compat, then please state so both in configury as in help-text and resubmit accordingly. TIA, > >-nc > ___ uClibc mailing list uClibc@uclibc.org http://busybox.net/cgi-bin/mailman/listinfo/uclibc
Re: [PATCH] c99 math func log2
On Wed, Oct 31, 2007 at 02:32:48PM +0100, Carmelo AMOROSO wrote: >Natanael Copa wrote: >> Hi, >> >> Here is a patch for the c99 math func log2(). If this gets applied I >> will look into the other c99 math funcs as well. >> >> exp2 >> fdim >> fma >> fmax >> fmin >> nearbyint >> nexttoward >> remquo >> scalbln >> tgamma >> trunc >> >> I dont know how to use the test suite. Looks like test-double is just >> disabled and I never managed to get the test suite to pass. I would be >> thankful if someone could give me a hint. >> >> -nc >> >Hi Natanael, >I usually run the testsuite. I'll try to integrate your patch in my code >and check the tests. >I'll keep you informed. Any status update, Carmelo? It would be nice if any function would be exercised in the testsuite, especially new ones. Does it make sense to make some or all of the functions listed above configurable (separately or on block)? Opinions? ___ uClibc mailing list uClibc@uclibc.org http://busybox.net/cgi-bin/mailman/listinfo/uclibc
Re: [PATCH] c99 math func log2
Natanael Copa wrote: > Hi, > > Here is a patch for the c99 math func log2(). If this gets applied I > will look into the other c99 math funcs as well. > > exp2 > fdim > fma > fmax > fmin > nearbyint > nexttoward > remquo > scalbln > tgamma > trunc > > I dont know how to use the test suite. Looks like test-double is just > disabled and I never managed to get the test suite to pass. I would be > thankful if someone could give me a hint. > > -nc > Hi Natanael, I usually run the testsuite. I'll try to integrate your patch in my code and check the tests. I'll keep you informed. Carmelo > > > ___ > uClibc mailing list > uClibc@uclibc.org > http://busybox.net/cgi-bin/mailman/listinfo/uclibc ___ uClibc mailing list uClibc@uclibc.org http://busybox.net/cgi-bin/mailman/listinfo/uclibc
[PATCH] c99 math func log2
Hi, Here is a patch for the c99 math func log2(). If this gets applied I will look into the other c99 math funcs as well. exp2 fdim fma fmax fmin nearbyint nexttoward remquo scalbln tgamma trunc I dont know how to use the test suite. Looks like test-double is just disabled and I never managed to get the test suite to pass. I would be thankful if someone could give me a hint. -nc Index: test/math/libm-test.inc === --- test/math/libm-test.inc (revision 20349) +++ test/math/libm-test.inc (working copy) @@ -3414,7 +3414,6 @@ } -#if 0 static void log2_test (void) { @@ -3444,7 +3443,6 @@ END (log2); } -#endif static void @@ -4967,9 +4965,7 @@ log_test (); log10_test (); log1p_test (); -#if 0 log2_test (); -#endif logb_test (); modf_test (); ilogb_test (); Index: libm/Makefile.in === --- libm/Makefile.in (revision 20349) +++ libm/Makefile.in (working copy) @@ -60,7 +60,7 @@ libm_CSRC := \ e_acos.c e_acosh.c e_asin.c e_atan2.c e_atanh.c e_cosh.c \ e_exp.c e_fmod.c e_gamma.c e_gamma_r.c e_hypot.c e_j0.c \ - e_j1.c e_jn.c e_lgamma.c e_lgamma_r.c e_log.c e_log10.c \ + e_j1.c e_jn.c e_lgamma.c e_lgamma_r.c e_log.c e_log2.c e_log10.c \ e_pow.c e_remainder.c e_rem_pio2.c e_scalb.c e_sinh.c \ e_sqrt.c k_cos.c k_rem_pio2.c k_sin.c k_standard.c k_tan.c \ s_asinh.c s_atan.c s_cbrt.c s_ceil.c s_copysign.c s_cos.c \ @@ -71,7 +71,7 @@ s_tanh.c w_acos.c w_acosh.c w_asin.c w_atan2.c w_atanh.c w_cabs.c \ w_cosh.c w_drem.c w_exp.c w_fmod.c w_gamma.c w_gamma_r.c \ w_hypot.c w_j0.c w_j1.c w_jn.c w_lgamma.c w_lgamma_r.c \ - w_log.c w_log10.c w_pow.c w_remainder.c w_scalb.c w_sinh.c \ + w_log.c w_log2.c w_log10.c w_pow.c w_remainder.c w_scalb.c w_sinh.c \ w_sqrt.c fpmacros.c nan.c carg.c s_llrint.c FL_MOBJ := \ acosf.o acoshf.o asinf.o asinhf.o atan2f.o atanf.o atanhf.o cbrtf.o \ @@ -87,10 +87,10 @@ libm_CSRC := \ w_acos.c w_asin.c s_atan.c w_atan2.c s_ceil.c s_cos.c \ w_cosh.c w_exp.c s_fabs.c s_floor.c w_fmod.c s_frexp.c \ - s_ldexp.c w_log.c w_log10.c s_modf.c w_pow.c s_sin.c \ + s_ldexp.c w_log.c w_log2.c w_log10.c s_modf.c w_pow.c s_sin.c \ w_sinh.c w_sqrt.c s_tan.c s_tanh.c \ s_expm1.c s_scalbn.c s_copysign.c e_acos.c e_asin.c e_atan2.c \ - k_cos.c e_cosh.c e_exp.c e_fmod.c e_log.c e_log10.c e_pow.c \ + k_cos.c e_cosh.c e_exp.c e_fmod.c e_log.c e_log2.c e_log10.c e_pow.c \ k_sin.c e_sinh.c e_sqrt.c k_tan.c e_rem_pio2.c k_rem_pio2.c \ s_finite.c # We'll add sqrtf to avoid problems with libstdc++ Index: libm/w_log2.c === --- libm/w_log2.c (revision 0) +++ libm/w_log2.c (revision 0) @@ -0,0 +1,32 @@ +/* + * wrapper log2(X) + */ + +#include "math.h" +#include "math_private.h" + +libm_hidden_proto(log2) +#ifdef __STDC__ + double log2(double x) /* wrapper log */ +#else + double log2(x) /* wrapper log */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_log2 (x); +#else + double z; + z = __ieee754_log2 (x); + if (_LIB_VERSION == _IEEE_ || __isnan (x)) return z; + if (x <= 0.0) +{ + if (x == 0.0) + return __kernel_standard (x, x, 48); /* log2 (0) */ + else + return __kernel_standard (x, x, 49); /* log2 (x < 0) */ +} + else +return z; +#endif +} Index: libm/e_log2.c === --- libm/e_log2.c (revision 0) +++ libm/e_log2.c (revision 0) @@ -0,0 +1,130 @@ +/* Adapted for log2 by Ulrich Drepper <[EMAIL PROTECTED]>. */ +/* + * + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + */ + +/* __ieee754_log2(x) + * Return the logarithm to base 2 of x + * + * Method : + * 1. Argument Reduction: find k and f such that + * x = 2^k * (1+f), + * where sqrt(2)/2 < 1+f < sqrt(2) . + * + * 2. Approximation of log(1+f). + * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) + * = 2s + 2/3 s**3 + 2/5 s**5 + ., + * = 2s + s*R + * We use a special Reme algorithm on [0,0.1716] to generate + * a polynomial of degree 14 to approximate R The maximum error + * of this polynomial approximation is bounded by 2**-58.45. In + * other words, + * 2 4 6 8 10 12 14 + * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s + * (the values of Lg1 to Lg7 are listed in the program) + * and + * | 2 14 | -58.45 + * | Lg1*s +...+Lg7*s- R(z) | <= 2 + * | | + * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2. + * In order to g