# mdifying a code for nested matrices

I have a matrix such as:

 tT = {{a, b, c}, {d, e, f}, {g, h, i}};
a = {{0, 0, 1}, {0, 1, 0}, {1, 0, 0}};
b = {{1, 0, 0}, {0, 0, 0}, {0, 1, 0}};
c = {{0, 0, 0}, {1, 0, 1}, {0, 0, 0}};
d = {{1, 0, 0}, {0, 1, 0}, {0, 1, 0}};
e = {{0, 1, 0}, {1, 0, 0}, {1, 0, 0}};
f = {{0, 1, 0}, {1, 0, 0}, {0, 0, 1}};
g = {{1, 0, 0}, {0, 0, 0}, {0, 0, 1}};
h = {{0, 0, 0}, {0, 1, 0}, {0, 0, 0}};
i = {{1, 0, 0}, {0, 0, 0}, {1, 0, 0}};


That the picture of matrix is same as:

In the first step, I want to comprise, elements of tT11 with the elements of tT12, also comprise between elements of tT11 with the elements of tT13. Moreover, comprise between elements of tT12 with the elements of tT13 . After that tT21 with tT22 and tT23 and so on.

If at least one of the corresponding elements of tT11 and tT12 are simultaneously equal to 1, I want to put a zero instead of all elements in tT12. Also, there is such comprising between elements of tT11 with the elements of tT13 with the same condition.(moreover, tT12 and tT13). Also corresponded element in other rows. I write bellow line:

Do[
If[tT[[r, n, k, q]] == tT[[r, m, k, q]]==1,
Do[tT[[r, m, x, y]] = 0,{x,1,3},{y,1,3}]],
{r, 1, 3}, {n, 1, 2}, {k, 1, 3}, {q, 1, 3}, {m, n + 1, 3}]


Actually, my desire is to get the result that I bring it bellow: I am going to generalize this goal to a very larger matrix and this matrix (tT 3*3) is just an example. How can I modify above written process (code) for more efficiency. How can I replace other commands instead of two 'DO's. my desire result is:

Thank you so much for your attention

-
By "If simultaneously, just one of the element of tT11 and tT12 equal to 1 ...",do you mean "one and only one" or "at least one"? –  belisarius Jun 2 at 14:39
at least one. ok I will correct the sentence. –  mostafa Jun 2 at 14:40
@mostafa See a closely related post How to Flatten Array of Arrays of the highest order in a simple way?. –  Artes Jun 2 at 21:14
@mostafa I don't really understand why T23_33 is equal to 0 in your example. (same goes with T33_31) –  Öskå Jun 3 at 12:22
What is T23_33? –  mostafa Jun 3 at 13:46