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<int, 1, A.rows()>(); // This will cause failure
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.