def gradient(f, *varargs): '''Gradient of array f -- array *varargs -- 0, 1, N scalars for sample distance, or (1 or N-d) datasets for sample points ''' if varargs is None or len(varargs) == 0: g = _maths.gradient(f) else: # check for scalars, etc from jycore import arange as _ar vl = len(varargs) nd = f.getRank() if vl == 1: varargs = [varargs[0]]*nd vl = nd if vl != nd: raise ValueError, "Number of arguments must be 0, 1 or rank of f" xlist = [] for i in range(vl): x = varargs[i] xlist.append(x if isinstance(x, _ads) else (_ar(f.shape[i])*x)._jdataset()) g = _maths.gradient(f, xlist) if len(g) == 1: return g[0] return g
def tanh(a): '''Hyperbolic tangent of input''' return _maths.tanh(a)
def floor_divide(a, b): '''Calculate largest integers smaller or equal to division''' return _maths.floorDivide(a, b)
def divide(a, b): '''Divide one array-like object by another''' return _maths.divide(a, b)
def subtract(a, b): '''Subtract one array-like object from another''' return _maths.subtract(a, b)
def diff(a, order=1, axis=-1): '''Difference of input''' return _maths.difference(a, order, axis)
def negative(a): '''Negate input''' return _maths.negative(a)
def deg2rad(a): '''Convert from degree to radian''' return _maths.toRadians(a)
def exp(a): '''Exponential of input''' return _maths.exp(a)
def log1p(x): '''Natural logarithm of (x+1)''' return _maths.log1p(x)
def log10(a): '''Logarithm of input to base 10''' return _maths.log10(a)
def log2(a): '''Logarithm of input to base 2''' return _maths.log2(a)
def log(a): '''Natural logarithm of input''' return _maths.log(a)
def arctanh(a): '''Inverse hyperbolic tangent of input''' return _maths.arctanh(a)
def arccosh(a): '''Inverse hyperbolic cosine of input''' return _maths.arccosh(a)
def rint(a): '''Round elements of input to nearest integers''' return _maths.rint(a)
def rad2deg(a): '''Convert from radian to degree''' return _maths.toDegrees(a)
def expm1(x): '''Exponential of (x-1)''' return _maths.expm1(x)
def sign(a): '''Sign of input, indicated by -1 for negative, +1 for positive and 0 for zero''' return _maths.signum(a)
def sqrt(a): '''Square root of input''' return _maths.sqrt(a)
def clip(a, a_min, a_max): '''Clip input to given bounds (replace NaNs with midpoint of bounds)''' return _maths.clip(a, a_min, a_max)
def cbrt(a): '''Cube root of input''' return _maths.cbrt(a)
def add(a, b): '''Add two array-like objects together''' return _maths.add(a, b)
def square(a): '''Square of input''' return _maths.square(a)
def multiply(a, b): '''Multiply two array-like objects together''' return _maths.multiply(a, b)
def power(a, p): '''Input raised to given power''' return _maths.power(a, p)
def dividez(a, b): '''Divide one array-like object by another with items that are zero divisors set to zero''' return _maths.dividez(a, b)
def floor(a): '''Largest integer smaller or equal to input''' return _maths.floor(a)
def remainder(a, b): '''Return remainder of division of inputs''' return _maths.remainder(a, b)
def ceil(a): '''Smallest integer greater or equal to input''' return _maths.ceil(a)