I have 3 matrices. I want to find the shared elements within these matrices with the number of repetition.
matrix 1:
1 2 3 4
5 3 2 1
3 2 1 0
0 2 1 4
matrix 2:
1 2 3 4
0 1 2 1
3 1 0 2
2 5 3 1
matrix 3:
2 3 1 0
3 2 1 0
4 0 2 1
2 3 0 1
imagine these three matrices make the Local_Connectivities which is a vector of vector of vector and each of these matrices are going to be sent to different processors. before that I need to know which points will be shared between processors.
the thing that come to my mind is looping over all matrices , but I think it gonna be a little messy, having many for loops with if condition.
you are making more work for yourself.
if you need to know something like this, track it on the front end... when you divide up the mesh to do your parallel processing, either do it in a systematic way (eg, every 1000x1000 block) or if you need to do it irregularly, store something -- if they are rectangular store the top and bottom corners (diagonal, top left bottom right). If they are not rectangular, you may need to store the coordinates of the entire boundary of each ROI. But don't try to *find* something like this, you already KNOW it, somewhere, somehow, so take what you know and stow it rather than try to rebuild it.
If this is not sufficient to detect overlapped points, it is enough to re-create that with minimal effort I believe.
what is a point, in the above?
matrix 1,2,3 all[0] ?
I think you need a concept of a point in your code. a tuple or something simple will do.
then a map or set or something to contain them will let you quickly see if a is in b etc.