/** {@inheritDoc} */
 public double magnitude() {
   // Check whether the current magnitude is valid and if not, recompute it
   if (magnitude < 0) {
     double m = 0;
     for (DoubleEntry e : this) m += e.value() * e.value();
     magnitude = Math.sqrt(m);
   }
   return magnitude;
 }