Suppose that we want to compute the outer product of a vector with itself:
import numpy as np
a = np.asarray([1, 1.5, 2, 2.5, 3])
A = np.outer(a, a)
print(A)
which results in:
[[ 1. 1.5 2. 2.5 3. ]
[ 1.5 2.25 3. 3.75 4.5 ]
[ 2. 3. 4. 5. 6. ]
[ 2.5 3.75 5. 6.25 7.5 ]
[ 3. 4.5 6. 7.5 9. ]]
This results in a symmetric matrix. Prior knowledge of the fact that the two vectors in the outer product are the same could be exploited by only computing one triangle of the matrix, and filling in the remaining entries from the corresponding entries in the triangle.
Question: are there any easy ways to exploit such knowledge in numpy
(or other solutions in Python)? Of course, it wouldn't be too difficult to write a custom solution in Python, but if that comes at the cost of not using a solid BLAS it would be unlikely to be worth it.
I am primarily concerned with computation time, not so much necessarily with RAM usage.