Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Java

Idiom #201 Euclidean norm

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

double n = 0d;
for(double value : data) {
	n += value * value;
}
n = Math.sqrt(n);
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