ulab.numpy – Numerical approximation methods

ulab.numpy.interp(x: ndarray, xp: ndarray, fp: ndarray, *, left: Optional[_float] = None, right: Optional[_float] = None)ndarray
Parameters
  • x (ulab.numpy.ndarray) – The x-coordinates at which to evaluate the interpolated values.

  • xp (ulab.numpy.ndarray) – The x-coordinates of the data points, must be increasing

  • fp (ulab.numpy.ndarray) – The y-coordinates of the data points, same length as xp

  • left – Value to return for x < xp[0], default is fp[0].

  • right – Value to return for x > xp[-1], default is fp[-1].

Returns the one-dimensional piecewise linear interpolant to a function with given discrete data points (xp, fp), evaluated at x.

ulab.numpy.trapz(y: ndarray, x: Optional[ndarray] = None, dx: _float = 1.0)_float
Parameters
  • ulab.numpy.ndarray y (1D) – the values of the dependent variable

  • ulab.numpy.ndarray x (1D) – optional, the coordinates of the independent variable. Defaults to uniformly spaced values.

  • dx (float) – the spacing between sample points, if x=None

Returns the integral of y(x) using the trapezoidal rule.

ulab.numpy._ArrayLike
ulab.numpy._DType

ulab.numpy.int8, ulab.numpy.uint8, ulab.numpy.int16, ulab.numpy.uint16, ulab.numpy.float or ulab.numpy.bool

ulab.numpy._float

Type alias of the bulitin float

ulab.numpy._bool

Type alias of the bulitin bool

ulab.numpy.int8 :_DType

Type code for signed integers in the range -128 .. 127 inclusive, like the ‘b’ typecode of array.array

ulab.numpy.int16 :_DType

Type code for signed integers in the range -32768 .. 32767 inclusive, like the ‘h’ typecode of array.array

ulab.numpy.float :_DType

Type code for floating point values, like the ‘f’ typecode of array.array

ulab.numpy.uint8 :_DType

Type code for unsigned integers in the range 0 .. 255 inclusive, like the ‘H’ typecode of array.array

ulab.numpy.uint16 :_DType

Type code for unsigned integers in the range 0 .. 65535 inclusive, like the ‘h’ typecode of array.array

ulab.numpy.bool :_DType

Type code for boolean values

ulab.numpy.argmax(array: _ArrayLike, *, axis: Optional[int] = None)int

Return the index of the maximum element of the 1D array

ulab.numpy.argmin(array: _ArrayLike, *, axis: Optional[int] = None)int

Return the index of the minimum element of the 1D array

ulab.numpy.argsort(array: ndarray, *, axis: int = - 1)ndarray

Returns an array which gives indices into the input array from least to greatest.

ulab.numpy.cross(a: ndarray, b: ndarray)ndarray

Return the cross product of two vectors of length 3

ulab.numpy.diff(array: ndarray, *, n: int = 1, axis: int = - 1)ndarray

Return the numerical derivative of successive elements of the array, as an array. axis=None is not supported.

ulab.numpy.flip(array: ndarray, *, axis: Optional[int] = None)ndarray

Returns a new array that reverses the order of the elements along the given axis, or along all axes if axis is None.

ulab.numpy.max(array: _ArrayLike, *, axis: Optional[int] = None)_float

Return the maximum element of the 1D array

ulab.numpy.mean(array: _ArrayLike, *, axis: Optional[int] = None)_float

Return the mean element of the 1D array, as a number if axis is None, otherwise as an array.

ulab.numpy.median(array: ndarray, *, axis: int = - 1)ndarray

Find the median value in an array along the given axis, or along all axes if axis is None.

ulab.numpy.min(array: _ArrayLike, *, axis: Optional[int] = None)_float

Return the minimum element of the 1D array

ulab.numpy.roll(array: ndarray, distance: int, *, axis: Optional[int] = None)None

Shift the content of a vector by the positions given as the second argument. If the axis keyword is supplied, the shift is applied to the given axis. The array is modified in place.

ulab.numpy.sort(array: ndarray, *, axis: int = - 1)ndarray

Sort the array along the given axis, or along all axes if axis is None. The array is modified in place.

ulab.numpy.std(array: _ArrayLike, *, axis: Optional[int] = None, ddof: int = 0)_float

Return the standard deviation of the array, as a number if axis is None, otherwise as an array.

ulab.numpy.sum(array: _ArrayLike, *, axis: Optional[int] = None)Union[_float, int, ndarray]

