Returns the L2-norm of the given vector.
(v)
| 683 | rel = relative |
| 684 | |
| 685 | def l2_norm(v): |
| 686 | """ Returns the L2-norm of the given vector. |
| 687 | """ |
| 688 | if isinstance(v, Vector): |
| 689 | return v.l2_norm |
| 690 | return sum(w * w for w in v.itervalues()) ** 0.5 |
| 691 | |
| 692 | norm = l2 = L2 = L2norm = l2norm = L2_norm = l2_norm |
| 693 |
no test coverage detected
searching dependent graphs…