Simple Linear Algebra Package
Project description
linalg_simple
A simple linear algebra package written in Python 3
This is a more or less direct implementation of the Udacity Linear Algebra Refresher Course.
Installation
linalg_simple is available from the Python Package Index PyPi.
If you have Python 3 installed on your system you can use the pip install
command:
pip install linalg_simple
Classes
The linalg_simple package currently offers the Vector()
class, which can directly be imported into your project with:
from linalg import Vector
Vector Class
Attributes
The Vector()
class has two attributes:
Vector.coordinates
(Decimal object)Vector.dimension
(int)
Methods
The following Vector()
class methods are available:
Constructor
Arguments: int, float
v1 = Vector([1.5, -4.8, 3])
+ Method
v3 = v1 + v2
- Method
v3 = v1 - v2
Scalar Mutliplication
Arguments: int, float
v1.times_scalar(42)
Magnitude
vector_length = v1.magnitude()
Vector Normalization
unit_vector = v1.normalized()
Dot Product
Arguments: vector object
dot_product = v1.dot(v2)
Angle between two vectors
Arguments: vector object
angle = v1.angle_with(v2)
Check if vector's length is zero
To avoid precision errors, you can indicate a tolerance (default: 1e-10).
v1.is_zero()
Check if two vectors are orthogonal to each other
To avoid precision errors, you can indicate a tolerance (default: 1e-10).
Arguments: vector object, tolerance
v1.is_orthogonal_to(v2)
Check if two vectors are parallel to each other
Arguments: vector object
v1.is_parallel_to(v2)
Calculate projection of a vector onto a basis vector
Arguments: vector object (basis vector)
projection_vector = v1.component_parallel_to(v2)
Calculate orthogonal component of vector
Arguments: vector object (basis vector)
projection_vector = v1.component_orthogonal_to(v2)
Calculate Cross Product of two vectors
The vectors should be 3D (2D vectors will be augmented to 3D).
Arguments: vector object
crossproduct_vector = v1.cross(v2)
Calculate the parallelogram spanned by two vectors
Arguments: vector object
area = v1.area_of_parallelogram_with(v2)
Calculate area of a parallelogram spanned by two vectors
Arguments: vector object
area = v1.area_of_parallelogram_with(v2)
Calculate area of a trinagle spanned by two vectors
Arguments: vector object
area = v1.area_of_triangle_with(v2)
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
File details
Details for the file linalg_simple-0.0.3.tar.gz
.
File metadata
- Download URL: linalg_simple-0.0.3.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ce8e6bf9cf4584141acce2148a694a2b10edda856653cbbe1596fbf4e5dd4c4 |
|
MD5 | 3a4d71e4de09bc266845db8073a690c1 |
|
BLAKE2b-256 | 495043f7618c9f3bf9d9fae4533628476ae28396b6923f177b6ceebe329c098e |