'Summing all elements of a numpy array pair-wisely and creating a matrix

What is the fastest way to generate a numpy array (A) of size n*n from a numpy vector (a) with n elements, so that (i,j)th element of A will be equal to the sum of i'th and j'th element of a. As an example if I have the vector [1,2,3] I want to get [[2,3,4],[3,4,5],[4,5,6]]. Is there any pre-implemented function to do so?



Sources

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

Source: Stack Overflow

Solution Source