 Timestamp:
 Sep 2, 2011, 2:06:21 AM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/trig.cpp
r885 r888 37 37 static const double VERY_SMALL_NUMBER = 0x1.0p128; 38 38 static const double VERY_LARGE_NUMBER = 4503599627370496.0; 39 static const double EVEN_LARGER_NUMBER = 9007199254740992.0; 39 40 40 41 /** sin Taylor series coefficients. */ … … 127 128 return r; 128 129 #else 129 if (c >= 0) return gte; returnlt;130 return (c >= 0) ? gte : lt; 130 131 #endif 131 132 } … … 166 167 { 167 168 double absx = lol_fabs(x); 169 double sign = lol_fsel(x, ONE, NEG_ONE); 168 170 #if defined __CELLOS_LV2__ 169 171 double num_cycles = lol_round(absx * INV_PI); 170 172 double is_even = lol_trunc(num_cycles * HALF)  (num_cycles * HALF); 171 173 #else 172 double num_cycles = absx * INV_PI; 173 num_cycles += VERY_LARGE_NUMBER; 174 double num_cycles = absx * INV_PI + VERY_LARGE_NUMBER; 174 175 __asm__("" : "+m" (num_cycles)); 175 176 num_cycles = VERY_LARGE_NUMBER; 176 double is_even = num_cycles * HALF  HALF; 177 is_even += VERY_LARGE_NUMBER;177 178 double is_even = num_cycles  HALF; 178 179 __asm__("" : "+m" (is_even)); 179 is_even = VERY_LARGE_NUMBER; 180 is_even = num_cycles * HALF; 180 is_even += EVEN_LARGER_NUMBER; 181 __asm__("" : "+m" (is_even)); 182 is_even = EVEN_LARGER_NUMBER; 183 __asm__("" : "+m" (is_even)); 184 is_even = num_cycles; 181 185 #endif 182 186 double norm_x = absx  PI * num_cycles; … … 186 190 * y + SC[2]) * y + SC[1]) 187 191 * y + SC[0]) * y); 188 double sign = lol_fsel(is_even * x, ONE, NEG_ONE);192 sign = lol_fsel(is_even, sign, sign); 189 193 double result = norm_x + norm_x * taylor; 190 194 return result * sign;
Note: See TracChangeset
for help on using the changeset viewer.