4.3.11 MMatrix

The following MMatrix methods differ from their C++ counterparts.

get( )
Returns the matrix as a list of four rows where each row is again a list of four floats.

Using the index operator is slightly different than in C++. You can use the index operator to read or write an entire row of the matrix or an individual element:

>>> m=MMatrix([[1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,16]])
>>> print m[0]
[1.0, 2.0, 3.0, 4.0]
>>> print m[0,1]
>>> m[0] = [1,0,0,0]
>>> print m[0,1]

The row is returned as a list, so you can also write m[0][1] instead of m[0,1] when you want to read values. Note however that this will inot work for writing values because this would just modify the intermediate list containing the row and not the actual matrix.