Logo

Programming-Idioms

  • Python

Idiom #201 Euclidean norm

Calculate n, the Euclidean norm of data, where data is a list of floating point values.

import numpy as np
np.linalg.norm(adata2[:, 0:3] - adata1[ipc1, 0:3], axis=1)
import numpy as np
n = np.linalg.norm(data)
n = norm2( data )

data may be a multidimensional array (e.g. data(:,:)). n is the Frobenius norm if data is a 2-dimensional array (matrix).

New implementation...
< >
Bart