Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #62 from visualfc/snprintf
Browse files Browse the repository at this point in the history
test snprintf fmaf
  • Loading branch information
xushiwei authored Oct 31, 2022
2 parents d929ec7 + 6e5a6ce commit 24ef5dd
Show file tree
Hide file tree
Showing 182 changed files with 763 additions and 757 deletions.
6 changes: 3 additions & 3 deletions acos.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func _cgos_R_acos(z float64) float64 {
var p float64
var q float64
p = z * (_cgos_pS0_acos + z*(_cgos_pS1_acos+z*(_cgos_pS2_acos+z*(_cgos_pS3_acos+z*(_cgos_pS4_acos+z*_cgos_pS5_acos)))))
q = 1 + z*(_cgos_qS1_acos+z*(_cgos_qS2_acos+z*(_cgos_qS3_acos+z*_cgos_qS4_acos)))
q = 1.0 + z*(_cgos_qS1_acos+z*(_cgos_qS2_acos+z*(_cgos_qS3_acos+z*_cgos_qS4_acos)))
return p / q
}
func Acos(x float64) float64 {
Expand Down Expand Up @@ -60,12 +60,12 @@ func Acos(x float64) float64 {
return _cgos_pio2_hi_acos - (x - (_cgos_pio2_lo_acos - x*_cgos_R_acos(x*x)))
}
if hx>>int32(31) != 0 {
z = (1 + x) * 0.5
z = (1.0 + x) * 0.5
s = Sqrt(z)
w = _cgos_R_acos(z)*s - _cgos_pio2_lo_acos
return float64(int32(2)) * (_cgos_pio2_hi_acos - (s + w))
}
z = (1 - x) * 0.5
z = (1.0 - x) * 0.5
s = Sqrt(z)
df = s
for {
Expand Down
2 changes: 1 addition & 1 deletion acosf.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func _cgos_R_acosf(z float32) float32 {
var p float32
var q float32
p = z * (_cgos_pS0_acosf + z*(_cgos_pS1_acosf+z*_cgos_pS2_acosf))
q = 1 + z*_cgos_qS1_acosf
q = 1.0 + z*_cgos_qS1_acosf
return p / q
}
func Acosf(x float32) float32 {
Expand Down
2 changes: 1 addition & 1 deletion asin.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func _cgos_R_asin(z float64) float64 {
var p float64
var q float64
p = z * (_cgos_pS0_asin + z*(_cgos_pS1_asin+z*(_cgos_pS2_asin+z*(_cgos_pS3_asin+z*(_cgos_pS4_asin+z*_cgos_pS5_asin)))))
q = 1 + z*(_cgos_qS1_asin+z*(_cgos_qS2_asin+z*(_cgos_qS3_asin+z*_cgos_qS4_asin)))
q = 1.0 + z*(_cgos_qS1_asin+z*(_cgos_qS2_asin+z*(_cgos_qS3_asin+z*_cgos_qS4_asin)))
return p / q
}
func Asin(x float64) float64 {
Expand Down
2 changes: 1 addition & 1 deletion asinf.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func _cgos_R_asinf(z float32) float32 {
var p float32
var q float32
p = z * (_cgos_pS0_asinf + z*(_cgos_pS1_asinf+z*_cgos_pS2_asinf))
q = 1 + z*_cgos_qS1_asinf
q = 1.0 + z*_cgos_qS1_asinf
return p / q
}
func Asinf(x float32) float32 {
Expand Down
8 changes: 4 additions & 4 deletions atan.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ func Atan(x float64) float64 {
if ix < uint32(1072889856) {
if ix < uint32(1072037888) {
id = int32(0)
x = (2*x - 1) / (2 + x)
x = (2.0*x - 1.0) / (2.0 + x)
} else {
id = int32(1)
x = (x - 1) / (x + 1)
x = (x - 1.0) / (x + 1.0)
}
} else if ix < uint32(1073971200) {
id = int32(2)
x = (x - 1.5) / (1 + 1.5*x)
x = (x - 1.5) / (1.0 + 1.5*x)
} else {
id = int32(3)
x = -1 / x
x = -1.0 / x
}
}
z = x * x
Expand Down
4 changes: 2 additions & 2 deletions atan2.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ func Atan2(y float64, x float64) float64 {
} else {
switch m {
case uint32(0):
return float64(0)
return float64(0.0)
case uint32(1):
return float64(-0)
return float64(-0.0)
case uint32(2):
return _cgos_pi_atan2
case uint32(3):
Expand Down
6 changes: 3 additions & 3 deletions atan2f.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ func Atan2f(y float32, x float32) float32 {
} else {
switch m {
case uint32(0):
return float32(0)
return float32(0.0)
case uint32(1):
return float32(-0)
return float32(-0.0)
case uint32(2):
return _cgos_pi_atan2f
case uint32(3):
Expand All @@ -147,7 +147,7 @@ func Atan2f(y float32, x float32) float32 {
}()
}
if m&uint32(2) != 0 && iy+uint32(218103808) < ix {
z = float32(0)
z = float32(0.0)
} else {
z = Atanf(Fabsf(y / x))
}
Expand Down
8 changes: 4 additions & 4 deletions atanf.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ func Atanf(x float32) float32 {
if ix < uint32(1066926080) {
if ix < uint32(1060110336) {
id = int32(0)
x = (2*x - 1) / (2 + x)
x = (2.0*x - 1.0) / (2.0 + x)
} else {
id = int32(1)
x = (x - 1) / (x + 1)
x = (x - 1.0) / (x + 1.0)
}
} else if ix < uint32(1075576832) {
id = int32(2)
x = (x - 1.5) / (1 + 1.5*x)
x = (x - 1.5) / (1.0 + 1.5*x)
} else {
id = int32(3)
x = -1 / x
x = -1.0 / x
}
}
z = x * x
Expand Down
2 changes: 1 addition & 1 deletion cbrt.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func Cbrt(x float64) float64 {
return x + x
}
if hx < uint32(1048576) {
u.f = x * 18014398509481984
u.f = x * 18014398509481984.0
hx = uint32(*(*uint64)(unsafe.Pointer(&u)) >> int32(32) & uint64(2147483647))
if hx == uint32(0) {
return x
Expand Down
2 changes: 1 addition & 1 deletion cbrtf.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func Cbrtf(x float32) float32 {
if hx == uint32(0) {
return x
}
u.f = x * 16777216
u.f = x * 16777216.0
hx = *(*uint32)(unsafe.Pointer(&u)) & uint32(2147483647)
hx = hx/uint32(3) + _cgos_B2_cbrtf
} else {
Expand Down
2 changes: 1 addition & 1 deletion ceil.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func Ceil(x float64) float64 {
}
return func() float64 {
if *(*uint64)(unsafe.Pointer(&u))>>int32(63) != 0 {
return -0
return -0.0
} else {
return float64(int32(1))
}
Expand Down
4 changes: 2 additions & 2 deletions ceilf.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ func Ceilf(x float32) float32 {
}
}
if *(*uint32)(unsafe.Pointer(&u))>>int32(31) != 0 {
u.f = float32(-0)
u.f = float32(-0.0)
} else if *(*uint32)(unsafe.Pointer(&u))<<int32(1) != 0 {
u.f = float32(1)
u.f = float32(1.0)
}
}
return u.f
Expand Down
2 changes: 1 addition & 1 deletion cos.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func Cos(x float64) float64 {
break
}
}
return float64(1)
return float64(1.0)
}
return __cos(x, float64(int32(0)))
}
Expand Down
2 changes: 1 addition & 1 deletion cosf.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Cosf(x float32) float32 {
break
}
}
return float32(1)
return float32(1.0)
}
return __cosdf(float64(x))
}
Expand Down
2 changes: 1 addition & 1 deletion cosh.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ func Cosh(x float64) float64 {
t = Exp(x)
return 0.5 * (t + float64(int32(1))/t)
}
t = __expo2(x, 1)
t = __expo2(x, 1.0)
return t
}
2 changes: 1 addition & 1 deletion coshf.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ func Coshf(x float32) float32 {
t = Expf(x)
return 0.5 * (t + float32(int32(1))/t)
}
t = __expo2f(x, 1)
t = __expo2f(x, 1.0)
return t
}
2 changes: 1 addition & 1 deletion drand48.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func Erand48(s *uint16) float64 {
}
var x _cgoa_19_drand48
x.u = uint64(4607182418800017408) | __rand48_step(s, (*uint16)(unsafe.Pointer(uintptr(unsafe.Pointer((*uint16)(unsafe.Pointer(&__seed48))))+uintptr(int32(3))*2)))<<int32(4)
return *(*float64)(unsafe.Pointer(&x)) - 1
return *(*float64)(unsafe.Pointer(&x)) - 1.0
}
func Drand48() float64 {
return Erand48((*uint16)(unsafe.Pointer(&__seed48)))
Expand Down
12 changes: 6 additions & 6 deletions erf.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ func _cgos_erfc2_erf(ix uint32, x float64) float64 {
s = float64(int32(1)) / (x * x)
if ix < uint32(1074191213) {
R = _cgos_ra0_erf + s*(_cgos_ra1_erf+s*(_cgos_ra2_erf+s*(_cgos_ra3_erf+s*(_cgos_ra4_erf+s*(_cgos_ra5_erf+s*(_cgos_ra6_erf+s*_cgos_ra7_erf))))))
S = 1 + s*(_cgos_sa1_erf+s*(_cgos_sa2_erf+s*(_cgos_sa3_erf+s*(_cgos_sa4_erf+s*(_cgos_sa5_erf+s*(_cgos_sa6_erf+s*(_cgos_sa7_erf+s*_cgos_sa8_erf)))))))
S = 1.0 + s*(_cgos_sa1_erf+s*(_cgos_sa2_erf+s*(_cgos_sa3_erf+s*(_cgos_sa4_erf+s*(_cgos_sa5_erf+s*(_cgos_sa6_erf+s*(_cgos_sa7_erf+s*_cgos_sa8_erf)))))))
} else {
R = _cgos_rb0_erf + s*(_cgos_rb1_erf+s*(_cgos_rb2_erf+s*(_cgos_rb3_erf+s*(_cgos_rb4_erf+s*(_cgos_rb5_erf+s*_cgos_rb6_erf)))))
S = 1 + s*(_cgos_sb1_erf+s*(_cgos_sb2_erf+s*(_cgos_sb3_erf+s*(_cgos_sb4_erf+s*(_cgos_sb5_erf+s*(_cgos_sb6_erf+s*_cgos_sb7_erf))))))
S = 1.0 + s*(_cgos_sb1_erf+s*(_cgos_sb2_erf+s*(_cgos_sb3_erf+s*(_cgos_sb4_erf+s*(_cgos_sb5_erf+s*(_cgos_sb6_erf+s*_cgos_sb7_erf))))))
}
z = x
for {
Expand Down Expand Up @@ -125,7 +125,7 @@ func Erf(x float64) float64 {
}
z = x * x
r = _cgos_pp0_erf + z*(_cgos_pp1_erf+z*(_cgos_pp2_erf+z*(_cgos_pp3_erf+z*_cgos_pp4_erf)))
s = 1 + z*(_cgos_qq1_erf+z*(_cgos_qq2_erf+z*(_cgos_qq3_erf+z*(_cgos_qq4_erf+z*_cgos_qq5_erf))))
s = 1.0 + z*(_cgos_qq1_erf+z*(_cgos_qq2_erf+z*(_cgos_qq3_erf+z*(_cgos_qq4_erf+z*_cgos_qq5_erf))))
y = r / s
return x + x*y
}
Expand Down Expand Up @@ -167,14 +167,14 @@ func Erfc(x float64) float64 {
}
if ix < uint32(1072365568) {
if ix < uint32(1013972992) {
return 1 - x
return 1.0 - x
}
z = x * x
r = _cgos_pp0_erf + z*(_cgos_pp1_erf+z*(_cgos_pp2_erf+z*(_cgos_pp3_erf+z*_cgos_pp4_erf)))
s = 1 + z*(_cgos_qq1_erf+z*(_cgos_qq2_erf+z*(_cgos_qq3_erf+z*(_cgos_qq4_erf+z*_cgos_qq5_erf))))
s = 1.0 + z*(_cgos_qq1_erf+z*(_cgos_qq2_erf+z*(_cgos_qq3_erf+z*(_cgos_qq4_erf+z*_cgos_qq5_erf))))
y = r / s
if sign != 0 || ix < uint32(1070596096) {
return 1 - (x + x*y)
return 1.0 - (x + x*y)
}
return 0.5 - (x - 0.5 + x*y)
}
Expand Down
10 changes: 5 additions & 5 deletions erff.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ func _cgos_erfc2_erff(ix uint32, x float32) float32 {
s = float32(int32(1)) / (x * x)
if ix < uint32(1077336941) {
R = _cgos_ra0_erff + s*(_cgos_ra1_erff+s*(_cgos_ra2_erff+s*(_cgos_ra3_erff+s*(_cgos_ra4_erff+s*(_cgos_ra5_erff+s*(_cgos_ra6_erff+s*_cgos_ra7_erff))))))
S = 1 + s*(_cgos_sa1_erff+s*(_cgos_sa2_erff+s*(_cgos_sa3_erff+s*(_cgos_sa4_erff+s*(_cgos_sa5_erff+s*(_cgos_sa6_erff+s*(_cgos_sa7_erff+s*_cgos_sa8_erff)))))))
S = 1.0 + s*(_cgos_sa1_erff+s*(_cgos_sa2_erff+s*(_cgos_sa3_erff+s*(_cgos_sa4_erff+s*(_cgos_sa5_erff+s*(_cgos_sa6_erff+s*(_cgos_sa7_erff+s*_cgos_sa8_erff)))))))
} else {
R = _cgos_rb0_erff + s*(_cgos_rb1_erff+s*(_cgos_rb2_erff+s*(_cgos_rb3_erff+s*(_cgos_rb4_erff+s*(_cgos_rb5_erff+s*_cgos_rb6_erff)))))
S = 1 + s*(_cgos_sb1_erff+s*(_cgos_sb2_erff+s*(_cgos_sb3_erff+s*(_cgos_sb4_erff+s*(_cgos_sb5_erff+s*(_cgos_sb6_erff+s*_cgos_sb7_erff))))))
S = 1.0 + s*(_cgos_sb1_erff+s*(_cgos_sb2_erff+s*(_cgos_sb3_erff+s*(_cgos_sb4_erff+s*(_cgos_sb5_erff+s*(_cgos_sb6_erff+s*_cgos_sb7_erff))))))
}
for {
ix = *(*uint32)(unsafe.Pointer(&_cgoz_18_erff{x}))
Expand Down Expand Up @@ -172,14 +172,14 @@ func Erfcf(x float32) float32 {
}
if ix < uint32(1062731776) {
if ix < uint32(595591168) {
return 1 - x
return 1.0 - x
}
z = x * x
r = _cgos_pp0_erff + z*(_cgos_pp1_erff+z*(_cgos_pp2_erff+z*(_cgos_pp3_erff+z*_cgos_pp4_erff)))
s = 1 + z*(_cgos_qq1_erff+z*(_cgos_qq2_erff+z*(_cgos_qq3_erff+z*(_cgos_qq4_erff+z*_cgos_qq5_erff))))
s = 1.0 + z*(_cgos_qq1_erff+z*(_cgos_qq2_erff+z*(_cgos_qq3_erff+z*(_cgos_qq4_erff+z*_cgos_qq5_erff))))
y = r / s
if sign != 0 || ix < uint32(1048576000) {
return 1 - (x + x*y)
return 1.0 - (x + x*y)
}
return 0.5 - (x - 0.5 + x*y)
}
Expand Down
24 changes: 12 additions & 12 deletions exp.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ func _cgos_specialcase_exp(tmp float64, sbits uint64, ki uint64) float64 {
sbits += 4602678819172646912
scale = *(*float64)(unsafe.Pointer(&_cgoz_19_exp{sbits}))
y = scale + scale*tmp
if y < 1 {
if y < 1.0 {
var hi float64
var lo float64
lo = scale - y + scale*tmp
hi = 1 + y
lo = 1 - hi + y + lo
y = eval_as_double(hi+lo) - 1
if int32(1) != 0 && y == 0 {
y = float64(0)
hi = 1.0 + y
lo = 1.0 - hi + y + lo
y = eval_as_double(hi+lo) - 1.0
if int32(1) != 0 && y == 0.0 {
y = float64(0.0)
}
fp_force_eval(fp_barrier(2.2250738585072014e-308) * 2.2250738585072014e-308)
}
Expand Down Expand Up @@ -60,7 +60,7 @@ func Exp(x float64) float64 {
var tmp float64
abstop = _cgos_top12_exp(x) & uint32(2047)
if func() int64 {
if abstop-_cgos_top12_exp(5.5511151231257827e-17) >= _cgos_top12_exp(512)-_cgos_top12_exp(5.5511151231257827e-17) {
if abstop-_cgos_top12_exp(5.5511151231257827e-17) >= _cgos_top12_exp(512.0)-_cgos_top12_exp(5.5511151231257827e-17) {
return 1
} else {
return 0
Expand All @@ -69,18 +69,18 @@ func Exp(x float64) float64 {
if abstop-_cgos_top12_exp(5.5511151231257827e-17) >= uint32(2147483648) {
return func() float64 {
if int32(1) != 0 {
return 1 + x
return 1.0 + x
} else {
return 1
return 1.0
}
}()
}
if abstop >= _cgos_top12_exp(1024) {
if abstop >= _cgos_top12_exp(1024.0) {
if *(*uint64)(unsafe.Pointer(&_cgoz_21_exp{x})) == *(*uint64)(unsafe.Pointer(&_cgoz_22_exp{float64(-X__builtin_inff())})) {
return float64(0)
return float64(0.0)
}
if abstop >= _cgos_top12_exp(float64(X__builtin_inff())) {
return 1 + x
return 1.0 + x
}
if *(*uint64)(unsafe.Pointer(&_cgoz_23_exp{x}))>>int32(63) != 0 {
return __math_uflow(uint32(0))
Expand Down
4 changes: 2 additions & 2 deletions exp10.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func Exp10(x float64) float64 {
y = Exp2(3.3219280948873622 * y)
return y * *(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer((*float64)(unsafe.Pointer(&_cgos_p10_exp10)))) + uintptr(int32(n)+int32(15))*8))
}
return Pow(10, x)
return Pow(10.0, x)
}

var _cgos_p10_exp10 [31]float64 = [31]float64{1.0000000000000001e-15, 9.9999999999999999e-15, 1.0e-13, 9.9999999999999998e-13, 9.9999999999999993e-12, 1.0e-10, 1.0000000000000001e-9, 1.0e-8, 9.9999999999999995e-8, 9.9999999999999995e-7, 1.0000000000000001e-5, 1.0e-4, 0.001, 0.01, 0.10000000000000001, float64(int32(1)), 10, 100, 1000, 1.0e+4, 1.0e+5, 1.0e+6, 1.0e+7, 1.0e+8, 1.0e+9, 1.0e+10, 1.0e+11, 1.0e+12, 1.0e+13, 1.0e+14, 1.0e+15}
var _cgos_p10_exp10 [31]float64 = [31]float64{1.0000000000000001e-15, 9.9999999999999999e-15, 1.0e-13, 9.9999999999999998e-13, 9.9999999999999993e-12, 1.0e-10, 1.0000000000000001e-9, 1.0e-8, 9.9999999999999995e-8, 9.9999999999999995e-7, 1.0000000000000001e-5, 1.0e-4, 0.001, 0.01, 0.10000000000000001, float64(int32(1)), 10.0, 100.0, 1000.0, 1.0e+4, 1.0e+5, 1.0e+6, 1.0e+7, 1.0e+8, 1.0e+9, 1.0e+10, 1.0e+11, 1.0e+12, 1.0e+13, 1.0e+14, 1.0e+15}
2 changes: 1 addition & 1 deletion exp10f.c.i.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ func Exp10f(x float32) float32 {
return float32(Exp2(3.3219280948873622 * float64(x)))
}

var _cgos_p10_exp10f [15]float32 = [15]float32{1.00000001e-7, 9.99999997e-7, 9.99999974e-6, 9.99999974e-5, 0.00100000005, 0.00999999977, 0.100000001, float32(int32(1)), float32(10), float32(100), float32(1000), float32(1.0e+4), float32(1.0e+5), float32(1.0e+6), float32(1.0e+7)}
var _cgos_p10_exp10f [15]float32 = [15]float32{1.00000001e-7, 9.99999997e-7, 9.99999974e-6, 9.99999974e-5, 0.00100000005, 0.00999999977, 0.100000001, float32(int32(1)), float32(10.0), float32(100.0), float32(1000.0), float32(1.0e+4), float32(1.0e+5), float32(1.0e+6), float32(1.0e+7)}
Loading

0 comments on commit 24ef5dd

Please sign in to comment.