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
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
Sounak Kar
Sounak Kar 2019-2-7
Thanks for the link, Luna. I think this is relevant but I'm particularly looking for efficient row search in tall arrays.
The relation is determined by a given rule. In this case, I just know that (i, j, k) is related to (i-1, j, k+1) and (i, j-1, k+1) when i>0 and j>0. But I would say I'm more concerned with searching for a row in a tall array.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by