Looks like what you need is the @ matrix multiplication operator. dot method is only to compute dot product between vectors, what you want is matrix multiplication.
>>> a = np.random.rand(70, 1) >>> (a @ a.T).shape (70, 70)
UPDATE:
Above answer is incorrect. dot does the same things if the array is 2D. See the docs here.
np.dot computes the dot product of two arrays. Specifically,
- If both a and b are 1-D arrays, it is inner product of vectors (without complex conjugation).
- If both a and b are 2-D arrays, it is matrix multiplication, but using matmul or a @ b is preferred.
Simplest way to do what you want is to convert the vector to a matrix first using np.matrix and then using the @. Although, dot can also be used @ is better because conventionally dot is used for vectors and @ for matrices.
>>> a = np.random.rand(70) (70,) >>> a.shape >>> a = np.matrix(a).T >>> a.shape (70, 1) >>> (a @ a.T).shape (70, 70)
shapeofx.Tis the same as that ofx. This is because x is a one-dimensional array. You want to use 2-d arrays. Try usingnp.reshapeto make x 2 dimensional.dotis the inner product. The equivalent ofnp.sum(y*y), a scalar. To get a (70,70) you want the 'outer' product.