# Checking Equal Differences between Indices

There is a matrix (4*4) m as below one:

m={{r[1,256]+r[2,257]+r[3,258]+r[4,259]+...},
{r[309,700]+r[310,701]+r[311,702]+r[312,710]+....},......}


I do not write all of elements. The r[i,j] is created by a table and after a calculation its elements have appeared in the m. But in any elements of m, I want to see the difference between j and i. For example 256-1=255 for the first step. It must be repeated to all others which are adding to that. If for a special r, j-i is not equal to the others, I can see that r. I mean If I have

m={{r[1,256]+r[2,257]+r[3,258]+r[4,259]+...+r[10,267]},
{r[309,700]+r[310,701]+r[311,702]+r[312,710]+....},......}


I must be notified that r[10,267] is wrong. Because it must be r[10,265].

Since There are many elements contribute to m I am not able to do that by hand. How can I gain this goal?

Let's make some fake data to play with:

data = Table[r[n + m, 255 + n + m], {n, 1, 20}, {m, {0, 10}}];


Then let's introduce an error:

data = data /. r[3, 258] -> r[3, 1000];


We can then conditionally format the r items that do not correspond to your rule:

data /. r[i_, j_] /; i + 255 != j :> Style[r[i, j], Red, Bold, Background -> Yellow]


As you can see, the offending item is visually highlighted in the output.

• I am grateful to receive again one of your perfects answers as before. – Unbelievable Jun 8 '17 at 10:10
• @Irreversible that's very kind, you are welcome! – MarcoB Jun 8 '17 at 13:36