Return the sum of the array, as a number if axis is None, otherwise as an array.

class ulab.numpy.ndarray
ulab.numpy.get_printoptions()Dict[str, int]

Get printing options

ulab.numpy.set_printoptions(threshold: Optional[int] = None, edgeitems: Optional[int] = None)None

Set printing options

ulab.numpy.ndinfo(array: ndarray)None
ulab.numpy.array(values: Union[ndarray, Iterable[Union[_float, _bool, Iterable[Any]]]], *, dtype: _DType = ulab.numpy.float)ndarray

alternate constructor function for ulab.numpy.ndarray. Mirrors numpy.array

ulab.numpy.trace(m: ndarray)_float
Parameters

m – a square matrix

Compute the trace of the matrix, the sum of its diagonal elements.

ulab.numpy.dot(m1: ndarray, m2: ndarray)Union[ndarray, _float]
Parameters
  • m1 (ndarray) – a matrix, or a vector

  • m2 (ndarray) – a matrix, or a vector

Computes the product of two matrices, or two vectors. In the letter case, the inner product is returned.

ulab.numpy.acos(a: _ArrayLike)ndarray

Computes the inverse cosine function

ulab.numpy.acosh(a: _ArrayLike)ndarray

Computes the inverse hyperbolic cosine function

ulab.numpy.asin(a: _ArrayLike)ndarray

Computes the inverse sine function

ulab.numpy.asinh(a: _ArrayLike)ndarray

Computes the inverse hyperbolic sine function

ulab.numpy.around(a: _ArrayLike, *, decimals: int = 0)ndarray

Returns a new float array in which each element is rounded to decimals places.

ulab.numpy.atan(a: _ArrayLike)ndarray

Computes the inverse tangent function; the return values are in the range [-pi/2,pi/2].

ulab.numpy.arctan2(ya: _ArrayLike, xa: _ArrayLike)ndarray

Computes the inverse tangent function of y/x; the return values are in the range [-pi, pi].

ulab.numpy.atanh(a: _ArrayLike)ndarray

Computes the inverse hyperbolic tangent function

ulab.numpy.ceil(a: _ArrayLike)ndarray

Rounds numbers up to the next whole number

ulab.numpy.cos(a: _ArrayLike)ndarray

Computes the cosine function

ulab.numpy.cosh(a: _ArrayLike)ndarray

Computes the hyperbolic cosine function

ulab.numpy.degrees(a: _ArrayLike)ndarray

Converts angles from radians to degrees

ulab.numpy.erf(a: _ArrayLike)ndarray

Computes the error function, which has applications in statistics

ulab.numpy.erfc(a: _ArrayLike)ndarray

Computes the complementary error function, which has applications in statistics

ulab.numpy.exp(a: _ArrayLike)ndarray

Computes the exponent function.

ulab.numpy.expm1(a: _ArrayLike)ndarray

Computes $e^x-1$. In certain applications, using this function preserves numeric accuracy better than the exp function.

ulab.numpy.floor(a: _ArrayLike)ndarray

Rounds numbers up to the next whole number

ulab.numpy.gamma(a: _ArrayLike)ndarray

Computes the gamma function

ulab.numpy.lgamma(a: _ArrayLike)ndarray

Computes the natural log of the gamma function

ulab.numpy.log(a: _ArrayLike)ndarray

Computes the natural log

ulab.numpy.log10(a: _ArrayLike)ndarray

Computes the log base 10

ulab.numpy.log2(a: _ArrayLike)ndarray

Computes the log base 2

ulab.numpy.radians(a: _ArrayLike)ndarray

Converts angles from degrees to radians

ulab.numpy.sin(a: _ArrayLike)ndarray

Computes the sine function

ulab.numpy.sinh(a: _ArrayLike)ndarray

Computes the hyperbolic sine

ulab.numpy.sqrt(a: _ArrayLike)ndarray

Computes the square root

ulab.numpy.tan(a: _ArrayLike)ndarray

Computes the tangent

ulab.numpy.tanh(a: _ArrayLike)ndarray

Computes the hyperbolic tangent

ulab.numpy.vectorize(f: Union[Callable[[int], _float], Callable[[_float], _float]], *, otypes: Optional[_DType] = None)Callable[[_ArrayLike], ndarray]
Parameters
  • f (callable) – The function to wrap

  • otypes – List of array types that may be returned by the function. None is interpreted to mean the return value is float.

Wrap a Python function f so that it can be applied to arrays. The callable must return only values of the types specified by otypes, or the result is undefined.