
272 Introduction to Computational Models with Python
>, >=, <, and <=. These are element-wise operations on the matrices. Function
array
equal returns the single truth value True if two arrays have the same
shape a nd elements and False otherwise.
The following program is stored in file tmat9.py and applies the various
relational op erators on matr ices. In line 9, function array
equal is called to
compare the shape and elements of matrices amat and bmat. In the rest of
the program the relational operators are directly a pplied.
1 import numpy as np
2 print "Relational operations on matrices"
3 amat = np.array([[1.0, 3.0], [2.0, 5.0], [4.0, 7.0]])
4 print ...