forked from gorgonia/gorgonia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
math_nooptim.go
40 lines (31 loc) · 902 Bytes
/
math_nooptim.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// +build !fastmath
package gorgonia
// this file holds the non-hacky version of anything that is in the math_fast.go file
import "math"
// SetOptimizationLevel sets the fast math optimization level. By default, fast math is turned off,
// and this function is a no-op.
//
// Use the `fastmath` build tag to use fast math
func SetOptimizationLevel(i int) {}
func _inversef32(x float32) float32 { return float32(1) / x }
func _inversef64(x float64) float64 { return float64(1) / x }
func _tanhf32(x float32) float32 { return float32(math.Tanh(float64(x))) }
func _tanhf64(x float64) float64 { return math.Tanh(x) }
func _sigmoidf64(x float64) float64 {
if x < -709 {
return 0
}
if x > 19 {
return 1
}
return 1.0 / (1.0 + math.Exp(-x))
}
func _sigmoidf32(x float32) float32 {
if x < -88 {
return 0
}
if x > 15 {
return 1
}
return float32(1.0 / (1.0 + math.Exp(float64(-x))))
}