|
1 | | -# Linear algebra library for Python |
| 1 | +# Linear algebra library for Python |
2 | 2 |
|
3 | | -This module contains classes and functions for doing linear algebra. |
| 3 | +This module contains classes and functions for doing linear algebra. |
4 | 4 |
|
5 | 5 | --- |
6 | 6 |
|
7 | | -## Overview |
| 7 | +## Overview |
8 | 8 |
|
9 | | -### class Vector |
| 9 | +### class Vector |
10 | 10 | - |
11 | | - - This class represents a vector of arbitrary size and related operations. |
12 | | - |
13 | | - **Overview about the methods:** |
14 | | - |
15 | | - - constructor(components : list) : init the vector |
16 | | - - set(components : list) : changes the vector components. |
17 | | - - \_\_str\_\_() : toString method |
18 | | - - component(i : int): gets the i-th component (start by 0) |
19 | | - - \_\_len\_\_() : gets the size / length of the vector (number of components) |
20 | | - - euclidLength() : returns the eulidean length of the vector. |
21 | | - - operator + : vector addition |
22 | | - - operator - : vector subtraction |
23 | | - - operator * : scalar multiplication and dot product |
24 | | - - copy() : copies this vector and returns it. |
25 | | - - changeComponent(pos,value) : changes the specified component. |
26 | | - |
27 | | -- function zeroVector(dimension) |
28 | | - - returns a zero vector of 'dimension' |
29 | | -- function unitBasisVector(dimension,pos) |
30 | | - - returns a unit basis vector with a One at index 'pos' (indexing at 0) |
31 | | -- function axpy(scalar,vector1,vector2) |
32 | | - - computes the axpy operation |
| 11 | + - This class represents a vector of arbitrary size and related operations. |
| 12 | + |
| 13 | + **Overview about the methods:** |
| 14 | + |
| 15 | + - constructor(components : list) : init the vector |
| 16 | + - set(components : list) : changes the vector components. |
| 17 | + - \_\_str\_\_() : toString method |
| 18 | + - component(i : int): gets the i-th component (start by 0) |
| 19 | + - \_\_len\_\_() : gets the size / length of the vector (number of components) |
| 20 | + - euclidLength() : returns the eulidean length of the vector. |
| 21 | + - operator + : vector addition |
| 22 | + - operator - : vector subtraction |
| 23 | + - operator * : scalar multiplication and dot product |
| 24 | + - copy() : copies this vector and returns it. |
| 25 | + - changeComponent(pos,value) : changes the specified component. |
| 26 | + |
| 27 | +- function zeroVector(dimension) |
| 28 | + - returns a zero vector of 'dimension' |
| 29 | +- function unitBasisVector(dimension,pos) |
| 30 | + - returns a unit basis vector with a One at index 'pos' (indexing at 0) |
| 31 | +- function axpy(scalar,vector1,vector2) |
| 32 | + - computes the axpy operation |
33 | 33 | - function randomVector(N,a,b) |
34 | 34 | - returns a random vector of size N, with random integer components between 'a' and 'b'. |
35 | 35 |
|
36 | 36 | ### class Matrix |
37 | 37 | - |
38 | 38 | - This class represents a matrix of arbitrary size and operations on it. |
39 | 39 |
|
40 | | - **Overview about the methods:** |
41 | | - |
42 | | - - \_\_str\_\_() : returns a string representation |
43 | | - - operator * : implements the matrix vector multiplication |
44 | | - implements the matrix-scalar multiplication. |
45 | | - - changeComponent(x,y,value) : changes the specified component. |
46 | | - - component(x,y) : returns the specified component. |
47 | | - - width() : returns the width of the matrix |
| 40 | + **Overview about the methods:** |
| 41 | + |
| 42 | + - \_\_str\_\_() : returns a string representation |
| 43 | + - operator * : implements the matrix vector multiplication |
| 44 | + implements the matrix-scalar multiplication. |
| 45 | + - changeComponent(x,y,value) : changes the specified component. |
| 46 | + - component(x,y) : returns the specified component. |
| 47 | + - width() : returns the width of the matrix |
48 | 48 | - height() : returns the height of the matrix |
49 | | - - determinate() : returns the determinate of the matrix if it is square |
50 | | - - operator + : implements the matrix-addition. |
51 | | - - operator - _ implements the matrix-subtraction |
52 | | - |
53 | | -- function squareZeroMatrix(N) |
54 | | - - returns a square zero-matrix of dimension NxN |
55 | | -- function randomMatrix(W,H,a,b) |
56 | | - - returns a random matrix WxH with integer components between 'a' and 'b' |
| 49 | + - determinate() : returns the determinate of the matrix if it is square |
| 50 | + - operator + : implements the matrix-addition. |
| 51 | + - operator - _ implements the matrix-subtraction |
| 52 | + |
| 53 | +- function squareZeroMatrix(N) |
| 54 | + - returns a square zero-matrix of dimension NxN |
| 55 | +- function randomMatrix(W,H,a,b) |
| 56 | + - returns a random matrix WxH with integer components between 'a' and 'b' |
57 | 57 | --- |
58 | 58 |
|
59 | | -## Documentation |
| 59 | +## Documentation |
60 | 60 |
|
61 | 61 | This module uses docstrings to enable the use of Python's in-built `help(...)` function. |
62 | 62 | For instance, try `help(Vector)`, `help(unitBasisVector)`, and `help(CLASSNAME.METHODNAME)`. |
63 | 63 |
|
64 | 64 | --- |
65 | 65 |
|
66 | | -## Usage |
| 66 | +## Usage |
67 | 67 |
|
68 | 68 | Import the module `lib.py` from the **src** directory into your project. |
69 | | -Alternatively, you can directly use the Python bytecode file `lib.pyc`. |
| 69 | +Alternatively, you can directly use the Python bytecode file `lib.pyc`. |
70 | 70 |
|
71 | 71 | --- |
72 | 72 |
|
73 | | -## Tests |
| 73 | +## Tests |
74 | 74 |
|
75 | 75 | `src/tests.py` contains Python unit tests which can be run with `python3 -m unittest -v`. |
0 commit comments