The norm of the vector.

||x|| = (x1 ** 2 ... + xn ** 2).sqrt

var v = new Vector
v["x"] = 1.0
v["y"] = 1.0
v["z"] = 1.0
v["t"] = 1.0
assert v.norm.is_approx(2.0, 0.001)

v["x"] = 1.0
v["y"] = 2.0
v["z"] = 3.0
v["t"] = 0.0
assert v.norm.is_approx(3.742, 0.001)

Property definitions

vsm $ Vector :: norm
	# The norm of the vector.
	#
	# `||x|| = (x1 ** 2 ... + xn ** 2).sqrt`
	#
	# ~~~
	# var v = new Vector
	# v["x"] = 1.0
	# v["y"] = 1.0
	# v["z"] = 1.0
	# v["t"] = 1.0
	# assert v.norm.is_approx(2.0, 0.001)
	#
	# v["x"] = 1.0
	# v["y"] = 2.0
	# v["z"] = 3.0
	# v["t"] = 0.0
	# assert v.norm.is_approx(3.742, 0.001)
	# ~~~
	fun norm: Float do
		var sum = 0.0
		for v in self.values do sum += v.pow(2.0)
		return sum.to_f.sqrt
	end
lib/vsm/vsm.nit:91,2--113,4