Friday, March 15, 2019

[Tutorial][python] Scalar multiplication

This is the most basic method to do matrix calculation. In example shown below, 2 is so called scalar in this calculation. We multiply each number in matrix by this scalar 2, and mark multiplied result in same location in matrix.


With python, we can use .dot() to calculate the dot product for this matrix with scalar 2:

import numpy as np
from scipy import linalg
A = np.array([[4,0],[1,-9]])
print(A.dot(2))
Result :
[[ 8 0]
[ 2 -18]]

No comments :

Post a Comment