The outer1
function computes the \(n \times n\) symmetric matrix
$$
\text{\texttt outer1}(X, f) =
\begin{bmatrix}
f(x_1, x_1) & \cdots & f(x_1, x_n) \cr
\vdots & \ddots & \vdots \cr
f(x_n, x_1) & \cdots & f(x_n, x_n) \cr
\end{bmatrix}
$$
and the outer1_matvec
operation computes the \(n\)-dimensional vector
$$
\text{\texttt outer1\_matvec}(X, f, a) =
\begin{bmatrix}
f(x_1, x_1) & \cdots & f(x_1, x_n) \cr
\vdots & \ddots & \vdots \cr
f(x_n, x_1) & \cdots & f(x_n, x_n) \cr
\end{bmatrix}
\begin{bmatrix}
a_1 \cr
\vdots \cr
a_n \cr
\end{bmatrix}.
$$
The outer2
operation computes the \(m \times n\) matrix
$$
\text{\texttt outer2}(X, Y, f) =
\begin{bmatrix}
f(x_1, y_1) & \cdots & f(x_1, y_n) \cr
\vdots & \ddots & \vdots \cr
f(x_m, y_1) & \cdots & f(x_m, y_n) \cr
\end{bmatrix}
$$
and the outer2_matvec
operation computes the \(m\)-dimensional vector
$$
\text{\texttt outer2\_matvec}(X, Y, f, a) =
\begin{bmatrix}
f(x_1, y_1) & \cdots & f(x_1, y_n) \cr
\vdots & \ddots & \vdots \cr
f(x_m, y_1) & \cdots & f(x_m, y_n) \cr
\end{bmatrix}
\begin{bmatrix}
a_1 \cr
\vdots \cr
a_n \cr
\end{bmatrix}.
$$