Previous Up Next

5.48.2  Changing a matrix by multi-assigment

You can use assignment to change several entries of a matrix at one. For example, to create a diagonal matrix with a diagonal of [1,2,3]:
Input:

M := matrix(3,3)

Output:

[[0,0,0],[0,0,0],[0,0,0]]

Input:

M[0..2,0..2] := [1,2,3]

Output:

matrix[[1,0,0],[0,2,0],[0,0,3]]

To make the last column [4,5,6]:
Input:

M[0..2,2] := [4,5,6]

Output:

matrix[[1,0,4],[0,2,5],[0,0,6]]

Previous Up Next