model_server/edge/src/matrix.cxx
/*
 * crossings_quick
 * assumes that there is at most one edge from position i on the upper level
 * and position j on the lower level. This avoids a multiplication but
 * does not give the exact number of crossings if the assumption is broken.
 */
crossings_quick
assumes that there is at most one edge from position i on the upper level
and position j on the lower level. This avoids a multiplication but
does not give the exact number of crossings if the assumption is broken.
crossings_quick assumes that there is at most one edge from position i on the upper level and position j on the lower level . This avoids a multiplication but does not give the exact number of crossings if the assumption is broken .
int 
matrix::crossings_quick() 
{
  register int i , k , submatrix , s;
  s = 0;
  edge_vector subrow(rows);
  for (i=0; i<rows; i++) subrow[i] = 0;
  for (k=1; k<columns; k++) {
    subrow[rows-1] += m[rows-1][k-1];
    submatrix = subrow[rows-1];
    for (i=rows-2; i>=0; i--) {
      s += submatrix;
      subrow[i] += m[i][k-1];
      submatrix += subrow[i];
    }
  }
  return s;
}
int matrix :: crossings_quick ( ) { register int i , k , submatrix , s ; s = 0 ; edge_vector subrow ( rows ) ; for ( i = 0 ; i < rows ; i ++ ) subrow [ i ] = 0 ; for ( k = 1 ; k < columns ; k ++ ) { subrow [ rows - 1 ] += m [ rows - 1 ] [ k - 1 ] ; submatrix = subrow [ rows - 1 ] ; for ( i = rows - 2 ; i >= 0 ; i -- ) { s += submatrix ; subrow [ i ] += m [ i ] [ k - 1 ] ; submatrix += subrow [ i ] ; } } return s ; }
crossings_quick
 assumes that there is at most one edge from position i on the upper level
 and position j on the lower level.
crossings_quick assumes that there is at most one edge from position i on the upper level and position j on the lower level .