During calculating the distance matrix between two feature maps.
A:(M,1)
B:(N,1)
I want to repeat B columns to equal A rows.
It is simple in NumPy:
A = np.random,rand(100, 1)
B = np.random.rand(88, 1)
np.repeat(B, A.shape[0], axis=1)
But in c Eigen, not work for dynamically assigning repeated shapes.
MatrixXi A = MatrixXi::Random(100,1);
MatrixXi B = MatrixXi::Random(88,1);
B.replicate<1, A.rows()>(); // This will cause failure
CodePudding user response:
The correct way to achieve the same effect as the python's numpy version in C would be:
B.replicate<1, 100>();
The above will do the replication as you want.
Or you can use:
B.replicate(1, A.rows());