Previous Up Next

2.42.25Define a matrix : matrix

matrix takes three arguments :

matrix returns the matrix A=(aj,k) (j=1..n and k=1..p) of dimension n p.
Input :

matrix(4,3,(j,k)->j+k)

or first define the h function:

h(j,k):=j+k

then, input:

matrix(4,3,h)

Output :

[[2,3,4],[3,4,5],[4,5,6],[5,6,7]]

Note the argument order and the fact that the indices are counted starting from 1. If the last argument is not provided, it defaults to 0.


Previous Up Next