Searching for indices of rows in a matrix with 10 million rows
1 次查看(过去 30 天)
显示 更早的评论
I have a matrix with few million unique rows (let's call the number of rows n) and 7 columns. Each row respresents an ID and is (directionally) related to another ~ 10 rows. The relation is specified through some known operation on the row. I want to end up with a matrix with two columns where each row contains the indices of the rows in the original matrix which are related. However, this needs ~(n x 10) lookups in a matrix of size n which makes things pretty slow. I tried using hashmaps (quite uninitiated there) but MATLAB won't let me create a cell of size n which I intend to use as a set of keys. Is there a way to do this? Below is a representative example showing the input and desired output.
Input matrix:
[ 1 1 0;
0 1 1;
0 0 2;
1 0 1]
and let's assume (1 1 0) is related to (0 1 1) and (0 1 1), (0 1 1) to (0 0 2), (0 0 2) to (1 1 0) and (1 0 1) to (0 0 2).
The output then should be
[1 2;
1 3;
2 3;
3 4;
4 1]
2 个评论
Luna
2019-2-7
What is the relation? How did you decide (1 1 0) is related to (0 1 1) and (0 1 1) ?
I recommend you to read about: Tall Arrays
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!