norm method

double norm()

Returns the Euclidean norm of the vector.

Vector v = Vector([1.0, 1.0, 1.0]);
print(v.norm());

will print 1.7320508

Implementation

double norm() {
  double v = 0.0;
  for (int i = 0; i < elements; i++) {
    v += this[i] * this[i];
  }
  return sqrt(v);
}