mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-01 12:52:26 -05:00
[chore] update dependencies (#4188)
Update dependencies:
- github.com/gin-gonic/gin v1.10.0 -> v1.10.1
- github.com/gin-contrib/sessions v1.10.3 -> v1.10.4
- github.com/jackc/pgx/v5 v5.7.4 -> v5.7.5
- github.com/minio/minio-go/v7 v7.0.91 -> v7.0.92
- github.com/pquerna/otp v1.4.0 -> v1.5.0
- github.com/tdewolff/minify/v2 v2.23.5 -> v2.23.8
- github.com/yuin/goldmark v1.7.11 -> v1.7.12
- go.opentelemetry.io/otel{,/*} v1.35.0 -> v1.36.0
- modernc.org/sqlite v1.37.0 -> v1.37.1
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4188
Reviewed-by: Daenney <daenney@noreply.codeberg.org>
Co-authored-by: kim <grufwub@gmail.com>
Co-committed-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
20aad9be0f
commit
b6ff55662e
214 changed files with 44839 additions and 32023 deletions
951
vendor/modernc.org/libc/libc.go
generated
vendored
951
vendor/modernc.org/libc/libc.go
generated
vendored
|
|
@ -4,11 +4,9 @@
|
|||
|
||||
//go:build !linux || mips64le
|
||||
|
||||
//go.generate echo package libc > ccgo.go
|
||||
//go:generate go fmt ./...
|
||||
|
||||
// Package libc provides run time support for ccgo generated programs and
|
||||
// implements selected parts of the C standard library.
|
||||
// go.generate echo package libc > ccgo.go
|
||||
//
|
||||
//go:generate go fmt -l -s -w ./...
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
//TODO use O_RDONLY etc. from fcntl header
|
||||
|
|
@ -1952,7 +1950,7 @@ func getLocalLocation() (loc *gotime.Location) {
|
|||
}
|
||||
|
||||
// time_t mktime(struct tm *tm);
|
||||
func Xmktime(t *TLS, ptm uintptr) time.Time_t {
|
||||
func Xmktime(t *TLS, ptm uintptr) (r time.Time_t) {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v ptm=%v, (%v:)", t, ptm, origin(2))
|
||||
}
|
||||
|
|
@ -1969,7 +1967,8 @@ func Xmktime(t *TLS, ptm uintptr) time.Time_t {
|
|||
)
|
||||
(*time.Tm)(unsafe.Pointer(ptm)).Ftm_wday = int32(tt.Weekday())
|
||||
(*time.Tm)(unsafe.Pointer(ptm)).Ftm_yday = int32(tt.YearDay() - 1)
|
||||
return time.Time_t(tt.Unix())
|
||||
r = time.Time_t(tt.Unix())
|
||||
return r
|
||||
}
|
||||
|
||||
// char *strpbrk(const char *s, const char *accept);
|
||||
|
|
@ -2314,14 +2313,6 @@ func Xwcwidth(t *TLS, c wchar_t) int32 {
|
|||
panic(todo(""))
|
||||
}
|
||||
|
||||
// int clock_gettime(clockid_t clk_id, struct timespec *tp);
|
||||
func Xclock_gettime(t *TLS, clk_id int32, tp uintptr) int32 {
|
||||
if __ccgo_strace {
|
||||
trc("t=%v clk_id=%v tp=%v, (%v:)", t, clk_id, tp, origin(2))
|
||||
}
|
||||
panic(todo(""))
|
||||
}
|
||||
|
||||
// AtExit will attempt to run f at process exit. The execution cannot be
|
||||
// guaranteed, neither its ordering with respect to any other handlers
|
||||
// registered by AtExit.
|
||||
|
|
@ -2650,3 +2641,933 @@ func Xlrint(tls *TLS, x float64) (r long) {
|
|||
}
|
||||
return long(Xrint(tls, x))
|
||||
}
|
||||
|
||||
func X__builtin_trunc(tls *TLS, x float64) (r float64) {
|
||||
return Xtrunc(tls, x)
|
||||
}
|
||||
|
||||
func X__builtin_fmin(tls *TLS, x float64, y float64) (r float64) {
|
||||
return Xfmin(tls, x, y)
|
||||
}
|
||||
|
||||
func Xfmin(tls *TLS, x float64, y float64) (r float64) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
bp := tls.Alloc(16)
|
||||
defer tls.Free(16)
|
||||
var v1, v10, v3, v5, v7 uint64
|
||||
var v12, v9 float64
|
||||
var _ /* __u at bp+0 */ struct {
|
||||
F__i [0]uint64
|
||||
F__f float64
|
||||
}
|
||||
_, _, _, _, _, _, _ = v1, v10, v12, v3, v5, v7, v9
|
||||
*(*float64)(unsafe.Pointer(bp)) = x
|
||||
v1 = *(*uint64)(unsafe.Pointer(bp))
|
||||
goto _2
|
||||
_2:
|
||||
if BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<<Int32FromInt32(52)) != 0 {
|
||||
return y
|
||||
}
|
||||
*(*float64)(unsafe.Pointer(bp)) = y
|
||||
v3 = *(*uint64)(unsafe.Pointer(bp))
|
||||
goto _4
|
||||
_4:
|
||||
if BoolInt32(v3&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<<Int32FromInt32(52)) != 0 {
|
||||
return x
|
||||
}
|
||||
/* handle signed zeros, see C99 Annex F.9.9.2 */
|
||||
*(*float64)(unsafe.Pointer(bp)) = x
|
||||
v5 = *(*uint64)(unsafe.Pointer(bp))
|
||||
goto _6
|
||||
_6:
|
||||
*(*float64)(unsafe.Pointer(bp)) = y
|
||||
v7 = *(*uint64)(unsafe.Pointer(bp))
|
||||
goto _8
|
||||
_8:
|
||||
if Int32FromUint64(v5>>Int32FromInt32(63)) != Int32FromUint64(v7>>Int32FromInt32(63)) {
|
||||
*(*float64)(unsafe.Pointer(bp)) = x
|
||||
v10 = *(*uint64)(unsafe.Pointer(bp))
|
||||
goto _11
|
||||
_11:
|
||||
if Int32FromUint64(v10>>Int32FromInt32(63)) != 0 {
|
||||
v9 = x
|
||||
} else {
|
||||
v9 = y
|
||||
}
|
||||
return v9
|
||||
}
|
||||
if x < y {
|
||||
v12 = x
|
||||
} else {
|
||||
v12 = y
|
||||
}
|
||||
return v12
|
||||
}
|
||||
|
||||
func Xfminf(tls *TLS, x float32, y float32) (r float32) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
bp := tls.Alloc(16)
|
||||
defer tls.Free(16)
|
||||
var v1, v10, v3, v5, v7 uint32
|
||||
var v12, v9 float32
|
||||
var _ /* __u at bp+0 */ struct {
|
||||
F__i [0]uint32
|
||||
F__f float32
|
||||
}
|
||||
_, _, _, _, _, _, _ = v1, v10, v12, v3, v5, v7, v9
|
||||
*(*float32)(unsafe.Pointer(bp)) = x
|
||||
v1 = *(*uint32)(unsafe.Pointer(bp))
|
||||
goto _2
|
||||
_2:
|
||||
if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 {
|
||||
return y
|
||||
}
|
||||
*(*float32)(unsafe.Pointer(bp)) = y
|
||||
v3 = *(*uint32)(unsafe.Pointer(bp))
|
||||
goto _4
|
||||
_4:
|
||||
if BoolInt32(v3&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 {
|
||||
return x
|
||||
}
|
||||
/* handle signed zeros, see C99 Annex F.9.9.2 */
|
||||
*(*float32)(unsafe.Pointer(bp)) = x
|
||||
v5 = *(*uint32)(unsafe.Pointer(bp))
|
||||
goto _6
|
||||
_6:
|
||||
*(*float32)(unsafe.Pointer(bp)) = y
|
||||
v7 = *(*uint32)(unsafe.Pointer(bp))
|
||||
goto _8
|
||||
_8:
|
||||
if Int32FromUint32(v5>>Int32FromInt32(31)) != Int32FromUint32(v7>>Int32FromInt32(31)) {
|
||||
*(*float32)(unsafe.Pointer(bp)) = x
|
||||
v10 = *(*uint32)(unsafe.Pointer(bp))
|
||||
goto _11
|
||||
_11:
|
||||
if Int32FromUint32(v10>>Int32FromInt32(31)) != 0 {
|
||||
v9 = x
|
||||
} else {
|
||||
v9 = y
|
||||
}
|
||||
return v9
|
||||
}
|
||||
if x < y {
|
||||
v12 = x
|
||||
} else {
|
||||
v12 = y
|
||||
}
|
||||
return v12
|
||||
}
|
||||
|
||||
func Xfminl(tls *TLS, x float64, y float64) (r float64) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
return Xfmin(tls, x, y)
|
||||
}
|
||||
|
||||
func Xfmax(tls *TLS, x float64, y float64) (r float64) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
bp := tls.Alloc(16)
|
||||
defer tls.Free(16)
|
||||
var v1, v10, v3, v5, v7 uint64
|
||||
var v12, v9 float64
|
||||
var _ /* __u at bp+0 */ struct {
|
||||
F__i [0]uint64
|
||||
F__f float64
|
||||
}
|
||||
_, _, _, _, _, _, _ = v1, v10, v12, v3, v5, v7, v9
|
||||
*(*float64)(unsafe.Pointer(bp)) = x
|
||||
v1 = *(*uint64)(unsafe.Pointer(bp))
|
||||
goto _2
|
||||
_2:
|
||||
if BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<<Int32FromInt32(52)) != 0 {
|
||||
return y
|
||||
}
|
||||
*(*float64)(unsafe.Pointer(bp)) = y
|
||||
v3 = *(*uint64)(unsafe.Pointer(bp))
|
||||
goto _4
|
||||
_4:
|
||||
if BoolInt32(v3&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<<Int32FromInt32(52)) != 0 {
|
||||
return x
|
||||
}
|
||||
/* handle signed zeros, see C99 Annex F.9.9.2 */
|
||||
*(*float64)(unsafe.Pointer(bp)) = x
|
||||
v5 = *(*uint64)(unsafe.Pointer(bp))
|
||||
goto _6
|
||||
_6:
|
||||
*(*float64)(unsafe.Pointer(bp)) = y
|
||||
v7 = *(*uint64)(unsafe.Pointer(bp))
|
||||
goto _8
|
||||
_8:
|
||||
if Int32FromUint64(v5>>Int32FromInt32(63)) != Int32FromUint64(v7>>Int32FromInt32(63)) {
|
||||
*(*float64)(unsafe.Pointer(bp)) = x
|
||||
v10 = *(*uint64)(unsafe.Pointer(bp))
|
||||
goto _11
|
||||
_11:
|
||||
if Int32FromUint64(v10>>Int32FromInt32(63)) != 0 {
|
||||
v9 = y
|
||||
} else {
|
||||
v9 = x
|
||||
}
|
||||
return v9
|
||||
}
|
||||
if x < y {
|
||||
v12 = y
|
||||
} else {
|
||||
v12 = x
|
||||
}
|
||||
return v12
|
||||
}
|
||||
|
||||
func Xfmaxf(tls *TLS, x float32, y float32) (r float32) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
bp := tls.Alloc(16)
|
||||
defer tls.Free(16)
|
||||
var v1, v10, v3, v5, v7 uint32
|
||||
var v12, v9 float32
|
||||
var _ /* __u at bp+0 */ struct {
|
||||
F__i [0]uint32
|
||||
F__f float32
|
||||
}
|
||||
_, _, _, _, _, _, _ = v1, v10, v12, v3, v5, v7, v9
|
||||
*(*float32)(unsafe.Pointer(bp)) = x
|
||||
v1 = *(*uint32)(unsafe.Pointer(bp))
|
||||
goto _2
|
||||
_2:
|
||||
if BoolInt32(v1&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 {
|
||||
return y
|
||||
}
|
||||
*(*float32)(unsafe.Pointer(bp)) = y
|
||||
v3 = *(*uint32)(unsafe.Pointer(bp))
|
||||
goto _4
|
||||
_4:
|
||||
if BoolInt32(v3&uint32(0x7fffffff) > uint32(0x7f800000)) != 0 {
|
||||
return x
|
||||
}
|
||||
/* handle signed zeroes, see C99 Annex F.9.9.2 */
|
||||
*(*float32)(unsafe.Pointer(bp)) = x
|
||||
v5 = *(*uint32)(unsafe.Pointer(bp))
|
||||
goto _6
|
||||
_6:
|
||||
*(*float32)(unsafe.Pointer(bp)) = y
|
||||
v7 = *(*uint32)(unsafe.Pointer(bp))
|
||||
goto _8
|
||||
_8:
|
||||
if Int32FromUint32(v5>>Int32FromInt32(31)) != Int32FromUint32(v7>>Int32FromInt32(31)) {
|
||||
*(*float32)(unsafe.Pointer(bp)) = x
|
||||
v10 = *(*uint32)(unsafe.Pointer(bp))
|
||||
goto _11
|
||||
_11:
|
||||
if Int32FromUint32(v10>>Int32FromInt32(31)) != 0 {
|
||||
v9 = y
|
||||
} else {
|
||||
v9 = x
|
||||
}
|
||||
return v9
|
||||
}
|
||||
if x < y {
|
||||
v12 = y
|
||||
} else {
|
||||
v12 = x
|
||||
}
|
||||
return v12
|
||||
}
|
||||
|
||||
func Xfmaxl(tls *TLS, x float64, y float64) (r float64) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
return Xfmax(tls, x, y)
|
||||
}
|
||||
|
||||
func X__builtin_fmax(tls *TLS, x float64, y float64) (r float64) {
|
||||
return Xfmax(tls, x, y)
|
||||
}
|
||||
|
||||
func Xexpm1(tls *TLS, x3 float64) (r float64) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
bp := tls.Alloc(16)
|
||||
defer tls.Free(16)
|
||||
var c, e, hfx, hi, hxs, lo, r1, t, twopk, y3 Tdouble_t
|
||||
var hx Tuint32_t
|
||||
var k, sign int32
|
||||
var y float32
|
||||
var y1, y2, v3 float64
|
||||
var v1 uint64
|
||||
var _ /* __u at bp+0 */ struct {
|
||||
F__i [0]uint64
|
||||
F__f float64
|
||||
}
|
||||
var _ /* u at bp+8 */ struct {
|
||||
Fi [0]Tuint64_t
|
||||
Ff float64
|
||||
}
|
||||
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, e, hfx, hi, hx, hxs, k, lo, r1, sign, t, twopk, y, y1, y2, y3, v1, v3
|
||||
*(*struct {
|
||||
Fi [0]Tuint64_t
|
||||
Ff float64
|
||||
})(unsafe.Pointer(bp + 8)) = struct {
|
||||
Fi [0]Tuint64_t
|
||||
Ff float64
|
||||
}{}
|
||||
*(*float64)(unsafe.Pointer(bp + 8)) = x3
|
||||
hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(32) & uint64(0x7fffffff))
|
||||
sign = Int32FromUint64(*(*Tuint64_t)(unsafe.Pointer(bp + 8)) >> int32(63))
|
||||
/* filter out huge and non-finite argument */
|
||||
if hx >= uint32(0x4043687A) { /* if |x|>=56*ln2 */
|
||||
*(*float64)(unsafe.Pointer(bp)) = x3
|
||||
v1 = *(*uint64)(unsafe.Pointer(bp))
|
||||
goto _2
|
||||
_2:
|
||||
if BoolInt32(v1&(-Uint64FromUint64(1)>>Int32FromInt32(1)) > Uint64FromUint64(0x7ff)<<Int32FromInt32(52)) != 0 {
|
||||
return x3
|
||||
}
|
||||
if sign != 0 {
|
||||
return float64(-Int32FromInt32(1))
|
||||
}
|
||||
if x3 > _o_threshold {
|
||||
x3 *= float64(8.98846567431158e+307)
|
||||
return x3
|
||||
}
|
||||
}
|
||||
/* argument reduction */
|
||||
if hx > uint32(0x3fd62e42) { /* if |x| > 0.5 ln2 */
|
||||
if hx < uint32(0x3FF0A2B2) { /* and |x| < 1.5 ln2 */
|
||||
if !(sign != 0) {
|
||||
hi = x3 - _ln2_hi
|
||||
lo = _ln2_lo
|
||||
k = int32(1)
|
||||
} else {
|
||||
hi = x3 + _ln2_hi
|
||||
lo = -_ln2_lo
|
||||
k = -int32(1)
|
||||
}
|
||||
} else {
|
||||
if sign != 0 {
|
||||
v3 = -Float64FromFloat64(0.5)
|
||||
} else {
|
||||
v3 = float64(0.5)
|
||||
}
|
||||
k = int32(float64(_invln2*x3) + v3)
|
||||
t = float64(k)
|
||||
hi = x3 - float64(t*_ln2_hi) /* t*ln2_hi is exact here */
|
||||
lo = Tdouble_t(t * _ln2_lo)
|
||||
}
|
||||
x3 = hi - lo
|
||||
c = hi - x3 - lo
|
||||
} else {
|
||||
if hx < uint32(0x3c900000) { /* |x| < 2**-54, return x */
|
||||
if hx < uint32(0x00100000) {
|
||||
if uint64(4) == uint64(4) {
|
||||
y = float32(x3)
|
||||
} else {
|
||||
if uint64(4) == uint64(8) {
|
||||
y1 = float64(float32(x3))
|
||||
} else {
|
||||
y2 = float64(float32(x3))
|
||||
}
|
||||
}
|
||||
}
|
||||
return x3
|
||||
} else {
|
||||
k = 0
|
||||
}
|
||||
}
|
||||
/* x is now in primary range */
|
||||
hfx = Tdouble_t(float64(0.5) * x3)
|
||||
hxs = Tdouble_t(x3 * hfx)
|
||||
r1 = float64(1) + float64(hxs*(_Q1+float64(hxs*(_Q2+float64(hxs*(_Q3+float64(hxs*(_Q4+float64(hxs*_Q5)))))))))
|
||||
t = float64(3) - float64(r1*hfx)
|
||||
e = Tdouble_t(hxs * ((r1 - t) / (Float64FromFloat64(6) - float64(x3*t))))
|
||||
if k == 0 { /* c is 0 */
|
||||
return x3 - (float64(x3*e) - hxs)
|
||||
}
|
||||
e = float64(x3*(e-c)) - c
|
||||
e -= hxs
|
||||
/* exp(x) ~ 2^k (Xreduced - e + 1) */
|
||||
if k == -int32(1) {
|
||||
return float64(float64(0.5)*(x3-e)) - float64(0.5)
|
||||
}
|
||||
if k == int32(1) {
|
||||
if x3 < -Float64FromFloat64(0.25) {
|
||||
return float64(-Float64FromFloat64(2) * (e - (x3 + Float64FromFloat64(0.5))))
|
||||
}
|
||||
return float64(1) + float64(float64(2)*(x3-e))
|
||||
}
|
||||
*(*Tuint64_t)(unsafe.Pointer(bp + 8)) = Uint64FromInt32(Int32FromInt32(0x3ff)+k) << int32(52) /* 2^k */
|
||||
twopk = *(*float64)(unsafe.Pointer(bp + 8))
|
||||
if k < 0 || k > int32(56) { /* suffice to return exp(x)-1 */
|
||||
y3 = x3 - e + float64(1)
|
||||
if k == int32(1024) {
|
||||
y3 = Tdouble_t(Tdouble_t(y3*float64(2)) * float64(8.98846567431158e+307))
|
||||
} else {
|
||||
y3 = Tdouble_t(y3 * twopk)
|
||||
}
|
||||
return y3 - float64(1)
|
||||
}
|
||||
*(*Tuint64_t)(unsafe.Pointer(bp + 8)) = Uint64FromInt32(Int32FromInt32(0x3ff)-k) << int32(52) /* 2^-k */
|
||||
if k < int32(20) {
|
||||
y3 = Tdouble_t((x3 - e + (Float64FromInt32(1) - *(*float64)(unsafe.Pointer(bp + 8)))) * twopk)
|
||||
} else {
|
||||
y3 = Tdouble_t((x3 - (e + *(*float64)(unsafe.Pointer(bp + 8))) + Float64FromInt32(1)) * twopk)
|
||||
}
|
||||
return y3
|
||||
}
|
||||
|
||||
var _ln2_hi1 = float32(0.69313812256) /* 0x3f317180 */
|
||||
var _ln2_lo1 = float32(9.0580006145e-06) /* 0x3717f7d1 */
|
||||
var _invln21 = float32(1.4426950216) /* 0x3fb8aa3b */
|
||||
/*
|
||||
* Domain [-0.34568, 0.34568], range ~[-6.694e-10, 6.696e-10]:
|
||||
* |6 / x * (1 + 2 * (1 / (exp(x) - 1) - 1 / x)) - q(x)| < 2**-30.04
|
||||
* Scaled coefficients: Qn_here = 2**n * Qn_for_q (see s_expm1.c):
|
||||
*/
|
||||
var _Q11 = float32(-Float64FromFloat64(0.033333212137)) /* -0x888868.0p-28 */
|
||||
var _Q21 = float32(0.0015807170421) /* 0xcf3010.0p-33 */
|
||||
|
||||
func Xexpm1f(tls *TLS, x3 float32) (r float32) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
bp := tls.Alloc(16)
|
||||
defer tls.Free(16)
|
||||
var c, e, hfx, hi, hxs, lo, r1, t, twopk, y3 Tfloat_t
|
||||
var hx Tuint32_t
|
||||
var k, sign int32
|
||||
var y, v1 float32
|
||||
var y1, y2 float64
|
||||
var _ /* u at bp+0 */ struct {
|
||||
Fi [0]Tuint32_t
|
||||
Ff float32
|
||||
}
|
||||
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = c, e, hfx, hi, hx, hxs, k, lo, r1, sign, t, twopk, y, y1, y2, y3, v1
|
||||
*(*struct {
|
||||
Fi [0]Tuint32_t
|
||||
Ff float32
|
||||
})(unsafe.Pointer(bp)) = struct {
|
||||
Fi [0]Tuint32_t
|
||||
Ff float32
|
||||
}{}
|
||||
*(*float32)(unsafe.Pointer(bp)) = x3
|
||||
hx = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff)
|
||||
sign = Int32FromUint32(*(*Tuint32_t)(unsafe.Pointer(bp)) >> int32(31))
|
||||
/* filter out huge and non-finite argument */
|
||||
if hx >= uint32(0x4195b844) { /* if |x|>=27*ln2 */
|
||||
if hx > uint32(0x7f800000) { /* NaN */
|
||||
return x3
|
||||
}
|
||||
if sign != 0 {
|
||||
return float32(-Int32FromInt32(1))
|
||||
}
|
||||
if hx > uint32(0x42b17217) { /* x > log(FLT_MAX) */
|
||||
x3 *= Float32FromFloat32(1.7014118346046923e+38)
|
||||
return x3
|
||||
}
|
||||
}
|
||||
/* argument reduction */
|
||||
if hx > uint32(0x3eb17218) { /* if |x| > 0.5 ln2 */
|
||||
if hx < uint32(0x3F851592) { /* and |x| < 1.5 ln2 */
|
||||
if !(sign != 0) {
|
||||
hi = x3 - _ln2_hi1
|
||||
lo = _ln2_lo1
|
||||
k = int32(1)
|
||||
} else {
|
||||
hi = x3 + _ln2_hi1
|
||||
lo = -_ln2_lo1
|
||||
k = -int32(1)
|
||||
}
|
||||
} else {
|
||||
if sign != 0 {
|
||||
v1 = -Float32FromFloat32(0.5)
|
||||
} else {
|
||||
v1 = Float32FromFloat32(0.5)
|
||||
}
|
||||
k = int32(float32(_invln21*x3) + v1)
|
||||
t = float32(k)
|
||||
hi = x3 - float32(t*_ln2_hi1) /* t*ln2_hi is exact here */
|
||||
lo = Tfloat_t(t * _ln2_lo1)
|
||||
}
|
||||
x3 = hi - lo
|
||||
c = hi - x3 - lo
|
||||
} else {
|
||||
if hx < uint32(0x33000000) { /* when |x|<2**-25, return x */
|
||||
if hx < uint32(0x00800000) {
|
||||
if uint64(4) == uint64(4) {
|
||||
y = float32(x3 * x3)
|
||||
} else {
|
||||
if uint64(4) == uint64(8) {
|
||||
y1 = float64(x3 * x3)
|
||||
} else {
|
||||
y2 = float64(x3 * x3)
|
||||
}
|
||||
}
|
||||
}
|
||||
return x3
|
||||
} else {
|
||||
k = 0
|
||||
}
|
||||
}
|
||||
/* x is now in primary range */
|
||||
hfx = Tfloat_t(Float32FromFloat32(0.5) * x3)
|
||||
hxs = Tfloat_t(x3 * hfx)
|
||||
r1 = Float32FromFloat32(1) + float32(hxs*(_Q11+float32(hxs*_Q21)))
|
||||
t = Float32FromFloat32(3) - float32(r1*hfx)
|
||||
e = Tfloat_t(hxs * ((r1 - t) / (Float32FromFloat32(6) - float32(x3*t))))
|
||||
if k == 0 { /* c is 0 */
|
||||
return x3 - (float32(x3*e) - hxs)
|
||||
}
|
||||
e = float32(x3*(e-c)) - c
|
||||
e -= hxs
|
||||
/* exp(x) ~ 2^k (Xreduced - e + 1) */
|
||||
if k == -int32(1) {
|
||||
return float32(Float32FromFloat32(0.5)*(x3-e)) - Float32FromFloat32(0.5)
|
||||
}
|
||||
if k == int32(1) {
|
||||
if x3 < -Float32FromFloat32(0.25) {
|
||||
return float32(-Float32FromFloat32(2) * (e - (x3 + Float32FromFloat32(0.5))))
|
||||
}
|
||||
return Float32FromFloat32(1) + float32(Float32FromFloat32(2)*(x3-e))
|
||||
}
|
||||
*(*Tuint32_t)(unsafe.Pointer(bp)) = Uint32FromInt32((int32(0x7f) + k) << int32(23)) /* 2^k */
|
||||
twopk = *(*float32)(unsafe.Pointer(bp))
|
||||
if k < 0 || k > int32(56) { /* suffice to return exp(x)-1 */
|
||||
y3 = x3 - e + Float32FromFloat32(1)
|
||||
if k == int32(128) {
|
||||
y3 = Tfloat_t(Tfloat_t(y3*Float32FromFloat32(2)) * Float32FromFloat32(1.7014118346046923e+38))
|
||||
} else {
|
||||
y3 = Tfloat_t(y3 * twopk)
|
||||
}
|
||||
return y3 - Float32FromFloat32(1)
|
||||
}
|
||||
*(*Tuint32_t)(unsafe.Pointer(bp)) = Uint32FromInt32((int32(0x7f) - k) << int32(23)) /* 2^-k */
|
||||
if k < int32(23) {
|
||||
y3 = Tfloat_t((x3 - e + (Float32FromInt32(1) - *(*float32)(unsafe.Pointer(bp)))) * twopk)
|
||||
} else {
|
||||
y3 = Tfloat_t((x3 - (e + *(*float32)(unsafe.Pointer(bp))) + Float32FromInt32(1)) * twopk)
|
||||
}
|
||||
return y3
|
||||
}
|
||||
|
||||
func Xexpm1l(tls *TLS, x float64) (r float64) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
return Xexpm1(tls, x)
|
||||
}
|
||||
|
||||
type Tdouble_t = float64
|
||||
type Tuint32_t = uint32
|
||||
type Tuint64_t = uint64
|
||||
|
||||
var _o_threshold = float64(709.782712893384) /* 0x40862E42, 0xFEFA39EF */
|
||||
var _ln2_hi = float64(0.6931471803691238) /* 0x3fe62e42, 0xfee00000 */
|
||||
var _ln2_lo = float64(1.9082149292705877e-10) /* 0x3dea39ef, 0x35793c76 */
|
||||
var _invln2 = float64(1.4426950408889634) /* 0x3ff71547, 0x652b82fe */
|
||||
/* Scaled Q's: Qn_here = 2**n * Qn_above, for R(2*z) where z = hxs = x*x/2: */
|
||||
var _Q1 = -Float64FromFloat64(0.03333333333333313) /* BFA11111 111110F4 */
|
||||
var _Q2 = float64(0.0015873015872548146) /* 3F5A01A0 19FE5585 */
|
||||
var _Q3 = -Float64FromFloat64(7.93650757867488e-05) /* BF14CE19 9EAADBB7 */
|
||||
var _Q4 = float64(4.008217827329362e-06) /* 3ED0CFCA 86E65239 */
|
||||
var _Q5 = -Float64FromFloat64(2.0109921818362437e-07) /* BE8AFDB7 6E09C32D */
|
||||
|
||||
var _ln2_hi2 = float64(0.6931471803691238) /* 3fe62e42 fee00000 */
|
||||
var _ln2_lo2 = float64(1.9082149292705877e-10) /* 3dea39ef 35793c76 */
|
||||
var _Lg12 = float64(0.6666666666666735) /* 3FE55555 55555593 */
|
||||
var _Lg22 = float64(0.3999999999940942) /* 3FD99999 9997FA04 */
|
||||
var _Lg32 = float64(0.2857142874366239) /* 3FD24924 94229359 */
|
||||
var _Lg42 = float64(0.22222198432149784) /* 3FCC71C5 1D8E78AF */
|
||||
var _Lg51 = float64(0.1818357216161805) /* 3FC74664 96CB03DE */
|
||||
var _Lg61 = float64(0.15313837699209373) /* 3FC39A09 D078C69F */
|
||||
var _Lg71 = float64(0.14798198605116586) /* 3FC2F112 DF3E5244 */
|
||||
|
||||
func Xlog1p(tls *TLS, x3 float64) (r float64) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
bp := tls.Alloc(16)
|
||||
defer tls.Free(16)
|
||||
var R, c, dk, f, hfsq, s, t1, t2, w, z Tdouble_t
|
||||
var hu, hx Tuint32_t
|
||||
var k int32
|
||||
var y float32
|
||||
var y1, y2, v1 float64
|
||||
var _ /* u at bp+0 */ struct {
|
||||
Fi [0]Tuint64_t
|
||||
Ff float64
|
||||
}
|
||||
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = R, c, dk, f, hfsq, hu, hx, k, s, t1, t2, w, y, y1, y2, z, v1
|
||||
*(*struct {
|
||||
Fi [0]Tuint64_t
|
||||
Ff float64
|
||||
})(unsafe.Pointer(bp)) = struct {
|
||||
Fi [0]Tuint64_t
|
||||
Ff float64
|
||||
}{}
|
||||
*(*float64)(unsafe.Pointer(bp)) = x3
|
||||
hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32))
|
||||
k = int32(1)
|
||||
if hx < uint32(0x3fda827a) || hx>>int32(31) != 0 { /* 1+x < sqrt(2)+ */
|
||||
if hx >= uint32(0xbff00000) { /* x <= -1.0 */
|
||||
if x3 == float64(-Int32FromInt32(1)) {
|
||||
return x3 / float64(0)
|
||||
} /* log1p(-1) = -inf */
|
||||
return (x3 - x3) / float64(0) /* log1p(x<-1) = NaN */
|
||||
}
|
||||
if hx<<int32(1) < Uint32FromInt32(Int32FromInt32(0x3ca00000)<<Int32FromInt32(1)) { /* |x| < 2**-53 */
|
||||
/* underflow if subnormal */
|
||||
if hx&uint32(0x7ff00000) == uint32(0) {
|
||||
if uint64(4) == uint64(4) {
|
||||
y = float32(x3)
|
||||
} else {
|
||||
if uint64(4) == uint64(8) {
|
||||
y1 = float64(float32(x3))
|
||||
} else {
|
||||
y2 = float64(float32(x3))
|
||||
}
|
||||
}
|
||||
}
|
||||
return x3
|
||||
}
|
||||
if hx <= uint32(0xbfd2bec4) { /* sqrt(2)/2- <= 1+x < sqrt(2)+ */
|
||||
k = 0
|
||||
c = Float64FromInt32(0)
|
||||
f = x3
|
||||
}
|
||||
} else {
|
||||
if hx >= uint32(0x7ff00000) {
|
||||
return x3
|
||||
}
|
||||
}
|
||||
if k != 0 {
|
||||
*(*float64)(unsafe.Pointer(bp)) = Float64FromInt32(1) + x3
|
||||
hu = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32))
|
||||
hu += Uint32FromInt32(Int32FromInt32(0x3ff00000) - Int32FromInt32(0x3fe6a09e))
|
||||
k = Int32FromUint32(hu>>Int32FromInt32(20)) - int32(0x3ff)
|
||||
/* correction term ~ log(1+x)-log(u), avoid underflow in c/u */
|
||||
if k < int32(54) {
|
||||
if k >= int32(2) {
|
||||
v1 = Float64FromInt32(1) - (*(*float64)(unsafe.Pointer(bp)) - x3)
|
||||
} else {
|
||||
v1 = x3 - (*(*float64)(unsafe.Pointer(bp)) - Float64FromInt32(1))
|
||||
}
|
||||
c = v1
|
||||
c /= *(*float64)(unsafe.Pointer(bp))
|
||||
} else {
|
||||
c = Float64FromInt32(0)
|
||||
}
|
||||
/* reduce u into [sqrt(2)/2, sqrt(2)] */
|
||||
hu = hu&uint32(0x000fffff) + uint32(0x3fe6a09e)
|
||||
*(*Tuint64_t)(unsafe.Pointer(bp)) = uint64(hu)<<int32(32) | *(*Tuint64_t)(unsafe.Pointer(bp))&uint64(0xffffffff)
|
||||
f = *(*float64)(unsafe.Pointer(bp)) - Float64FromInt32(1)
|
||||
}
|
||||
hfsq = Tdouble_t(float64(float64(0.5)*f) * f)
|
||||
s = f / (Float64FromFloat64(2) + f)
|
||||
z = Tdouble_t(s * s)
|
||||
w = Tdouble_t(z * z)
|
||||
t1 = Tdouble_t(w * (_Lg22 + float64(w*(_Lg42+float64(w*_Lg61)))))
|
||||
t2 = Tdouble_t(z * (_Lg12 + float64(w*(_Lg32+float64(w*(_Lg51+float64(w*_Lg71)))))))
|
||||
R = t2 + t1
|
||||
dk = float64(k)
|
||||
return Tdouble_t(s*(hfsq+R)) + (Tdouble_t(dk*_ln2_lo2) + c) - hfsq + f + Tdouble_t(dk*_ln2_hi2)
|
||||
}
|
||||
|
||||
var _ln2_hi3 = float32(0.69313812256) /* 0x3f317180 */
|
||||
var _ln2_lo3 = float32(9.0580006145e-06) /* 0x3717f7d1 */
|
||||
/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
|
||||
var _Lg13 = float32(0.6666666269302368) /* 0.66666662693 */
|
||||
var _Lg23 = float32(0.40000972151756287) /* 0.40000972152 */
|
||||
var _Lg33 = float32(0.2849878668785095) /* 0.28498786688 */
|
||||
var _Lg43 = float32(0.24279078841209412) /* 0.24279078841 */
|
||||
|
||||
func Xlog1pf(tls *TLS, x3 float32) (r float32) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x3=%v, (%v:)", tls, x3, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
bp := tls.Alloc(16)
|
||||
defer tls.Free(16)
|
||||
var R, c, dk, f, hfsq, s, t1, t2, w, z Tfloat_t
|
||||
var iu, ix Tuint32_t
|
||||
var k int32
|
||||
var y, v1 float32
|
||||
var y1, y2 float64
|
||||
var _ /* u at bp+0 */ struct {
|
||||
Fi [0]Tuint32_t
|
||||
Ff float32
|
||||
}
|
||||
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = R, c, dk, f, hfsq, iu, ix, k, s, t1, t2, w, y, y1, y2, z, v1
|
||||
*(*struct {
|
||||
Fi [0]Tuint32_t
|
||||
Ff float32
|
||||
})(unsafe.Pointer(bp)) = struct {
|
||||
Fi [0]Tuint32_t
|
||||
Ff float32
|
||||
}{}
|
||||
*(*float32)(unsafe.Pointer(bp)) = x3
|
||||
ix = *(*Tuint32_t)(unsafe.Pointer(bp))
|
||||
k = int32(1)
|
||||
if ix < uint32(0x3ed413d0) || ix>>int32(31) != 0 { /* 1+x < sqrt(2)+ */
|
||||
if ix >= uint32(0xbf800000) { /* x <= -1.0 */
|
||||
if x3 == float32(-Int32FromInt32(1)) {
|
||||
return x3 / Float32FromFloat32(0)
|
||||
} /* log1p(-1)=+inf */
|
||||
return (x3 - x3) / Float32FromFloat32(0) /* log1p(x<-1)=NaN */
|
||||
}
|
||||
if ix<<int32(1) < Uint32FromInt32(Int32FromInt32(0x33800000)<<Int32FromInt32(1)) { /* |x| < 2**-24 */
|
||||
/* underflow if subnormal */
|
||||
if ix&uint32(0x7f800000) == uint32(0) {
|
||||
if uint64(4) == uint64(4) {
|
||||
y = float32(x3 * x3)
|
||||
} else {
|
||||
if uint64(4) == uint64(8) {
|
||||
y1 = float64(x3 * x3)
|
||||
} else {
|
||||
y2 = float64(x3 * x3)
|
||||
}
|
||||
}
|
||||
}
|
||||
return x3
|
||||
}
|
||||
if ix <= uint32(0xbe95f619) { /* sqrt(2)/2- <= 1+x < sqrt(2)+ */
|
||||
k = 0
|
||||
c = Float32FromInt32(0)
|
||||
f = x3
|
||||
}
|
||||
} else {
|
||||
if ix >= uint32(0x7f800000) {
|
||||
return x3
|
||||
}
|
||||
}
|
||||
if k != 0 {
|
||||
*(*float32)(unsafe.Pointer(bp)) = Float32FromInt32(1) + x3
|
||||
iu = *(*Tuint32_t)(unsafe.Pointer(bp))
|
||||
iu += Uint32FromInt32(Int32FromInt32(0x3f800000) - Int32FromInt32(0x3f3504f3))
|
||||
k = Int32FromUint32(iu>>Int32FromInt32(23)) - int32(0x7f)
|
||||
/* correction term ~ log(1+x)-log(u), avoid underflow in c/u */
|
||||
if k < int32(25) {
|
||||
if k >= int32(2) {
|
||||
v1 = Float32FromInt32(1) - (*(*float32)(unsafe.Pointer(bp)) - x3)
|
||||
} else {
|
||||
v1 = x3 - (*(*float32)(unsafe.Pointer(bp)) - Float32FromInt32(1))
|
||||
}
|
||||
c = v1
|
||||
c /= *(*float32)(unsafe.Pointer(bp))
|
||||
} else {
|
||||
c = Float32FromInt32(0)
|
||||
}
|
||||
/* reduce u into [sqrt(2)/2, sqrt(2)] */
|
||||
iu = iu&uint32(0x007fffff) + uint32(0x3f3504f3)
|
||||
*(*Tuint32_t)(unsafe.Pointer(bp)) = iu
|
||||
f = *(*float32)(unsafe.Pointer(bp)) - Float32FromInt32(1)
|
||||
}
|
||||
s = f / (Float32FromFloat32(2) + f)
|
||||
z = Tfloat_t(s * s)
|
||||
w = Tfloat_t(z * z)
|
||||
t1 = Tfloat_t(w * (_Lg23 + float32(w*_Lg43)))
|
||||
t2 = Tfloat_t(z * (_Lg13 + float32(w*_Lg33)))
|
||||
R = t2 + t1
|
||||
hfsq = Tfloat_t(float32(Float32FromFloat32(0.5)*f) * f)
|
||||
dk = float32(k)
|
||||
return Tfloat_t(s*(hfsq+R)) + (Tfloat_t(dk*_ln2_lo3) + c) - hfsq + f + Tfloat_t(dk*_ln2_hi3)
|
||||
}
|
||||
|
||||
func Xlog1pl(tls *TLS, x float64) (r float64) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
return Xlog1p(tls, x)
|
||||
}
|
||||
|
||||
type Tfloat_t = float32
|
||||
|
||||
var _B1 = uint32(715094163) /* B1 = (1023-1023/3-0.03306235651)*2**20 */
|
||||
var _B2 = uint32(696219795) /* B2 = (1023-1023/3-54/3-0.03306235651)*2**20 */
|
||||
|
||||
// C documentation
|
||||
//
|
||||
// /* |1/cbrt(x) - p(x)| < 2**-23.5 (~[-7.93e-8, 7.929e-8]). */
|
||||
|
||||
var _P0 = float64(1.87595182427177) /* 0x3ffe03e6, 0x0f61e692 */
|
||||
var _P1 = -Float64FromFloat64(1.8849797954337717) /* 0xbffe28e0, 0x92f02420 */
|
||||
var _P2 = float64(1.6214297201053545) /* 0x3ff9f160, 0x4a49d6c2 */
|
||||
var _P3 = -Float64FromFloat64(0.758397934778766) /* 0xbfe844cb, 0xbee751d9 */
|
||||
var _P4 = float64(0.14599619288661245) /* 0x3fc2b000, 0xd4e4edd7 */
|
||||
|
||||
func Xcbrt(tls *TLS, x float64) (r1 float64) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
defer func() { trc("-> %v", r1) }()
|
||||
}
|
||||
bp := tls.Alloc(16)
|
||||
defer tls.Free(16)
|
||||
var hx Tuint32_t
|
||||
var r, s, t, w Tdouble_t
|
||||
var p1 uintptr
|
||||
var _ /* u at bp+0 */ struct {
|
||||
Fi [0]Tuint64_t
|
||||
Ff float64
|
||||
}
|
||||
_, _, _, _, _, _ = hx, r, s, t, w, p1
|
||||
*(*struct {
|
||||
Fi [0]Tuint64_t
|
||||
Ff float64
|
||||
})(unsafe.Pointer(bp)) = struct {
|
||||
Fi [0]Tuint64_t
|
||||
Ff float64
|
||||
}{}
|
||||
*(*float64)(unsafe.Pointer(bp)) = x
|
||||
hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32) & uint64(0x7fffffff))
|
||||
if hx >= uint32(0x7ff00000) { /* cbrt(NaN,INF) is itself */
|
||||
return x + x
|
||||
}
|
||||
/*
|
||||
* Rough cbrt to 5 bits:
|
||||
* cbrt(2**e*(1+m) ~= 2**(e/3)*(1+(e%3+m)/3)
|
||||
* where e is integral and >= 0, m is real and in [0, 1), and "/" and
|
||||
* "%" are integer division and modulus with rounding towards minus
|
||||
* infinity. The RHS is always >= the LHS and has a maximum relative
|
||||
* error of about 1 in 16. Adding a bias of -0.03306235651 to the
|
||||
* (e%3+m)/3 term reduces the error to about 1 in 32. With the IEEE
|
||||
* floating point representation, for finite positive normal values,
|
||||
* ordinary integer divison of the value in bits magically gives
|
||||
* almost exactly the RHS of the above provided we first subtract the
|
||||
* exponent bias (1023 for doubles) and later add it back. We do the
|
||||
* subtraction virtually to keep e >= 0 so that ordinary integer
|
||||
* division rounds towards minus infinity; this is also efficient.
|
||||
*/
|
||||
if hx < uint32(0x00100000) { /* zero or subnormal? */
|
||||
*(*float64)(unsafe.Pointer(bp)) = float64(x * float64(1.8014398509481984e+16))
|
||||
hx = uint32(*(*Tuint64_t)(unsafe.Pointer(bp)) >> int32(32) & uint64(0x7fffffff))
|
||||
if hx == uint32(0) {
|
||||
return x
|
||||
} /* cbrt(0) is itself */
|
||||
hx = hx/uint32(3) + _B2
|
||||
} else {
|
||||
hx = hx/uint32(3) + _B1
|
||||
}
|
||||
p1 = bp
|
||||
*(*Tuint64_t)(unsafe.Pointer(p1)) = Tuint64_t(*(*Tuint64_t)(unsafe.Pointer(p1)) & (Uint64FromUint64(1) << Int32FromInt32(63)))
|
||||
*(*Tuint64_t)(unsafe.Pointer(bp)) |= uint64(hx) << int32(32)
|
||||
t = *(*float64)(unsafe.Pointer(bp))
|
||||
/*
|
||||
* New cbrt to 23 bits:
|
||||
* cbrt(x) = t*cbrt(x/t**3) ~= t*P(t**3/x)
|
||||
* where P(r) is a polynomial of degree 4 that approximates 1/cbrt(r)
|
||||
* to within 2**-23.5 when |r - 1| < 1/10. The rough approximation
|
||||
* has produced t such than |t/cbrt(x) - 1| ~< 1/32, and cubing this
|
||||
* gives us bounds for r = t**3/x.
|
||||
*
|
||||
* Try to optimize for parallel evaluation as in __tanf.c.
|
||||
*/
|
||||
r = Tdouble_t(Tdouble_t(t*t) * (t / x))
|
||||
t = Tdouble_t(t * (_P0 + float64(r*(_P1+float64(r*_P2))) + float64(Tdouble_t(Tdouble_t(r*r)*r)*(_P3+float64(r*_P4)))))
|
||||
/*
|
||||
* Round t away from zero to 23 bits (sloppily except for ensuring that
|
||||
* the result is larger in magnitude than cbrt(x) but not much more than
|
||||
* 2 23-bit ulps larger). With rounding towards zero, the error bound
|
||||
* would be ~5/6 instead of ~4/6. With a maximum error of 2 23-bit ulps
|
||||
* in the rounded t, the infinite-precision error in the Newton
|
||||
* approximation barely affects third digit in the final error
|
||||
* 0.667; the error in the rounded t can be up to about 3 23-bit ulps
|
||||
* before the final error is larger than 0.667 ulps.
|
||||
*/
|
||||
*(*float64)(unsafe.Pointer(bp)) = t
|
||||
*(*Tuint64_t)(unsafe.Pointer(bp)) = uint64(*(*Tuint64_t)(unsafe.Pointer(bp))+Uint64FromUint32(0x80000000)) & uint64(0xffffffffc0000000)
|
||||
t = *(*float64)(unsafe.Pointer(bp))
|
||||
/* one step Newton iteration to 53 bits with error < 0.667 ulps */
|
||||
s = Tdouble_t(t * t) /* t*t is exact */
|
||||
r = x / s /* error <= 0.5 ulps; |r| < |t| */
|
||||
w = t + t /* t+t is exact */
|
||||
r = (r - t) / (w + r) /* r-t is exact; w+r ~= 3*t */
|
||||
t = t + Tdouble_t(t*r) /* error <= 0.5 + 0.5/3 + epsilon */
|
||||
return t
|
||||
}
|
||||
|
||||
var _B11 = uint32(709958130) /* B1 = (127-127.0/3-0.03306235651)*2**23 */
|
||||
var _B21 = uint32(642849266) /* B2 = (127-127.0/3-24/3-0.03306235651)*2**23 */
|
||||
|
||||
func Xcbrtf(tls *TLS, x float32) (r1 float32) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
defer func() { trc("-> %v", r1) }()
|
||||
}
|
||||
bp := tls.Alloc(16)
|
||||
defer tls.Free(16)
|
||||
var T, r Tdouble_t
|
||||
var hx Tuint32_t
|
||||
var _ /* u at bp+0 */ struct {
|
||||
Fi [0]Tuint32_t
|
||||
Ff float32
|
||||
}
|
||||
_, _, _ = T, hx, r
|
||||
*(*struct {
|
||||
Fi [0]Tuint32_t
|
||||
Ff float32
|
||||
})(unsafe.Pointer(bp)) = struct {
|
||||
Fi [0]Tuint32_t
|
||||
Ff float32
|
||||
}{}
|
||||
*(*float32)(unsafe.Pointer(bp)) = x
|
||||
hx = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff)
|
||||
if hx >= uint32(0x7f800000) { /* cbrt(NaN,INF) is itself */
|
||||
return x + x
|
||||
}
|
||||
/* rough cbrt to 5 bits */
|
||||
if hx < uint32(0x00800000) { /* zero or subnormal? */
|
||||
if hx == uint32(0) {
|
||||
return x
|
||||
} /* cbrt(+-0) is itself */
|
||||
*(*float32)(unsafe.Pointer(bp)) = float32(x * Float32FromFloat32(1.6777216e+07))
|
||||
hx = *(*Tuint32_t)(unsafe.Pointer(bp)) & uint32(0x7fffffff)
|
||||
hx = hx/uint32(3) + _B21
|
||||
} else {
|
||||
hx = hx/uint32(3) + _B11
|
||||
}
|
||||
*(*Tuint32_t)(unsafe.Pointer(bp)) &= uint32(0x80000000)
|
||||
*(*Tuint32_t)(unsafe.Pointer(bp)) |= hx
|
||||
/*
|
||||
* First step Newton iteration (solving t*t-x/t == 0) to 16 bits. In
|
||||
* double precision so that its terms can be arranged for efficiency
|
||||
* without causing overflow or underflow.
|
||||
*/
|
||||
T = float64(*(*float32)(unsafe.Pointer(bp)))
|
||||
r = Tdouble_t(Tdouble_t(T*T) * T)
|
||||
T = Tdouble_t(T*(float64(x)+float64(x)+r)) / (float64(x) + r + r)
|
||||
/*
|
||||
* Second step Newton iteration to 47 bits. In double precision for
|
||||
* efficiency and accuracy.
|
||||
*/
|
||||
r = Tdouble_t(Tdouble_t(T*T) * T)
|
||||
T = Tdouble_t(T*(float64(x)+float64(x)+r)) / (float64(x) + r + r)
|
||||
/* rounding to 24 bits is perfect in round-to-nearest mode */
|
||||
return float32(T)
|
||||
}
|
||||
|
||||
func Xcbrtl(tls *TLS, x float64) (r float64) {
|
||||
if __ccgo_strace {
|
||||
trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
|
||||
defer func() { trc("-> %v", r) }()
|
||||
}
|
||||
return Xcbrt(tls, x)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue