A lightweight python package for solving linear algebra problems
pip install:
sudo pip install Pylinear
Example:
from Pylinear import Vector
>>> v1 = Vector([1,2,3])
>>> v2 = Vector([6,5,4])
>>> print(v1, v2)
Vector: (1, 2, 3) Vector: (6, 5, 4)
Example:
>>> v = v1 + v2
>>> print(v)
Vector: (7, 7, 7)
>>> v = v1 + 3
>>> print(v)
Vector: (4, 5, 6)
>>> v = v1 - v2
>>> print(v)
Vector: (-5, -3, -1)
Example:
>>> v = v1 * 3
>>> print(v)
Vector: (3, 6, 9)
Example:
>>> v = v1 / 3
>>> print(v)
Vector: (0.3333333333333333, 0.6666666666666666, 1.0)
Example:
>>> v = v1 * v2
>>> print(v)
28
Example:
>>> v = v1 ** v2
>>> print(v)
Vector: (-7, 14, -7)
Example:
>>> v1.mag()
3.7416573867739413
Example:
>>> v1.sim(v2)
0.8528028654224418
Example:
>>> v1.angle(v2)
0.5494672447576273
>>> v1.angle(v2, degree = True)
62.96430821058771
Example:
>>> v1.parallel(v2)
False
>>> v1.orthogonal(v2)
False
Example:
>>> v = v1.projectTo(v2)
>>> print(v)
Vector: (2.1818181818181817, 1.8181818181818181, 1.4545454545454544)
Example:
>>> from Pylinear import Lineq
>>> l1 = Lineq([1,1],1)
>>> l2 = Lineq([2,3],7)
>>> l3 = Lineq([0,0],5)
>>> print(l1)
x_1 + x_2 = 1
Example:
>>> print(l1 + l2)
3x_1 + 4x_2 = 8
>>> print(l1-l2)
-x_1 - 2x_2 = -6
>>> print(3*l1)
3x_1 + 3x_2 = 3
>>> print(l1/3)
0.333x_1 + 0.333x_2 = 0.333
Example:
>> l1.valid()
True
>>> l3.valid()
False
Example:
>>> from Pylinear import LinearSystem
>>> s = LinearSystem([l1, l2])
>>> print(s)
Linear System:
Equation 1: x_1 + x_2 = 1
Equation 2: 2x_1 + 3x_2 = 7
Example:
>>> print(s.triangularForm())
Linear System:
Equation 1: x_1 + x_2 = 1
Equation 2: x_2 = 5
Example:
>>> result = s.solve()
>>> print(result)
[-4.0, 5.0]
Example:
>>> from Pylinear import Line
>>> l1 = Line([1,2],3)
>>> l2 = Line([1,2],4)
>>> l3 = Line([2,4],6)
>>> print(l1)
x_1 + 2x_2 = 3
Example:
>>> l1.parallel(l3)
True
Example:
>>> l1 == l2
False
>>> l1 == l3
True
Example:
from Pylinear import Plane
>>> p1 = Plane([1,2,3],4)
>>> p2 = Plane([2,4,6],8)
Example:
>>> p1.parallel(p2)
True
Example:
>>> p1 == p2
True
- Add Matrix class and its methods.
- Add Optimization class and the methods to solve linear programming problem.