I don't think `lazy val` is useful because user should call this method only once. If the dimension is beyond 1e6, cache this extra mean vector cost several MBs. Same for other lazy values. Also, use while loop instead of chaining vector ops.