'Dot Product of Two 2-D Column Vectors Using Numpy (Without Transpose)

I am trying to calculate dot product of two 2D vectors using numpy Here is what I know so far:

  1. If we have two 1D np arrays like v and w, we can use np.inner(v, w) to get the dot product of these two vectors but since 1D arrays have shape of (m, ) I don't like to use them due to making troubles by that lost second dimension in (m, )
  2. If we use 2D arrays to define v and w like below:
    v = np.array([[1], [3], [5]])
    w = np.array([[2], [4], [6]])

We can calculate the dot product by transposing one of these vectors and then using matrix multiplication:

    vdotw = v.T @ w

or:

   vdotw = w.T @ v

My question is that is there any method is numpy that specifically calculate dot product of two vectors (defined as 2D arrays not those funny 1D arrays) directly and without transposing one of them?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source