Documentation
https://ablina.readthedocs.io/en/latest
Installation
Ablina can be installed using pip:
pip install ablina
or by directly cloning the git repository:
git clone https://github.com/daniyal1249/ablina.git
and running the following in the cloned repo:
pip install .
Overview
>>> from ablina import *
Define a Vector Space
To define a subspace of $ℝ^n$ or $ℂ^n$, use fn
>>> V = fn("V", R, 3)
>>> print(V.info())
V (Subspace of R^3)
-------------------
Field R
Identity [0, 0, 0]
Basis [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
Dimension 3
Vector [c0, c1, c2]
You can provide a list of constraints
>>> U = fn("U", R, 3, constraints=["v0 == 0", "2*v1 == v2"])
>>> print(U.info())
U (Subspace of R^3)
-------------------
Field R
Identity [0, 0, 0]
Basis [[0, 1, 2]]
Dimension 1
Vector [0, c0, 2*c0]
Or specify a basis
>>> W = fn("W", R, 3, basis=[[1, 0, 0], [0, 1, 0]])
>>> print(W.info())
W (Subspace of R^3)
-------------------
Field R
Identity [0, 0, 0]
Basis [[1, 0, 0], [0, 1, 0]]
Dimension 2
Vector [c0, c1, 0]
Operations with Vectors
Check whether a vector is an element of a vector space
>>> [1, 2, 0] in W
True
>>> [1, 2, 1] in W
False
Generate a random vector from a vector space
>>> U.vector()
[0, 2, 4]
>>> U.vector(arbitrary=True)
[0, c0, 2*c0]
Find the coordinate vector representation of a vector
>>> W.to_coordinate([1, 2, 0])
[1, 2]
>>> W.from_coordinate([1, 2])
[1, 2, 0]
>>> W.to_coordinate([1, 2, 0], basis=[[1, 1, 0], [1, -1, 0]])
[3/2, -1/2]
Check whether a list of vectors is linearly independent
>>> V.is_independent([1, 1, 0], [1, 0, 0])
True
>>> V.is_independent([1, 2, 3], [2, 4, 6])
False
Operations on Vector Spaces
Check for equality of two vector spaces
>>> U == W
False
Check whether a vector space is a subspace of another
>>> V.is_subspace(U)
True
>>> U.is_subspace(V)
False
Take the sum of two vector spaces
>>> X = U.sum(W)
>>> print(X.info())
U + W (Subspace of R^3)
-----------------------
Field R
Identity [0, 0, 0]
Basis [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
Dimension 3
Vector [c0, c1, c2]
Take the intersection of two vector spaces
>>> X = U.intersection(W)
>>> print(X.info())
U ∩ W (Subspace of R^3)
-----------------------
Field R
Identity [0, 0, 0]
Basis []
Dimension 0
Vector [0, 0, 0]
Take the quotient of two vector spaces
>>> X = V.quotient(U)
>>> print(X.info())
V / U (Subspace of R^3 / U)
---------------------------
Field R
Identity U + [0, 0, 0]
Basis [U + [1, 0, 0], U + [0, 1, -1/2]]
Dimension 2
Vector U + [c0, c1, -c1/2]
Take the span of a list of vectors
>>> S = V.span("S", [1, 2, 3], [4, 5, 6])
>>> print(S.info())
S (Subspace of R^3)
-------------------
Field R
Identity [0, 0, 0]
Basis [[1, 0, -1], [0, 1, 2]]
Dimension 2
Vector [c0, c1, -c0 + 2*c1]
Define a Linear Map
>>> def mapping(vec):
>>> return [vec[0], vec[1], 0]
>>>
>>> T = LinearMap("T", domain=V, codomain=W, mapping=mapping)
>>> print(T.info())
T : V → W
---------
Field R
Rank 2
Nullity 1
Injective? False
Surjective? True
Bijective? False
Matrix [[1, 0, 0], [0, 1, 0]]
>>> T([0, 0, 0])
[0, 0, 0]
>>> T([1, 2, 3])
[1, 2, 0]
Operations with Linear Maps
Find the image of a linear map
>>> im = T.image()
>>> print(im.info())
im(T) (Subspace of R^3)
-----------------------
Field R
Identity [0, 0, 0]
Basis [[1, 0, 0], [0, 1, 0]]
Dimension 2
Vector [c0, c1, 0]
Find the kernel of a linear map
>>> ker = T.kernel()
>>> print(ker.info())
ker(T) (Subspace of R^3)
------------------------
Field R
Identity [0, 0, 0]
Basis [[0, 0, 1]]
Dimension 1
Vector [0, 0, c0]
Define an Inner Product
Here we define the standard dot product
>>> def mapping(vec1, vec2):
>>> return sum(i * j for i, j in zip(vec1, vec2))
>>>
>>> dot = InnerProduct("dot", vectorspace=V, mapping=mapping)
>>> print(dot.info())
dot : V × V → R
---------------
Orthonormal Basis [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
Matrix [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
>>> dot([1, 2, 3], [1, 2, 3])
14
Operations with Inner Products
Compute the norm of a vector
>>> dot.norm([1, 2, 3])
sqrt(14)
Check whether a list of vectors is pairwise orthogonal
>>> dot.is_orthogonal([1, 2, 3], [4, 5, 6])
False
>>> dot.is_orthogonal([0, 0, 0], [1, 2, 3])
True
Check whether a list of vectors is orthonormal
>>> dot.is_orthonormal([1, 0, 0], [0, 1, 0], [0, 0, 1])
True
Take the orthogonal complement of a vector space
>>> X = dot.ortho_complement(U)
>>> print(X.info())
perp(U) (Subspace of R^3)
-------------------------
Field R
Identity [0, 0, 0]
Basis [[1, 0, 0], [0, 1, -1/2]]
Dimension 2
Vector [c0, c1, -c1/2]
Define a Linear Operator
>>> def mapping(vec):
>>> return [vec[0], 2*vec[1], 3*vec[2]]
>>>
>>> T = LinearOperator("T", vectorspace=V, mapping=mapping)
>>> print(T.info())
T : V → V
---------
Field R
Rank 3
Nullity 0
Injective? True
Surjective? True
Bijective? True
Matrix [[1, 0, 0], [0, 2, 0], [0, 0, 3]]
>>> T([1, 1, 1])
[1, 2, 3]
Operations with Linear Operators
Given an inner product, check whether a linear operator
>>> T.is_symmetric(dot)
True
>>> T.is_hermitian(dot)
True
>>> T.is_orthogonal(dot)
False
>>> T.is_unitary(dot)
False
>>> T.is_normal(dot)
True
Metadata
Release files for ablina 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ablina-1.1.0.tar.gz | 69.4 kB | Without provenance | Details for ablina-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ablina-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for ablina-1.1.0-py3-none-any.whl |
Total release size: 105.8 kB
Release files / ablina-1.1.0.tar.gz
| Download URL | ablina-1.1.0.tar.gz |
|---|---|
| Size | 69.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a9686b04b41bb44b862f39e170b36cd29cf189ed8d4d58b7e4ab32d378c9208
|
|
BLAKE2b-256 checksum How to use checksums |
64752ba22590556dfb8937e372cca833e4018a6b3a299c376f622206d7abcb6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.5
|
Release files / ablina-1.1.0-py3-none-any.whl
| Download URL | ablina-1.1.0-py3-none-any.whl |
|---|---|
| Size | 36.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76c267b8e6e858bab6108c82771619c21eb4231928cc68e00c05c2219dacd324
|
|
BLAKE2b-256 checksum How to use checksums |
6348a30c5047170821b8265cd8b4cd1071e2d8de962cace00e5140a3bbe9e3a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.5
|
Security for ablina 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.