Let's assume that we have a 10x20 real matrix:
We would like to construct a 10x10 matrix of the form
B = [v v ... v v]
v is a column vector of length
10. For this vector,
v, each element is the squared norm of each row of A, that is:
v = ( ||x_1||^2, ||x_2||^2, ..., ||x_10||^2,)^T,
x_j denotes the j-th row of A.
What is the most efficient way to construct matrix
I could construct
v as follows:
for (int i=1; i<10; i++)
v(i) = A.row(i).squaredNorm();
I think that this step cannot be solved without a
for loop. How could I replicate this column 10 times such that
B is filled as discussed above?