euclidean norm


See On Github

Data

Tags

euclid, length

Source Code

module.exports = function(m) {
  var sum = 0
  for(var i in m) {
    sum += m[i] * m[i]
  }
  return Math.sqrt(sum).toFixed(4)
}
var euclidean_norm = require('./euclidean_norm')
console.log(euclidean_norm([1,2,3,4]))
// (1^2 + 2^2 + 3^2 + 4^2)^1/2 = 5.4772