diff options
author | Travis Oliphant <oliphant@enthought.com> | 2007-12-15 18:54:52 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2007-12-15 18:54:52 +0000 |
commit | e76b5fa6896c09257181675bbf4cf47789d32927 (patch) | |
tree | 7174e22c68fc47df61e745ee18625ee9f4f5b88c /numpy/lib/scimath.py | |
parent | 02ee35a7e1c722a1cdac8f3a60fe9ef7aa079a37 (diff) | |
download | numpy-e76b5fa6896c09257181675bbf4cf47789d32927.tar.gz |
Create a branch for io work in NumPy
Diffstat (limited to 'numpy/lib/scimath.py')
-rw-r--r-- | numpy/lib/scimath.py | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/numpy/lib/scimath.py b/numpy/lib/scimath.py deleted file mode 100644 index c15f254a3..000000000 --- a/numpy/lib/scimath.py +++ /dev/null @@ -1,86 +0,0 @@ -""" -Wrapper functions to more user-friendly calling of certain math functions -whose output data-type is different than the input data-type in certain -domains of the input. -""" - -__all__ = ['sqrt', 'log', 'log2', 'logn','log10', 'power', 'arccos', - 'arcsin', 'arctanh'] - -import numpy.core.numeric as nx -import numpy.core.numerictypes as nt -from numpy.core.numeric import asarray, any -from numpy.lib.type_check import isreal - - -#__all__.extend([key for key in dir(nx.umath) -# if key[0] != '_' and key not in __all__]) - -_ln2 = nx.log(2.0) - -def _tocomplex(arr): - if isinstance(arr.dtype, (nt.single, nt.byte, nt.short, nt.ubyte, - nt.ushort)): - return arr.astype(nt.csingle) - else: - return arr.astype(nt.cdouble) - -def _fix_real_lt_zero(x): - x = asarray(x) - if any(isreal(x) & (x<0)): - x = _tocomplex(x) - return x - -def _fix_int_lt_zero(x): - x = asarray(x) - if any(isreal(x) & (x < 0)): - x = x * 1.0 - return x - -def _fix_real_abs_gt_1(x): - x = asarray(x) - if any(isreal(x) & (abs(x)>1)): - x = _tocomplex(x) - return x - -def sqrt(x): - x = _fix_real_lt_zero(x) - return nx.sqrt(x) - -def log(x): - x = _fix_real_lt_zero(x) - return nx.log(x) - -def log10(x): - x = _fix_real_lt_zero(x) - return nx.log10(x) - -def logn(n, x): - """ Take log base n of x. - """ - x = _fix_real_lt_zero(x) - n = _fix_real_lt_zero(n) - return nx.log(x)/nx.log(n) - -def log2(x): - """ Take log base 2 of x. - """ - x = _fix_real_lt_zero(x) - return nx.log(x)/_ln2 - -def power(x, p): - x = _fix_real_lt_zero(x) - p = _fix_int_lt_zero(p) - return nx.power(x, p) - -def arccos(x): - x = _fix_real_abs_gt_1(x) - return nx.arccos(x) - -def arcsin(x): - x = _fix_real_abs_gt_1(x) - return nx.arcsin(x) - -def arctanh(x): - x = _fix_real_abs_gt_1(x) - return nx.arctanh(x) |