| Home | Trees | Indices | Help |
|
|---|
|
|
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from |
|||
|
|||
|
Inherited from |
|||
|
|||
Initializes a matrix to contain specific values. The rows is a list of lists. |
Initializates a matrix. The arguments can be either a number m and n counting rows and columns of an all-zero matrix, or a list of lists representing the rows of the matrix.
|
Allows matrix entry assignment using [,]. The assignment works as follows: >>> M = Matrix(2, 2) >>> M[0, 1] = 42 >>> print M [[ 0 42] [ 0 0]] |
Allows matrix entry access using [, ]. The access works as follows: >>> M = Matrix([[1, 2], [3, 4]]) >>> print M[1,1] 4 |
Adds another matrix or an element to this matrix. Adds this matrix with another matrix, or adds the matrix with an element. The addition is done element-wise. >>> A = Matrix([[x + 2*y for x in range(2)] for y in range(2)]) >>> print A [[0 1] [2 3]] >>> print A + 10 [[10 11] [12 13]] >>> print A + A [[0 2] [4 6]] |
Matrix multiplication. Multiplies this matrix with another matrix, or multiplies the matrix with an element. >>> A = Matrix([[x + 2*y for x in range(2)] for y in range(2)]) >>> print A [[0 1] [2 3]] >>> print A * 10 [[ 0 10] [20 30]] >>> print A * A [[ 2 3] [ 6 11]] The matrices must have compatible dimensions: >>> Matrix(1, 5) * Matrix(2, 3) Traceback (most recent call last): ... ValueError: Matrix dimensions do not match for multiplication |
Returns a string representation of the matrix. >>> print Matrix([[x + 4*y for x in range(4)] for y in range(4)]) [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11] [12 13 14 15]]
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Mon Oct 19 16:43:42 2009 | http://epydoc.sourceforge.net |