code: public double magnitude() {
          // Check whether the current magnitude is valid and if not, recompute it
          if (magnitude < 0) {
              magnitude = 0;
              for (int nz : getNonZeroIndices()) {
                  double d = vector.get(nz).doubleValue();
                  magnitude += d * d;
              }
              magnitude = Math.sqrt(magnitude);
          }
          return magnitude;
      }
docs: {@inheritDoc}