this repo has no description
at fixPythonPipStalling 53 lines 1.3 kB view raw
1/* 2 * by Ian Ollmann 3 * 4 * based on fdlibm cosh by Sun Microsystems, with improvements for efficiency and proper flag setting on i386. 5 * 6 * Copyright (C) 2005 by Apple Computer, Inc. All rights reserved. 7 */ 8 9 10 11#include "math.h" 12#include "math_private.h" 13 14long double coshl( long double x ) 15{ 16 static const long double overflow = 0x1.62e9bb80635d81d4p+13L; //ln(LDBL_MAX) + ln(2.0) 17 static const long double ln2 = 0.693147180559945309417232121458176568L; //ln(2) 18 long double fabsx = __builtin_fabsl( x ); 19 long double t, w; 20 21 if( x != x ) return x + x; 22 23 if( fabsx < __builtin_infl() ) 24 { 25 if( fabsx < 0.5L * ln2 ) 26 { 27 if( fabsx > 0x1.0p-1000L ) //avoid underflow, save time 28 fabsx = expm1l( fabsx ); 29 w = 1.0L + fabsx; 30 if( fabsx < 0x1.0p-67L ) 31 return w; 32 return 1.0L + (fabsx*fabsx)/(w+w); 33 } 34 35 if( fabsx < 22.L ) 36 { 37 t = expl( fabsx ); 38 return 0.5L * t + 0.5L/t; 39 } 40 41 if( fabsx < overflow ) 42 { 43 w = expl( 0.5L * fabsx ); 44 t = 0.5L * w; 45 return t * w; 46 } 47 48 return fabsx * 0x1.0p16383L; 49 } 50 51 //Nan or Inf result 52 return fabsx + fabsx; 53}