Models with Matrices and Linear Equations 267
Executing the Python interpreter and running the program in file
tmat5.py, yields the following output. Note that matrices amat and bmat
are two-dimensional arrays with three rows and two columns.
$ python tmat5.py
Matrix scalar and elementwise multiplication
Matrix amat:
[[ 1. 3.]
[ 2. 5.]
[ 4. 7.]]
Matrix bmat:
[[ 2.5 1.5 ]
[ 3. 1.5 ]
[ 2. 4.25]]
Matrix cmat:
[[ 2. 6.]
[ 4. 10.]
[ 8. 14.]]
Matrix dmat:
[[ 2.5 4.5 ]
[ 6. 7.5 ]
[ 8. 29.75]]
Matrix scalar division involves dividing each element of the matr ix by the
value of the scalar. With Numpy, the division operator (/) is applied directly
for dividing the specified matrix by the constant factor.
Element-by-element matrix division involves dividing the corresponding ...