When I added unpack_buffer_archive, in code review people said
it was redundant with unpack_buffer and they should be merged.
I said merging was too annoying. They were right. This merges
the functions together into a function with a 38 line docstring
and a 18 line implementation.
Merge together unpack_buffer and unpack_buffer_archive. When I added unpack_buffer_archive, in code review people said
it was redundant with unpack_buffer and they should be merged.
I said merging was too annoying. They were right. This merges
the functions together into a function with a 38 line docstring
and a 18 line implementation.
# http://stackoverflow.com/questions/7741878/how-to-apply-numpy-linalg-norm-to-each-row-of-a-matrix/7741976#7741976
# setup: import numpy as np ; N = 1000; x = np.random.rand(N,N)
# run: l2norm(x)

# pythran export l2norm(float64[][])
import numpy as np


def l2norm(x):
    return np.sqrt(np.einsum("ij,ij->i", x, x))

# http://stackoverflow.com/questions/7741878/how-to-apply-numpy-linalg-norm-to-each-row-of-a-matrix/7741976#7741976
# setup: import numpy as np ; N = 1000; x = np.random.rand(N,N)
# run: l2norm(x)

# pythran export l2norm(float64[][])
import numpy as np


def l2norm(x):
    return np.sqrt(np.einsum("ij,ij->i", x, x))
