corewise_norm#

t3toolbox.corewise.corewise_norm(X)#
def corewise_norm(
        X,  # any nested tree of ints/floats/arrays
) -> NDArray:  # ||X||, a scalar (collapses EVERY axis, stacks included)

Norm of nested objects, X -> ||X||

Examples

>>> import numpy as np
>>> import t3toolbox.corewise as cw
>>> X = (np.array([1,2,3]), (4, (), np.array([5,6])))
>>> print(cw.corewise_norm(X))
9.539392014169456
>>> print(np.sqrt(1**2 + 2**2 + 3**2 + 4**2 + 5**2 + 6**2))
9.539392014169456
Return type:

NDArray