File size: 730 Bytes
b1b3bae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/// ------------------------------------------------------
/// SwarmOps - Numeric and heuristic optimization for C#
/// Copyright (C) 2003-2011 Magnus Erik Hvass Pedersen.
/// Please see the file license.txt for license details.
/// SwarmOps on the internet: http://www.Hvass-Labs.org/
/// ------------------------------------------------------

using System.Linq;

namespace SwarmOps
{
    public static partial class Tools
    {
        /// <summary>
        /// Euclidian norm (or length) of a numeric vector.
        /// </summary>
        public static double Norm(double[] x)
        {
            return System.Math.Sqrt(x.Aggregate((double)0.0, (sum, elm) => sum += elm * elm));
        }
    }
}