So you want to normalize a vector? Well numpy can do that for you with a little help.
First include numpy:
!INCLUDE normalized.py 1:1Then call the norm function of the linealg module:
!INCLUDE normalized.py 4:6Encapsulate all this into a function:
!INCLUDE normalized.pyAnd now with graphics!
@startditaa
+--------+ +-------+ +-------+
| +---+ ditaa +--> | |
| Text | +-------+ |diagram|
|Document| |!magic!| | |
| {d}| | | | |
+---+----+ +-------+ +-------+
: ^
| Lots of work |
+-------------------------+
@endditaaThat's all folks!