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

Idiom #201 Euclidean norm

Calculate n, the Euclidean norm of data (an array or list of floating point values).

import numpy as np
np.linalg.norm(data)
n = norm2( data )
math
var
  data: array of double;
...
  n := norm(data);
...
use Math::GSL::Vector qw();
use Math::GSL::BLAS qw(gsl_blas_dnrm2);
my $data = [5.0, 4.0, 3.0, 2.0, 1.0];
my $n = gsl_blas_dnrm2(Math::GSL::Vector->new($data)->raw);
require 'matrix'
data = Vector[5.0, 4.0, 3.0, 2.0, 1.0]
n = data.norm

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

Bart