numeric — replace the numeric module of CodeSkulptor¶
numeric module.
Replace the numeric module of CodeSkulptor.
Piece of SimpleGUICS2Pygame. https://bitbucket.org/OPiMedia/simpleguics2pygame
license: | GPLv3 — Copyright (C) 2013-2014, 2020-2021 Olivier Pirson |
---|---|
author: | Olivier Pirson — http://www.opimedia.be/ |
version: | May 5, 2021 |
-
class
SimpleGUICS2Pygame.numeric.
Matrix
(data, _copy=True)[source]¶ Matrix (m x n).
See http://en.wikipedia.org/wiki/Matrix_%28mathematics%29 .
-
__add__
(other)[source]¶ To a matrix (m x n) return the matrix plus other.
Parameters: other – Matrix (m x n) Returns: Matrix (m x n)
-
__getitem__
(i_j)[source]¶ Return the value of the (m x n) matrix at row i and column j.
Parameters: i_j – (0 <= int < m, 0 <= int < n) or [0 <= int < m, 0 <= int < n] Returns: float
-
__init__
(data, _copy=True)[source]¶ Create a matrix with the 2-dimensional data.
If not _copy then data is directly used without copy. In this case, data must be a correct list of list of float. (Option not available in SimpleGUI of CodeSkulptor.)
Parameters: - data – (not empty tuple or list) of (same size tuple or list) of (int or float)
- _copy – bool
-
__mul__
(other)[source]¶ To a matrix (m x k) return the matrix multiply by other.
Parameters: other – Matrix (k x n) Returns: Matrix (m x n)
-
__setitem__
(i_j, value)[source]¶ Change the value of the element at row i and column j, to the (m x n) matrix.
Parameters: - i_j – (0 <= int < m, 0 <= int < n) or [0 <= int < m, 0 <= int < n]
- value – int or float
-
__sub__
(other)[source]¶ To a matrix (m x n) return the matrix minus other.
Parameters: other – Matrix (m x n) Returns: Matrix (m x n)
-
__weakref__
¶ list of weak references to the object (if defined)
-
_is_identity
(epsilon=2.220446049250313e-16)[source]¶ If the matrix is an identity matrix then return True, else return False.
(Not available in SimpleGUI of CodeSkulptor.)
Parameters: epsilon – 0 <= (float or int) < 1 Returns: bool
-
_is_zero
(epsilon=2.220446049250313e-16)[source]¶ If the matrix is a zeros matrix then return True, else return False.
(Not available in SimpleGUI of CodeSkulptor.)
Parameters: epsilon – 0 <= (float or int) < 1 Returns: bool
-
_nb_columns
()[source]¶ Return n for a (m x n) matrix.
(Not available in SimpleGUI of CodeSkulptor.)
Returns: int >= 1
-
_nb_lines
()[source]¶ Return m to a (m x n) matrix.
(Not available in SimpleGUI of CodeSkulptor.)
Returns: int >= 1
-
abs
()[source]¶ To a matrix (m x n) return the matrix with each element is the absolute value.
Returns: Matrix (m x n)
-
getcol
(j)[source]¶ Return the (1 x m) matrix that is a copy of column j of the (m x n) matrix.
Parameters: j – 0 <= int < n Returns: Matrix (1 x m)
-
getrow
(i)[source]¶ Return the (1 x n) matrix that is a copy of row i of the (m x n) matrix.
Parameters: i – 0 <= int < m Returns: Matrix (1 x n)
-
inverse
(_epsilon=2.220446049250313e-16)[source]¶ If the square matrix (n x n) is inversible then return the inverse, else raise an ValueError exception.
Algorithm used: Gaussian elimination. See http://en.wikipedia.org/wiki/Gaussian_elimination .
Parameters: _epsilon – 0 <= (float or int) < 1 (Option not available in SimpleGUI of CodeSkulptor.) Returns: Matrix (n x n) Raise: ValueError if the matrix is not inversible
-
-
SimpleGUICS2Pygame.numeric.
_EPSILON
= 2.220446049250313e-16¶ The default epsilon value.
-
SimpleGUICS2Pygame.numeric.
_zero
(m, n)[source]¶ Return a (m x n) zeros matrix.
Parameters: - m – int >= 1
- n – int >= 1
Returns: Matrix (m x n)
-
SimpleGUICS2Pygame.numeric.
identity
(size)[source]¶ Return a (size x size) identity matrix.
Parameters: size – int >= 1 Returns: Matrix (size x size)
[source]