# Numeric¶

The numeric module provides methods that are lacking from the numpy module. An accompanying extension module _numeric.c should be compiled to benefit from extra performance, although a Python-only implementation is provided as fallback. A warning message is printed if the extension module is not found.

nutils.numeric.normdim(ndim, n)[source]

check bounds and make positive

nutils.numeric.align(arr, trans, ndim)[source]

create new array of ndim from arr with axes moved accordin to trans

nutils.numeric.get(arr, axis, item)[source]

take single item from array axis

nutils.numeric.expand(arr, *shape)[source]
nutils.numeric.linspace2d(start, stop, steps)[source]

linspace & meshgrid combined

nutils.numeric.contract(A, B, axis=-1)[source]
nutils.numeric.contract_fast(A, B, naxes)[source]

contract last n axes

nutils.numeric.dot(A, B, axis=-1)[source]

Transform axis of A by contraction with first axis of B and inserting remaining axes. Note: with default axis=-1 this leads to multiplication of vectors and matrices following linear algebra conventions.

nutils.numeric.fastrepeat(A, nrepeat, axis=-1)[source]

repeat axis by 0stride

nutils.numeric.fastmeshgrid(X, Y)[source]

mesh grid based on fastrepeat

nutils.numeric.meshgrid(*args)[source]

multi-dimensional meshgrid generalisation

nutils.numeric.appendaxes(A, shape)[source]

append axes by 0stride

nutils.numeric.inverse(A)[source]

linearized inverse

nutils.numeric.determinant(A)[source]
nutils.numeric.eig(A, sort=False)[source]

Compute the eigenvalues and vectors of a hermitian matrix sort -1/0/1 -> descending / unsorted / ascending

nutils.numeric.eigh(A, sort=False)[source]

Compute the eigenvalues and vectors of a hermitian matrix sort -1/0/1 -> descending / unsorted / ascending

nutils.numeric.reshape(A, *shape)[source]

more useful reshape

nutils.numeric.mean(A, weights=None, axis=-1)[source]

generalized mean

nutils.numeric.norm2(A, axis=-1)[source]

L2 norm over specified axis

nutils.numeric.normalize(A, axis=-1)[source]

devide by normal

nutils.numeric.cross(v1, v2, axis)[source]

cross product

nutils.numeric.stack(arrays, axis=0)[source]

powerful array stacker with singleton expansion

nutils.numeric.bringforward(arg, axis)[source]

bring axis forward

nutils.numeric.diagonalize(arg)[source]

append axis, place last axis on diagonal of self and new