 Timestamp:
 Mar 22, 2006, 3:56:50 PM (15 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

libcaca/trunk/cucul/bitmap.c
r657 r660 184 184 register long double v, e; 185 185 #else 186 register float tmp, t, r;186 register float tmp, t, t2, r; 187 187 int i; 188 188 #endif … … 209 209 return v; 210 210 #else 211 /* Compute ln(x) as ln(1+t) where t = x  1, x ∈ ]0,1[ 212 * ln(1+t) = t  t^2/2 + t^3/3  t^4/4 + t^5/5 ... 213 * The convergence is quite slow, especially when x is near 0. */ 214 tmp = t = r = x  1.0; 215 for(i = 2; i < 30; i++) 216 { 217 r *= t; 211 /* Compute ln(x) for x ∈ ]0,1] 212 * ln(x) = 2 * (t + t^3/3 + t^5/5 + ...) with t = (x1)/(x+1) 213 * The convergence is a bit slow, especially when x is near 0. */ 214 t = (x  1.0) / (x + 1.0); 215 t2 = t * t; 216 tmp = r = t; 217 for(i = 3; i < 20; i += 2) 218 { 219 r *= t2; 218 220 tmp += r / i; 219 221 } 220 222 221 /* Compute x^y as e^t where t = y*ln(x): 223 /* Compute y*ln(x) */ 224 tmp =  y * 2.0 * tmp; 225 226 /* Compute x^y as e^t where t = y*ln(x): 222 227 * e^t = 1 + t/1! + t^2/2! + t^3/3! + t^4/4! + t^5/5! ... 223 * The convergence is a lotfaster here, thanks to the factorial. */224 r = t =  y *tmp;228 * The convergence is quite faster here, thanks to the factorial. */ 229 r = t = tmp; 225 230 tmp = 1.0 + t; 226 231 for(i = 2; i < 16; i++)
Note: See TracChangeset
for help on using the changeset viewer.