title: Matrix element comparison
body: <p>I have some problems with comparison of matrix elements. Here is the code:</p>
  
  <pre><code>int coll = 0;
  for (int i = 0; i &lt; 9; i++)
  {
      for (int j = 0; j &lt; 9; j++)
      {
          int tmp = 0;
          for (int k = 0; k &lt; 9; k++)
          {
              if (matrix[i, j] == matrix[i, k])
              {
                  tmp++;
                  Console.WriteLine("{0},{1} coll {2},{3}-al", i, j, i, k);
              }
              coll += tmp;
          }
  
      }
  }
  </code></pre>
  
  <p>The code wants to compare the elements of an array called <code>matrix</code>. When 2 elements in a column are the same, I'll increase the <code>tmp</code> value. At the end <code>coll</code> will be increased by the number of the collisions of the actual element of the array. The problem is that the program will find only the collisions of the element with itself. For example, for a matrix like</p>
  
  <pre><code>1234
  1342
  2341
  2413
  </code></pre>
  
  <p>the 0:0 position will collide only with itself and not with 1:0. Can anyone tell me why?</p>