optim/onn/float.py

20 lines
322 B
Python
Raw Normal View History

2018-01-21 14:04:25 -08:00
import numpy as np
_f = np.float32
2018-01-22 11:40:36 -08:00
2018-01-21 14:04:25 -08:00
def _check(a):
assert isinstance(a, np.ndarray) or type(a) == _f, type(a)
assert a.dtype == _f, a.dtype
return a
2018-01-22 11:40:36 -08:00
2018-01-21 14:04:25 -08:00
_0 = _f(0)
_1 = _f(1)
_2 = _f(2)
_inv2 = _f(1/2)
_sqrt2 = _f(np.sqrt(2))
_invsqrt2 = _f(1/np.sqrt(2))
2018-03-22 04:02:17 -07:00
_invsqrt2pi = _f(1/np.sqrt(2 * np.pi))
2018-01-21 14:04:25 -08:00
_pi = _f(np.pi)