next up previous
Next: Horner's Rule for a Up: Horner's Rule for Polynomials Previous: Evaluating a polynomial:


Doubly subscripted arrays (matrices) can be constructed as a list of vectors (lists), where each vector represents a row of the matrix. So to make a matrix b with n rows and m columns we could do this:

    b = [[0 for i in range(m)] for j in range(m)]
(You need to be careful about getting all the parentheses and brackets right.) Then we can refer to an element of the matrix with two subscripts, namely, b[i][j]. As you can see, setting up matrices in Python is a bit clunky. Later, we use the numpy package, which will make it more elegant.

Carleton DeTar 2017-09-19