forked from TheAlgorithms/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix all errors mentioned in pre-commit run (TheAlgorithms#2512)
* Fix all errors mentioned in pre-commit run: - Fix end of file - Remove trailing whitespace - Fix files with black - Fix imports with isort * Fix errors
- Loading branch information
1 parent
e6e2dc6
commit 0a42ae9
Showing
14 changed files
with
88 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,75 @@ | ||
# Linear algebra library for Python | ||
# Linear algebra library for Python | ||
|
||
This module contains classes and functions for doing linear algebra. | ||
This module contains classes and functions for doing linear algebra. | ||
|
||
--- | ||
|
||
## Overview | ||
## Overview | ||
|
||
### class Vector | ||
### class Vector | ||
- | ||
- This class represents a vector of arbitrary size and related operations. | ||
|
||
**Overview about the methods:** | ||
- constructor(components : list) : init the vector | ||
- set(components : list) : changes the vector components. | ||
- \_\_str\_\_() : toString method | ||
- component(i : int): gets the i-th component (start by 0) | ||
- \_\_len\_\_() : gets the size / length of the vector (number of components) | ||
- euclidLength() : returns the eulidean length of the vector. | ||
- operator + : vector addition | ||
- operator - : vector subtraction | ||
- operator * : scalar multiplication and dot product | ||
- copy() : copies this vector and returns it. | ||
- changeComponent(pos,value) : changes the specified component. | ||
|
||
- function zeroVector(dimension) | ||
- returns a zero vector of 'dimension' | ||
- function unitBasisVector(dimension,pos) | ||
- returns a unit basis vector with a One at index 'pos' (indexing at 0) | ||
- function axpy(scalar,vector1,vector2) | ||
- computes the axpy operation | ||
- This class represents a vector of arbitrary size and related operations. | ||
|
||
**Overview about the methods:** | ||
|
||
- constructor(components : list) : init the vector | ||
- set(components : list) : changes the vector components. | ||
- \_\_str\_\_() : toString method | ||
- component(i : int): gets the i-th component (start by 0) | ||
- \_\_len\_\_() : gets the size / length of the vector (number of components) | ||
- euclidLength() : returns the eulidean length of the vector. | ||
- operator + : vector addition | ||
- operator - : vector subtraction | ||
- operator * : scalar multiplication and dot product | ||
- copy() : copies this vector and returns it. | ||
- changeComponent(pos,value) : changes the specified component. | ||
|
||
- function zeroVector(dimension) | ||
- returns a zero vector of 'dimension' | ||
- function unitBasisVector(dimension,pos) | ||
- returns a unit basis vector with a One at index 'pos' (indexing at 0) | ||
- function axpy(scalar,vector1,vector2) | ||
- computes the axpy operation | ||
- function randomVector(N,a,b) | ||
- returns a random vector of size N, with random integer components between 'a' and 'b'. | ||
|
||
### class Matrix | ||
- | ||
- This class represents a matrix of arbitrary size and operations on it. | ||
|
||
**Overview about the methods:** | ||
- \_\_str\_\_() : returns a string representation | ||
- operator * : implements the matrix vector multiplication | ||
implements the matrix-scalar multiplication. | ||
- changeComponent(x,y,value) : changes the specified component. | ||
- component(x,y) : returns the specified component. | ||
- width() : returns the width of the matrix | ||
**Overview about the methods:** | ||
|
||
- \_\_str\_\_() : returns a string representation | ||
- operator * : implements the matrix vector multiplication | ||
implements the matrix-scalar multiplication. | ||
- changeComponent(x,y,value) : changes the specified component. | ||
- component(x,y) : returns the specified component. | ||
- width() : returns the width of the matrix | ||
- height() : returns the height of the matrix | ||
- determinate() : returns the determinate of the matrix if it is square | ||
- operator + : implements the matrix-addition. | ||
- operator - _ implements the matrix-subtraction | ||
|
||
- function squareZeroMatrix(N) | ||
- returns a square zero-matrix of dimension NxN | ||
- function randomMatrix(W,H,a,b) | ||
- returns a random matrix WxH with integer components between 'a' and 'b' | ||
- determinate() : returns the determinate of the matrix if it is square | ||
- operator + : implements the matrix-addition. | ||
- operator - _ implements the matrix-subtraction | ||
|
||
- function squareZeroMatrix(N) | ||
- returns a square zero-matrix of dimension NxN | ||
- function randomMatrix(W,H,a,b) | ||
- returns a random matrix WxH with integer components between 'a' and 'b' | ||
--- | ||
|
||
## Documentation | ||
## Documentation | ||
|
||
This module uses docstrings to enable the use of Python's in-built `help(...)` function. | ||
For instance, try `help(Vector)`, `help(unitBasisVector)`, and `help(CLASSNAME.METHODNAME)`. | ||
|
||
--- | ||
|
||
## Usage | ||
## Usage | ||
|
||
Import the module `lib.py` from the **src** directory into your project. | ||
Alternatively, you can directly use the Python bytecode file `lib.pyc`. | ||
Alternatively, you can directly use the Python bytecode file `lib.pyc`. | ||
|
||
--- | ||
|
||
## Tests | ||
## Tests | ||
|
||
`src/tests.py` contains Python unit tests which can be run with `python3 -m unittest -v`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -997,4 +997,4 @@ | |
672276,515708 | ||
325361,545187 | ||
172115,573985 | ||
13846,725685 | ||
13846,725685 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2899,4 +2899,4 @@ | |
725, | ||
"4598797036650685" | ||
] | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters