예제 #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, _ds) else (_ar(f.shape[i])*x)._jdataset())
        g = _maths.gradient(f, xlist)

    if len(g) == 1:
        return g[0]
    return g
예제 #2
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, _ds) else (_ar(f.shape[i]) *
                                                       x)._jdataset())
        g = _maths.gradient(f, xlist)

    if len(g) == 1:
        return g[0]
    return g
예제 #3
0
def interp(x, xp, fp, left=None, right=None):
    '''Linearly interpolate'''
    x = _asarray(x)
        
    xp = _asarray(xp)
    fp = _asarray(fp)
    if left is None:
        left = fp[0]
    if right is None:
        right = fp[-1]
    r = _asarray(_maths.interpolate(xp._jdataset(), fp._jdataset(), x._jdataset(), left, right))
    if x.ndim == 0:
        return r.item()
    return r
예제 #4
0
def interp(x, xp, fp, left=None, right=None):
    '''Linearly interpolate'''
    x = _asarray(x)

    xp = _asarray(xp)
    fp = _asarray(fp)
    if left is None:
        left = fp[0]
    if right is None:
        right = fp[-1]
    r = _asarray(
        _maths.interpolate(xp._jdataset(), fp._jdataset(), x._jdataset(), left,
                           right))
    if x.ndim == 0:
        return r.item()
    return r
예제 #5
0
def hypot(a, b, out=None):
    '''Hypotenuse of triangle of given sides'''
    return _maths.hypot(a, b, out)
예제 #6
0
def clip(a, a_min, a_max, out=None):
    '''Clip input to given bounds (replace NaNs with midpoint of bounds)'''
    return _maths.clip(a, a_min, a_max, out)
예제 #7
0
def cosh(a, out=None):
    '''Hyperbolic cosine of input'''
    return _maths.cosh(a, out)
예제 #8
0
def floor(a, out=None):
    '''Largest integer smaller or equal to input'''
    return _maths.floor(a, out)
예제 #9
0
def rad2deg(a, out=None):
    '''Convert from radian to degree'''
    return _maths.toDegrees(a, out)
예제 #10
0
def log(a, out=None):
    '''Natural logarithm of input'''
    return _maths.log(a, out)
예제 #11
0
def expm1(x, out=None):
    '''Exponential of (x-1)'''
    return _maths.expm1(x, out)
예제 #12
0
def log1p(x, out=None):
    '''Natural logarithm of (x+1)'''
    return _maths.log1p(x, out)
예제 #13
0
def exp(a, out=None):
    '''Exponential of input'''
    return _maths.exp(a, out)
예제 #14
0
def log(a, out=None):
    '''Natural logarithm of input'''
    return _maths.log(a, out)
예제 #15
0
def log10(a, out=None):
    '''Logarithm of input to base 10'''
    return _maths.log10(a, out)
예제 #16
0
def arctanh(a, out=None):
    '''Inverse hyperbolic tangent of input'''
    return _maths.arctanh(a, out)
예제 #17
0
def arccosh(a, out=None):
    '''Inverse hyperbolic cosine of input'''
    return _maths.arccosh(a, out)
예제 #18
0
def tanh(a, out=None):
    '''Hyperbolic tangent of input'''
    return _maths.tanh(a, out)
예제 #19
0
def cosh(a, out=None):
    '''Hyperbolic cosine of input'''
    return _maths.cosh(a, out)
예제 #20
0
def expm1(x, out=None):
    '''Exponential of (x-1)'''
    return _maths.expm1(x, out)
예제 #21
0
def arccosh(a, out=None):
    '''Inverse hyperbolic cosine of input'''
    return _maths.arccosh(a, out)
예제 #22
0
def sqrt(a, out=None):
    '''Square root of input'''
    return _maths.sqrt(a, out)
예제 #23
0
def log1p(x, out=None):
    '''Natural logarithm of (x+1)'''
    return _maths.log1p(x, out)
예제 #24
0
def square(a, out=None):
    '''Square of input'''
    return _maths.square(a, out)
예제 #25
0
def square(a, out=None):
    '''Square of input'''
    return _maths.square(a, out)
예제 #26
0
def power(a, p, out=None):
    '''Input raised to given power'''
    return _maths.power(a, p, out)
예제 #27
0
def rint(a, out=None):
    '''Round elements of input to nearest integers'''
    return _maths.rint(a, out)
예제 #28
0
def floor(a, out=None):
    '''Largest integer smaller or equal to input'''
    return _maths.floor(a, out)
