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

Commit

Permalink
support ./src/math/*.c
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Jul 22, 2022
1 parent 2b76d51 commit a808ae2
Show file tree
Hide file tree
Showing 198 changed files with 9,657 additions and 619 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ lib/musl-gcc.specs

.vscode
.DS_Store
.c2go.*

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
Expand Down
93 changes: 93 additions & 0 deletions acos.c.i.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package libc

import unsafe "unsafe"

var pio2_hi_cgo18_acos float64 = 1.5707963267948966
var pio2_lo_cgo19_acos float64 = 6.123233995736766e-17
var pS0_cgo20_acos float64 = 0.16666666666666666
var pS1_cgo21_acos float64 = -0.32556581862240092
var pS2_cgo22_acos float64 = 0.20121253213486293
var pS3_cgo23_acos float64 = -0.040055534500679411
var pS4_cgo24_acos float64 = 7.9153499428981453e-4
var pS5_cgo25_acos float64 = 3.4793310759602117e-5
var qS1_cgo26_acos float64 = -2.4033949117344142
var qS2_cgo27_acos float64 = 2.0209457602335057
var qS3_cgo28_acos float64 = -0.68828397160545329
var qS4_cgo29_acos float64 = 0.077038150555901935

func R_cgo30_acos(z float64) float64 {
var p float64
var q float64
p = z * (pS0_cgo20_acos + z*(pS1_cgo21_acos+z*(pS2_cgo22_acos+z*(pS3_cgo23_acos+z*(pS4_cgo24_acos+z*pS5_cgo25_acos)))))
q = 1 + z*(qS1_cgo26_acos+z*(qS2_cgo27_acos+z*(qS3_cgo28_acos+z*qS4_cgo29_acos)))
return p / q
}
func Acos(x float64) float64 {
var z float64
var w float64
var s float64
var c float64
var df float64
var hx uint32
var ix uint32
for {
hx = uint32(*(*uint64)(unsafe.Pointer(&_cgoz_31_acos{x})) >> int32(32))
if true {
break
}
}
ix = hx & uint32(2147483647)
if ix >= uint32(1072693248) {
var lx uint32
for {
lx = uint32(*(*uint64)(unsafe.Pointer(&_cgoz_32_acos{x})))
if true {
break
}
}
if ix-uint32(1072693248)|lx == uint32(0) {
if hx>>int32(31) != 0 {
return float64(int32(2))*pio2_hi_cgo18_acos + float64(7.52316385e-37)
}
return float64(int32(0))
}
return float64(int32(0)) / (x - x)
}
if ix < uint32(1071644672) {
if ix <= uint32(1012924416) {
return pio2_hi_cgo18_acos + float64(7.52316385e-37)
}
return pio2_hi_cgo18_acos - (x - (pio2_lo_cgo19_acos - x*R_cgo30_acos(x*x)))
}
if hx>>int32(31) != 0 {
z = (1 + x) * 0.5
s = Sqrt(z)
w = R_cgo30_acos(z)*s - pio2_lo_cgo19_acos
return float64(int32(2)) * (pio2_hi_cgo18_acos - (s + w))
}
z = (1 - x) * 0.5
s = Sqrt(z)
df = s
for {
df = *(*float64)(unsafe.Pointer(&_cgoz_33_acos{uint64(*(*uint64)(unsafe.Pointer(&_cgoz_34_acos{df}))>>int32(32))<<int32(32) | uint64(0)}))
if true {
break
}
}
c = (z - df*df) / (s + df)
w = R_cgo30_acos(z)*s + c
return float64(int32(2)) * (df + w)
}

type _cgoz_31_acos struct {
_f float64
}
type _cgoz_32_acos struct {
_f float64
}
type _cgoz_33_acos struct {
_i uint64
}
type _cgoz_34_acos struct {
_f float64
}
82 changes: 82 additions & 0 deletions acosf.c.i.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package libc

import unsafe "unsafe"

var pio2_hi_cgo18_acosf float32 = float32(1.5707962513)
var pio2_lo_cgo19_acosf float32 = float32(7.5497894159e-8)
var pS0_cgo20_acosf float32 = float32(0.16666586696999999)
var pS1_cgo21_acosf float32 = float32(-0.042743422091000002)
var pS2_cgo22_acosf float32 = float32(-0.0086563630029999998)
var qS1_cgo23_acosf float32 = float32(-0.7066296339)

func R_cgo24_acosf(z float32) float32 {
var p float32
var q float32
p = z * (pS0_cgo20_acosf + z*(pS1_cgo21_acosf+z*pS2_cgo22_acosf))
q = 1 + z*qS1_cgo23_acosf
return p / q
}
func Acosf(x float32) float32 {
var z float32
var w float32
var s float32
var c float32
var df float32
var hx uint32
var ix uint32
for {
hx = *(*uint32)(unsafe.Pointer(&_cgoz_25_acosf{x}))
if true {
break
}
}
ix = hx & uint32(2147483647)
if ix >= uint32(1065353216) {
if ix == uint32(1065353216) {
if hx>>int32(31) != 0 {
return float32(int32(2))*pio2_hi_cgo18_acosf + 7.52316385e-37
}
return float32(int32(0))
}
return float32(int32(0)) / (x - x)
}
if ix < uint32(1056964608) {
if ix <= uint32(847249408) {
return pio2_hi_cgo18_acosf + 7.52316385e-37
}
return pio2_hi_cgo18_acosf - (x - (pio2_lo_cgo19_acosf - x*R_cgo24_acosf(x*x)))
}
if hx>>int32(31) != 0 {
z = (float32(int32(1)) + x) * 0.5
s = Sqrtf(z)
w = R_cgo24_acosf(z)*s - pio2_lo_cgo19_acosf
return float32(int32(2)) * (pio2_hi_cgo18_acosf - (s + w))
}
z = (float32(int32(1)) - x) * 0.5
s = Sqrtf(z)
for {
hx = *(*uint32)(unsafe.Pointer(&_cgoz_26_acosf{s}))
if true {
break
}
}
for {
df = *(*float32)(unsafe.Pointer(&_cgoz_27_acosf{hx & uint32(4294963200)}))
if true {
break
}
}
c = (z - df*df) / (s + df)
w = R_cgo24_acosf(z)*s + c
return float32(int32(2)) * (df + w)
}

type _cgoz_25_acosf struct {
_f float32
}
type _cgoz_26_acosf struct {
_f float32
}
type _cgoz_27_acosf struct {
_i uint32
}
19 changes: 19 additions & 0 deletions acosh.c.i.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package libc

import unsafe "unsafe"

func Acosh(x float64) float64 {
type _cgoa_18_acosh struct {
f float64
}
var u _cgoa_18_acosh
u.f = x
var e uint32 = uint32(*(*uint64)(unsafe.Pointer(&u)) >> int32(52) & uint64(2047))
if e < uint32(1024) {
return Log1p(x - float64(int32(1)) + Sqrt((x-float64(int32(1)))*(x-float64(int32(1)))+float64(int32(2))*(x-float64(int32(1)))))
}
if e < uint32(1049) {
return Log(float64(int32(2))*x - float64(int32(1))/(x+Sqrt(x*x-float64(int32(1)))))
}
return Log(x) + 0.69314718055994529
}
19 changes: 19 additions & 0 deletions acoshf.c.i.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package libc

import unsafe "unsafe"

func Acoshf(x float32) float32 {
type _cgoa_18_acoshf struct {
f float32
}
var u _cgoa_18_acoshf
u.f = x
var a uint32 = *(*uint32)(unsafe.Pointer(&u)) & uint32(2147483647)
if a < uint32(1073741824) {
return Log1pf(x - float32(int32(1)) + Sqrtf((x-float32(int32(1)))*(x-float32(int32(1)))+float32(int32(2))*(x-float32(int32(1)))))
}
if a < uint32(1166016512) {
return Logf(float32(int32(2))*x - float32(int32(1))/(x+Sqrtf(x*x-float32(int32(1)))))
}
return Logf(x) + 0.693147182
}
5 changes: 5 additions & 0 deletions acoshl.c.i.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package libc

func Acoshl(x float64) float64 {
return float64(Acosh(float64(x)))
}
5 changes: 5 additions & 0 deletions acosl.c.i.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package libc

func Acosl(x float64) float64 {
return float64(Acos(float64(x)))
}
92 changes: 92 additions & 0 deletions asin.c.i.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package libc

import unsafe "unsafe"

var pio2_hi_cgo18_asin float64 = 1.5707963267948966
var pio2_lo_cgo19_asin float64 = 6.123233995736766e-17
var pS0_cgo20_asin float64 = 0.16666666666666666
var pS1_cgo21_asin float64 = -0.32556581862240092
var pS2_cgo22_asin float64 = 0.20121253213486293
var pS3_cgo23_asin float64 = -0.040055534500679411
var pS4_cgo24_asin float64 = 7.9153499428981453e-4
var pS5_cgo25_asin float64 = 3.4793310759602117e-5
var qS1_cgo26_asin float64 = -2.4033949117344142
var qS2_cgo27_asin float64 = 2.0209457602335057
var qS3_cgo28_asin float64 = -0.68828397160545329
var qS4_cgo29_asin float64 = 0.077038150555901935

func R_cgo30_asin(z float64) float64 {
var p float64
var q float64
p = z * (pS0_cgo20_asin + z*(pS1_cgo21_asin+z*(pS2_cgo22_asin+z*(pS3_cgo23_asin+z*(pS4_cgo24_asin+z*pS5_cgo25_asin)))))
q = 1 + z*(qS1_cgo26_asin+z*(qS2_cgo27_asin+z*(qS3_cgo28_asin+z*qS4_cgo29_asin)))
return p / q
}
func Asin(x float64) float64 {
var z float64
var r float64
var s float64
var hx uint32
var ix uint32
for {
hx = uint32(*(*uint64)(unsafe.Pointer(&_cgoz_31_asin{x})) >> int32(32))
if true {
break
}
}
ix = hx & uint32(2147483647)
if ix >= uint32(1072693248) {
var lx uint32
for {
lx = uint32(*(*uint64)(unsafe.Pointer(&_cgoz_32_asin{x})))
if true {
break
}
}
if ix-uint32(1072693248)|lx == uint32(0) {
return x*pio2_hi_cgo18_asin + float64(7.52316385e-37)
}
return float64(int32(0)) / (x - x)
}
if ix < uint32(1071644672) {
if ix < uint32(1045430272) && ix >= uint32(1048576) {
return x
}
return x + x*R_cgo30_asin(x*x)
}
z = (float64(int32(1)) - Fabs(x)) * 0.5
s = Sqrt(z)
r = R_cgo30_asin(z)
if ix >= uint32(1072640819) {
x = pio2_hi_cgo18_asin - (float64(int32(2))*(s+s*r) - pio2_lo_cgo19_asin)
} else {
var f float64
var c float64
f = s
for {
f = *(*float64)(unsafe.Pointer(&_cgoz_33_asin{uint64(*(*uint64)(unsafe.Pointer(&_cgoz_34_asin{f}))>>int32(32))<<int32(32) | uint64(0)}))
if true {
break
}
}
c = (z - f*f) / (s + f)
x = 0.5*pio2_hi_cgo18_asin - (float64(int32(2))*s*r - (pio2_lo_cgo19_asin - float64(int32(2))*c) - (0.5*pio2_hi_cgo18_asin - float64(int32(2))*f))
}
if hx>>int32(31) != 0 {
return -x
}
return x
}

type _cgoz_31_asin struct {
_f float64
}
type _cgoz_32_asin struct {
_f float64
}
type _cgoz_33_asin struct {
_i uint64
}
type _cgoz_34_asin struct {
_f float64
}
53 changes: 53 additions & 0 deletions asinf.c.i.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package libc

import unsafe "unsafe"

var pio2_cgo18_asinf float64 = 1.5707963267948966
var pS0_cgo19_asinf float32 = float32(0.16666586696999999)
var pS1_cgo20_asinf float32 = float32(-0.042743422091000002)
var pS2_cgo21_asinf float32 = float32(-0.0086563630029999998)
var qS1_cgo22_asinf float32 = float32(-0.7066296339)

func R_cgo23_asinf(z float32) float32 {
var p float32
var q float32
p = z * (pS0_cgo19_asinf + z*(pS1_cgo20_asinf+z*pS2_cgo21_asinf))
q = 1 + z*qS1_cgo22_asinf
return p / q
}
func Asinf(x float32) float32 {
var s float64
var z float32
var hx uint32
var ix uint32
for {
hx = *(*uint32)(unsafe.Pointer(&_cgoz_24_asinf{x}))
if true {
break
}
}
ix = hx & uint32(2147483647)
if ix >= uint32(1065353216) {
if ix == uint32(1065353216) {
return float32(float64(x)*pio2_cgo18_asinf + float64(7.52316385e-37))
}
return float32(int32(0)) / (x - x)
}
if ix < uint32(1056964608) {
if ix < uint32(964689920) && ix >= uint32(8388608) {
return x
}
return x + x*R_cgo23_asinf(x*x)
}
z = (float32(int32(1)) - Fabsf(x)) * 0.5
s = Sqrt(float64(z))
x = float32(pio2_cgo18_asinf - float64(int32(2))*(s+s*float64(R_cgo23_asinf(z))))
if hx>>int32(31) != 0 {
return -x
}
return x
}

type _cgoz_24_asinf struct {
_f float32
}
Loading

0 comments on commit a808ae2

Please sign in to comment.