Looking for more compact expression to generate matrix from vector

linear algebramatrices

Given a vector $v = \begin{pmatrix}
v_1 \\
v_2 \\
\vdots \\
v_n
\end{pmatrix}$
, I need to generate a matrix $A$

$$A = \begin{pmatrix}
0 & v_1 + v_2 & \cdots & v_1 + v_n \\
v_2 + v_1 & 0 & & v_2 + v_n \\
\vdots & & \ddots & \vdots \\
v_n + v_1 & v_n + v_2 & \cdots & 0 \\
\end{pmatrix}$$

Currently, I describe this as

$$A = (v J_{1,n} + J_{n,1} v^{T}) \circ (J_{n,n} – I_n)$$

$J_{n,m}$ is an $n\times m$ matrix of ones and $\circ$ is the element-wise product.

Is there a more compact expression to generate $A$, potentially using some special product?

Thank you for your help!

Best Answer

As stated in comments, you have $A_{ij}=v_i+v_j-2\delta_{ij}v_i$ which is probably most obvious and naïve method of generating $A$.

Related Question