-
Notifications
You must be signed in to change notification settings - Fork 0
algebra
The avmath.algebra submodule provides functionalities for
linear algebra. It can be imported in the following way:
# pip install avmath
from avmath import algebraImplemented in v3.0.0 | Last change v3.0.0
The Tuple class is the base class for the algebra submodule classes and the avmath.analysis.Point class.
It defines interaction methods inherited by the other classes.
The methods of Tuple simulate an immutable type.
Implemented in v3.0.0 | Last change v3.0.0
Stores the items of the tuple in a list.
Implemented in v3.0.0 | Last change v3.0.0
Initialises the Tuple. Tuple can be initialised giving either numbers as parameters or a list.
import avmath
# Initialisation via numbers
a = avmath.Tuple(1, 2, 4)
# Initialisation via iterable object
b_list = [4, 3, 4.9]
b = avmath.Tuple(b_list)Implemented in v3.0.0 | Last change v3.0.0
Returns generator to convert Tuple to another iterable object.
Implemented in v3.0.0 | Last change v3.0.0
Gives access to the items of a Tuple.
Implemented in v3.0.0 | Last change v3.0.0
Returns string representation of the Tuple. String has the
form of built-in tuple representation.
Implemented in v3.0.0 | Last change v3.0.0
Returns whether two Tuples are equal.
Implemented in v3.0.0 | Last change v3.0.0
Returns the length of the Tuple. Is equal to the dimension.
Implemented in v3.0.0 | Last change v3.0.0
Returns negative Tuple.
Implemented in v3.0.0 | Last change v3.0.0
Adds two Tuples.
Implemented in v3.0.0 | Last change v3.0.0
Subtracts two tuples.
Implemented in v3.0.0 | Last change v3.0.0
Returns scalar multiplied Tuple.
Implemented in v3.0.0 | Last change v3.0.0
Tuple divided by a scalar. Returns Tuple with Fraction values.
Implemented in v3.0.0 | Last change v3.0.0
Appends value to Tuple.
Implemented in v3.0.0 | Last change v3.0.0
Returns Tuple that does not contain Fraction members.
Implemented in v3.0.0 | Last change v3.0.0
Checks if arguments have the same amount of dimensions.
Implemented in v1.0.0 | Last change v3.0.0
The Vector-class is an inherited class of Tuple.
The methods of Vector simulate an immutable type.
It also defines the following methods:
Implemented in v1.0.0 | Last Change in v3.0.0
Initialisation of Vector object. Takes either number arguments, vectorizes a Tuple or is initialised by giving a beginning and end as Tuples.
from avmath import algebra
# Initialisation via numbers
u = algebra.Vector(1, 2, 4)
# Initialisation via vectorisation
a = algebra.Tuple(2, 5, 2)
v = algebra.Vector(a)
# Initialisation via begin and end
b = algebra.Tuple(-1, 2, 0)
c = algebra.Tuple(4, 5, 8)
w = algebra.Vector(begin=b, end=c)Implemented in v1.0.0 | Last Change in v3.0.0
Returns the absolute of the vector using pythagorean formula. Use
u = algebra.Vector(1, 2, 4)
print(abs(u))Implemented in v1.0.0 | Last Change in v3.0.0
Adds two vectors.
Implemented in v1.0.0 | Last Change in v3.0.0
Subtracts two vectors.
Implemented in v1.0.0 | Last Change in v3.0.0
Either calculates scalar product of two vectors or returns the scalar multiplication of a scalar and a vector.
Implemented in v3.0.0 | Last Change in v3.0.0
Vector divided by a scalar. Returns vector with Fraction values.
Implemented in v1.0.0 | Last Change in v3.0.0
Returns power times scalar multiplied vector. power= 0 returns unit vector.
Implemented in v3.0.0 | Last Change in v3.0.0
Returns vector product of two three-dimensional vectors.
Implemented in v3.0.0 | Last Change in v3.0.0
Returns specific unit vector.
Implemented in v3.0.0 | Last Change in v3.0.0
Returns the number of leading zeroes of a vector.
Implemented in v3.0.0 | Last Change in v3.0.0
Returns a copied vector that does not contain Fraction members.
Implemented in v1.0.0 | Last Change in v3.0.0
Returns the spat product of three vectors.
Implemented in v1.0.0 | Last Change in v3.0.0
Calculates the angle (in radiant) between two vectors.
The structure class provides features for calculation with many points.
| Attribute | Usage | Implemented in version | Last Change |
|---|---|---|---|
self.points |
The edges of the structure | v2.0.0 | v2.0.0 |
self.vectors |
The links of the points | v2.0.0 | v2.0.0 |
Implemented in v1.0.0 | Last Change in v3.0.0
Initialises the Structure with Tuples.
Implemented in v2.0.0 | Last Change in v3.0.0
Returns True if there is a flat area in which all points
lie.
Implemented in v1.0.0 | Last Change in v3.0.0
Returns the circumference of the structure.
Implemented in v1.0.0 | Last Change in v3.1.0
Returns the area of the structure. opt can be 'flat',
in this case GeometricalError is thrown if the area is not flat.
Is not recommended because the algorithm is not very accurate.
With no option specified GeometricalWarning is caused if
the area is not flat.
Implemented in v1.0.0 | Last Change in v3.0.0
Calculates the area between three points.
Implemented in v1.0.0 | Last change v3.0.0
The matrix class inherits from Tuple and also simulates an immutable type. It defines following methods
Implemented in v1.0.0 | Last change v3.0.0
Initialises the matrix. The matrix can be initialised by lists or a vector.
from avmath import algebra
# Initialisation via lists (normal)
A = algebra.Matrix([1, 2, 3], [4, 2, 5], [5, 4, 2])
# Initialisation via lists (better view)
B = algebra.Matrix([1, 2, 3],
[4, 2, 5],
[5, 4, 2])
# Initialisation via Vector
u = algebra.Vector(1, 3, 2)
C = algebra.Matrix(u) # Vector gets column vector
D = algebra.Matrix(list(u)) # Vector gets row vectorImplemented in v1.0.0 | Last change v3.0.0
Returns string of matrix.
A = algebra.Matrix([1, 2, 4],
[4, avmath.Fraction(2, 3), 2],
[5, 2, 9])gives the output:
┌ 1 2 4 ┐
| 4 2/3 2 |
└ 5 2 9 ┘
Implemented in v2.0.0 | Last change v3.0.0
Returns matrix rounded to n digits. If no n is specified rounds with no post comma digits.
Implemented in v1.0.0 | Last change v2.0.0
Returns negative matrix.
Adds two matrices.
Implemented in v1.0.0 | Last change v2.0.0
Subtracts two matrices.
Implemented in v1.0.0 | Last change v3.0.0
Either multiplies two matrices, returns product of vector and matrix or returns the scalar multiplication of a scalar and a matrix.
Implemented in v3.0.0 | Last change v3.0.0
Matrix divided by a scalar. Returns matrix with Fraction values.
Implemented in v1.0.0 | Last change v3.0.0
Returns power times multiplied quadratic matrix.
power=0 returns identity. power=-1 returns
inverse matrix.
Implemented in v2.0.0 | Last change v2.0.0
Returns the size of a matrix in a list. Normally in order
(m, n) with m is number of rows and n is the number of
columns. If opt="xy" is specified, the order is reversed.
Implemented in v3.0.0 | Last change v3.0.0
Returns the dimension of the matrix (=m * n).
Implemented in v1.0.0 | Last change v1.0.0
Returns position of element in a matrix. If There are multiple, all get returned in a list.
Implemented in v1.0.0 | Last change v3.0.0
Returns a copied matrix that
does not contain Fraction members.
Implemented in v1.0.0 | Last change v3.0.0
Returns the column vector of given index.
Implemented in v1.0.0 | Last change v3.0.0
Returns the row vector of given index.
Implemented in v1.0.0 | Last change v3.0.0
Returns a matrix with appended iterable. Can be row or column or both.
Implemented in v1.0.0 | Last change v3.0.0
Returns matrix without row or column specified. Can contain both row and column deletion.
Implemented in v1.0.0 | Last change v3.0.0
Returns transposed matrix.
Implemented in v2.0.0 | Last change v2.0.0
Returns determinant of a matrix.
Implemented in v2.0.0 | Last change v2.0.0
Returns cofactor matrix.
Implemented in v2.0.0 | Last change v2.0.0
Returns adjunct of a matrix.
Implemented in v2.0.0 | Last change v3.0.0
Returns inverse matrix.
Implemented in v3.0.0 | Last change v3.0.0
Returns a row echelon form of a matrix.
Implemented in v3.0.0 | Last change v3.0.0
Returns rank of a matrix.
Implemented in v3.0.0 | Last change v3.0.0
Returns a reduced row echelon form of a matrix.
Implemented in v1.0.0 | Last change v1.0.0
Returns a matrix of size (m, n) with zeros only.
Implemented in v1.0.0 | Last change v1.0.0
Returns an identity matrix with n rows.
Implemented in v3.0.0 | Last change v3.0.0
Sorts the given matrix value list so that elements are ordered by the numbers of leading zeroes they have.
Implemented in v2.0.0 | Last change v3.0.0
The system of linear equations takes coefficients
and solves the system using inverse matrix. It inherits from Matrix.
Implemented in v2.0.0 | Last change v3.0.0
Initialises SLE.
Type
a = algebra.SLE([a_11, a_12, a_13, b_1],
[a_21, a_22, a_23, b_2],
[a_31, a_32, a_33, b_3])for
| a_11 x_1 + a_12 x_2 + a_13 x_3 = b_1 |
| a_21 x_1 + a_22 x_2 + a_23 x_3 = b_2 |
| a_31 x_1 + a_32 x_2 + a_33 x_3 = b_3 |
Implemented in v2.0.0 | Last change v3.0.0
Returns a vector with all unknown variables.
Implemented in v2.0.0 | Last change v3.0.0
Returns the unknown variable of given index.