Simple, general, pure Python vectors
Project description
Simple, general, pure Python vectors
hypervector.py defines arbitrary-dimentional vector types for all your vectoring needs. The vectors are immutable and come with many useful and well-tested vector operations and features.
hypervector is in the public domain.
A few explanatory examples
Hello world, NOW IN 3D!
>>> from hypervector import Vector3
>>> (Vector3(1, 2, 1) + Vector3(3, 0, 2)).zxy
Vector3(3, 4, 2)
Higher dimensions
>>> from hypervector import Vector, Vector2, Vector3
>>> Vector2 is Vector[2] and Vector3 is Vector[3]
True
>>> Vector[4](1, 2, 3, 4)
Vector[4](1, 2, 3, 4)
>>> Vector[5](1, 2, 3, 4)
Vector[5](1, 2, 3, 4, 0)
>>> Vector[10].zero
Vector[10](0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
King of infinite (vector) space
>>> vec = Vector(2, 4) # Dimensionless vectors are "infinite"
>>> (vec[0], vec[1], vec[2], vec[1114111])
(2, 4, 0, 0)
Cross-eyed
>>> vec_1, vec_2 = Vector(1, 2, 3), Vector(3, 2, 1)
>>> Vector.cross(vec_1, vec_2)
Vector(-4.0, 8.0, -4.0)
>>> [Vector.dot(_, vec) for vec in (vec_1, vec_2)]
[0.0, 0.0]
>>> vec_3 = Vector(-1, 8, 3, 2)
>>> Vector.cross(vec_1, vec_2, vec_3)
Vector(8.0, -16.0, 8.0, 56.0)
>>> [Vector.dot(_, vec) for vec in (vec_1, vec_2, vec_3)]
[0.0, 0.0, 0.0]
Testing
How fast is hypervector?
Dunno. Probably pretty slow. If you need speed, use numpy.
Alternatives
There are many other libraries with similar features to hypervector. Some notable examples I have used:
Links
Get hypervector from PyPI: pip install hypervector
Report bugs and offer suggestions at the github issues page.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hypervector-0.1.0.tar.gz
(9.5 kB
view hashes)
Built Distribution
Close
Hashes for hypervector-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4fd128929635e88290aece410bcfd302f31f72222a29bab89909150ebad1df4 |
|
MD5 | b9bb1b2824f3e09a1b271bf0c53dc513 |
|
BLAKE2b-256 | afad6ac18cbef6a11de1017aa55383a44f41c194df32529dfa5f6685de3b8258 |