|
| 1 | +# Linear algebra library for Python |
| 2 | + |
| 3 | +This module contains some useful classes and functions for dealing with linear algebra in python 2. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +- class Vector |
| 10 | + - This class represents a vector of arbitray size and operations on it. |
| 11 | + |
| 12 | + **Overview about the methods:** |
| 13 | + |
| 14 | + - constructor(components : list) : init the vector |
| 15 | + - set(components : list) : changes the vector components. |
| 16 | + - __str__() : toString method |
| 17 | + - component(i : int): gets the i-th component (start by 0) |
| 18 | + - size() : gets the size of the vector (number of components) |
| 19 | + - euclidLength() : returns the eulidean length of the vector. |
| 20 | + - operator + : vector addition |
| 21 | + - operator - : vector subtraction |
| 22 | + - operator * : scalar multiplication and dot product |
| 23 | + - copy() : copies this vector and returns it. |
| 24 | + - changeComponent(pos,value) : changes the specified component. |
| 25 | + |
| 26 | +- function zeroVector(dimension) |
| 27 | + - returns a zero vector of 'dimension' |
| 28 | +- function unitBasisVector(dimension,pos) |
| 29 | + - returns a unit basis vector with a One at index 'pos' (indexing at 0) |
| 30 | +- function axpy(scalar,vector1,vector2) |
| 31 | + - computes the axpy operation |
| 32 | +- class Matrix |
| 33 | + - This class represents a matrix of arbitrary size and operations on it. |
| 34 | + |
| 35 | + **Overview about the methods:** |
| 36 | + |
| 37 | + - __str__() : returns a string representation |
| 38 | + - operator * : implements the matrix vector multiplication |
| 39 | + implements the matrix-scalar multiplication. |
| 40 | + - changeComponent(x,y,value) : changes the specified component. |
| 41 | + - component(x,y) : returns the specified component. |
| 42 | + - width() : returns the width of the matrix |
| 43 | + - height() : returns the height of the matrix |
| 44 | + - operator + : implements the matrix-addition. |
| 45 | + - operator - _ implements the matrix-subtraction |
| 46 | +- function squareZeroMatrix(N) |
| 47 | + - returns a square zero-matrix of dimension NxN |
| 48 | +--- |
| 49 | + |
| 50 | +## Documentation |
| 51 | + |
| 52 | +The module is well documented. You can use the python in-built ```help(...)``` function. |
| 53 | +For instance: ```help(Vector)``` gives you all information about the Vector-class. |
| 54 | +Or ```help(unitBasisVector)``` gives you all information you needed about the |
| 55 | +global function ```unitBasisVector(...)```. If you need informations about a certain |
| 56 | +method you type ```help(CLASSNAME.METHODNAME)```. |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## Usage |
| 61 | + |
| 62 | +You will find the module in the **src** directory its called ```lib.py```. You need to |
| 63 | +import this module in your project. Alternative you can also use the file ```lib.pyc``` in python-bytecode. |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## Tests |
| 68 | + |
| 69 | +In the **src** directory you also find the test-suite, its called ```tests.py```. |
| 70 | +The test-suite uses the built-in python-test-framework **unittest**. |
0 commit comments