Beispiel #1
0
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
Beispiel #2
0
def tanh(a):
    '''Hyperbolic tangent of input'''
    return _maths.tanh(a)
Beispiel #3
0
def floor_divide(a, b):
    '''Calculate largest integers smaller or equal to division'''
    return _maths.floorDivide(a, b)
Beispiel #4
0
def divide(a, b):
    '''Divide one array-like object by another'''
    return _maths.divide(a, b)
Beispiel #5
0
def subtract(a, b):
    '''Subtract one array-like object from another'''
    return _maths.subtract(a, b)
Beispiel #6
0
def diff(a, order=1, axis=-1):
    '''Difference of input'''
    return _maths.difference(a, order, axis)
Beispiel #7
0
def negative(a):
    '''Negate input'''
    return _maths.negative(a)
Beispiel #8
0
def deg2rad(a):
    '''Convert from degree to radian'''
    return _maths.toRadians(a)
Beispiel #9
0
def exp(a):
    '''Exponential of input'''
    return _maths.exp(a)
Beispiel #10
0
def log1p(x):
    '''Natural logarithm of (x+1)'''
    return _maths.log1p(x)
Beispiel #11
0
def log10(a):
    '''Logarithm of input to base 10'''
    return _maths.log10(a)
Beispiel #12
0
def log2(a):
    '''Logarithm of input to base 2'''
    return _maths.log2(a)
Beispiel #13
0
def log(a):
    '''Natural logarithm of input'''
    return _maths.log(a)
Beispiel #14
0
def arctanh(a):
    '''Inverse hyperbolic tangent of input'''
    return _maths.arctanh(a)
Beispiel #15
0
def arccosh(a):
    '''Inverse hyperbolic cosine of input'''
    return _maths.arccosh(a)
Beispiel #16
0
def rint(a):
    '''Round elements of input to nearest integers'''
    return _maths.rint(a)
Beispiel #17
0
def rad2deg(a):
    '''Convert from radian to degree'''
    return _maths.toDegrees(a)
Beispiel #18
0
def expm1(x):
    '''Exponential of (x-1)'''
    return _maths.expm1(x)
Beispiel #19
0
def sign(a):
    '''Sign of input, indicated by -1 for negative, +1 for positive and 0 for zero'''
    return _maths.signum(a)
Beispiel #20
0
def sqrt(a):
    '''Square root of input'''
    return _maths.sqrt(a)
Beispiel #21
0
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)
Beispiel #22
0
def cbrt(a):
    '''Cube root of input'''
    return _maths.cbrt(a)
Beispiel #23
0
def add(a, b):
    '''Add two array-like objects together'''
    return _maths.add(a, b)
Beispiel #24
0
def square(a):
    '''Square of input'''
    return _maths.square(a)
Beispiel #25
0
def multiply(a, b):
    '''Multiply two array-like objects together'''
    return _maths.multiply(a, b)
Beispiel #26
0
def power(a, p):
    '''Input raised to given power'''
    return _maths.power(a, p)
Beispiel #27
0
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)
Beispiel #28
0
def floor(a):
    '''Largest integer smaller or equal to input'''
    return _maths.floor(a)
Beispiel #29
0
def remainder(a, b):
    '''Return remainder of division of inputs'''
    return _maths.remainder(a, b)
Beispiel #30
0
def ceil(a):
    '''Smallest integer greater or equal to input'''
    return _maths.ceil(a)