Home | Trees | Indices | Help |
|
---|
|
object --+ | list --+ | Matrix
Matrix type
This class implements the Matrix type, based on the Python lists. The matrix object is a list of lists and have 2 properties ('cols' and 'rows'), that store the sizes of the matrix. For example:
>>> a = Matrix([ ... [1, 2, 3], ... [2, 3, 4], ... [3, 4, 5], ... ]) >>> >>> print a 1 2 3 2 3 4 3 4 5 >>> >>> a.rows 3 >>> a.cols 3
|
|||
new list |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from |
|
|||
Inherited from |
|
|||
Inherited from |
|
Initialization of Matrix object This method initialize a Matrix object, calculating the values of the properties 'cols' and 'rows'.
|
String representation This method returns the string representation of matrices. For example: 1 2 3 2 3 4 3 4 5
|
Callable object This method returns a row Matrix object if a parameter is used and a number if two parameters are used. For example: >>> a = Matrix([ ... [1, 2], ... [3, 4], ... ]) >>> >>> b = a(1) >>> print b 3 4 >>> type(b) <class 'controlsystems.types.Matrix'> >>> >>> c = a(0, 0) >>> print c 1 >>> type(c) <type 'int'> |
Operation of addition This method returns a Matrix object with the result of the addition of the Matrix 'self' and the Matrix 'mat'. For example: >>> a = Matrix([ ... [1, 2], ... [3, 4], ... ]) >>> >>> b = Matrix([ ... [2, 3], ... [4, 5], ... ]) >>> >>> c = a + b >>> print c 3 5 7 9 >>> type(c) <class 'controlsystems.types.Matrix'>
|
Operation of subtraction This method returns a Matrix object with the result of the subtraction of the Matrix 'self' and the Matrix 'mat'. For example: >>> a = Matrix([ ... [2, 3], ... [4, 5], ... ]) >>> >>> b = Matrix([ ... [1, 2], ... [3, 4], ... ]) >>> >>> c = a - b >>> print c 1 1 1 1 >>> >>> type(c) <class 'controlsystems.types.Matrix'> This method is based on __add__ method |
Operation of multiplication of polynomials This method returns a Matrix object with the result of the multiplication of the Matrix 'self' and the Matrix 'mat'. For example: >>> a = Matrix([ ... [1, 2], ... [3, 4], ... ]) >>> >>> b = Matrix([ ... [2, 3], ... [4, 5], ... ]) >>> >>> c = a * b >>> print c 10 13 22 29 >>> >>> type(c) <class 'controlsystems.types.Matrix'>
|
Operation of multiplication between numbers and matrices This method returns a Matrix object with the result of the multiplication of the Matrix 'self' and the number 'num'. For example: >>> a = Matrix([ ... [1, 2], ... [3, 4], ... ]) >>> >>> b = a.mult(5) >>> print b 5 10 15 20 >>> >>> type(b) <class 'controlsystems.types.Matrix'> |
Transpose of matrix This method returns a Matrix object with the transpose of the Matrix 'self'. For example: >>> a = Matrix([ ... [1, 2], ... [3, 4], ... ]) >>> >>> b = a.transpose() >>> print b 1 3 2 4 >>> >>> type(b) <class 'controlsystems.types.Matrix'> |
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Nov 19 01:50:56 2009 | http://epydoc.sourceforge.net |