A quick one:
>>> from vecpy import Vector as Vec
>>> v = Vec(0, 2)
>>> w = Vec([1, 3])
>>> v + 2
>>> v + w
- Basic operations ( dot-product, projection, rescaling, etc.)
To install VecPy, simply:
$ pip install vecpy
This is a simple package allowing to complete very basic linear algebra tasks.
It is best explained by example:
>>> v = Vec(0, 2)
>>> w = Vec(1, 3)
You can do basic rescaling of a vector:
>>> v_twice = v ^ 2
>>> print v_twice.length == 2 * v.length
>>> v_unit = v ^ 0
>>> print v_unit.length
Adding scalar and other vectors:
>>> v + 2
>>> v + w
...
Multiplication and dot-product
>>> v * 3
>>> v.dot(w)
A vector has several properties:
>>> v.length
>>> v.dim
You can specify which norm to use (default is the Euclidean)
>>> v.norm(1)
>>> v.norm('inf')
>>> v.norm(2) == v.length
...
You can project one vector on another:
>>> w_proj_v = v.proj(w)
>>> ratio = v.proj(w, get_scale=True)
Iteration is supported as well:
>>> print [xi for xi in v]
String representations:
>>> print str(v)
>>> print '{:[x, y, z]}'.format(v)