Constructing a matrix whose elements are the differences between elements of a vector using the Eigen library in c++

Consider a vector initialized as: Eigen::Vector A ={a1, a2} I would like to efficiently construct a matrix like: A = {{a11, a12}, {a21, a22}} where aij = ai - aj In other words, the elements of the matrix are differences of the elements of the vector. How can I do this efficiently using the Eigen library in C++?

Constructing a matrix whose elements are the differences between elements of a vector using the Eigen library in c++

Consider a vector initialized as:

Eigen::Vector A ={a1, a2}

I would like to efficiently construct a matrix like:

 A = 
     {{a11, a12},
     {a21, a22}}

where aij = ai - aj

In other words, the elements of the matrix are differences of the elements of the vector. How can I do this efficiently using the Eigen library in C++?