I would like to multiply two vectors, one column (i.e. (N + 1) x1), one row (i.e. 1x (N + 1)) to give (N + 1) x (N + 1) . I am new to Numpy, but have some experience with MATLAB, this is the equivalent code in MATLAB for what I want in Numpy:
n = 0:N; xx = cos(pi*n/N)'; T = cos(acos(xx)*n');
in Numpy I tried:
import numpy as np n = range(0,N+1) pi = np.pi xx = np.cos(np.multiply(pi / float(N), n)) xxa = np.asarray(xx) na = np.asarray(n) nd = np.transpose(na) T = np.cos(np.multiply(np.arccos(xxa),nd))
I added the asarray line after I noticed that without it, apparently, Numpy treats xx and n as lists. np.shape(n) , np.shape(xx) , np.shape(na) and np.shape(xxa) give the same result: (100001L,)
source share