예제 #29
0
def sign(a, out=None):
    '''Sign of input, indicated by -1 for negative, +1 for positive and 0 for zero'''
    return _maths.signum(a, out)
예제 #30
0
def ceil(a, out=None):
    '''Smallest integer greater or equal to input'''
    return _maths.ceil(a, out)
예제 #31
0
def diff(a, order=1, axis=-1):
    '''Difference of input'''
    return _maths.difference(a, order, axis)
예제 #32
0
def rint(a, out=None):
    '''Round elements of input to nearest integers'''
    return _maths.rint(a, out)
예제 #33
0
def arctan2(a, b, out=None):
    '''Inverse tangent of a/b with correct choice of quadrant'''
    return _maths.arctan2(a, b, out)
예제 #34
0
def trunc(a, out=None):
    '''Truncate elements of input to nearest integers'''
    return _maths.truncate(a, out)
예제 #35
0
def sinh(a, out=None):
    '''Hyperbolic sine of input'''
    return _maths.sinh(a, out)
예제 #36
0
def rad2deg(a, out=None):
    '''Convert from radian to degree'''
    return _maths.toDegrees(a, out)
예제 #37
0
def tanh(a, out=None):
    '''Hyperbolic tangent of input'''
    return _maths.tanh(a, out)
예제 #38
0
def deg2rad(a, out=None):
    '''Convert from degree to radian'''
    return _maths.toRadians(a, out)
예제 #39
0
def arctanh(a, out=None):
    '''Inverse hyperbolic tangent of input'''
    return _maths.arctanh(a, out)
예제 #40
0
def sign(a, out=None):
    '''Sign of input, indicated by -1 for negative, +1 for positive and 0 for zero'''
    return _maths.signum(a, out)
예제 #41
0
def log10(a, out=None):
    '''Logarithm of input to base 10'''
    return _maths.log10(a, out)
예제 #42
0
def negative(a, out=None):
    '''Negate input'''
    return _maths.negative(a, out)
예제 #43
0
def exp(a, out=None):
    '''Exponential of input'''
    return _maths.exp(a, out)
예제 #44
0
def clip(a, a_min, a_max, out=None):
    '''Clip input to given bounds (replace NaNs with midpoint of bounds)'''
    return _maths.clip(a, a_min, a_max, out)
예제 #45
0
def sqrt(a, out=None):
    '''Square root of input'''
    return _maths.sqrt(a, out)
예제 #46
0
def minimum(a, b, out=None):
    '''Item-wise minimum'''
    return _maths.minimum(a, b)
예제 #47
0
def power(a, p, out=None):
    '''Input raised to given power'''
    return _maths.power(a, p, out)
예제 #48
0
def diff(a, order=1, axis=-1):
    '''Difference of input'''
    return _maths.difference(a, order, axis)
예제 #49
0
def ceil(a, out=None):
    '''Smallest integer greater or equal to input'''
    return _maths.ceil(a, out)
예제 #50
0
def hypot(a, b, out=None):
    '''Hypotenuse of triangle of given sides'''
    return _maths.hypot(a, b, out)
예제 #51
0
def trunc(a, out=None):
    '''Truncate elements of input to nearest integers'''
    return _maths.truncate(a, out)
예제 #52
0
def arctan2(a, b, out=None):
    '''Inverse tangent of a/b with correct choice of quadrant'''
    return _maths.arctan2(a, b, out)
예제 #53
0
def deg2rad(a, out=None):
    '''Convert from degree to radian'''
    return _maths.toRadians(a, out)
예제 #54
0
def arctan(a, out=None):
    '''Inverse tangent of input'''
    return _maths.arctan(a, out)
예제 #55
0
def negative(a, out=None):
    '''Negate input'''
    return _maths.negative(a, out)
예제 #56
0
def arccos(a, out=None):
    '''Inverse cosine of input'''
    return _maths.arccos(a, out)
예제 #57
0
def minimum(a, b, out=None):
    '''Item-wise minimum'''
    return _maths.minimum(a, b)
예제 #58
0
def arctan(a, out=None):
    '''Inverse tangent of input'''
    return _maths.arctan(a, out)
예제 #59
0
def abs(a, out=None): #@ReservedAssignment
    '''Absolute value of input'''
    return _maths.abs(a, out)
예제 #60
0
def sinh(a, out=None):
    '''Hyperbolic sine of input'''
    return _maths.sinh(a, out)