Tutorial by Examples

Matrix multiplication can be done in two equivalent ways with the dot function. One way is to use the dot member function of numpy.ndarray. >>> import numpy as np >>> A = np.ones((4,4)) >>> A array([[ 1., 1., 1., 1.], [ 1., 1., 1., 1.], [ 1., 1.,...
The dot function can also be used to compute vector dot products between two one-dimensional numpy arrays. >>> v = np.array([1,2]) >>> w = np.array([1,2]) >>> v.dot(w) 5 >>> np.dot(w,v) 5 >>> np.dot(v,w) 5
The numpy dot function has an optional parameter out=None. This parameter allows you to specify an array to write the result to. This array must be exactly the same shape and type as the array that would have been returned, or an exception will be thrown. >>> I = np.eye(2) >>> I ...
numpy.dot can be used to multiply a list of vectors by a matrix but the orientation of the vectors must be vertical so that a list of eight two component vectors appears like two eight components vectors: >>> a array([[ 1., 2.], [ 3., 1.]]) >>> b array([[ 1., 2., ...

Page 1 of 1