Logo

Programming-Idioms

New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating resource.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
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);
import numpy as np
np.linalg.norm(data)
require 'matrix'
data = Vector[5.0, 4.0, 3.0, 2.0, 1.0]
n = data.norm