Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You're incrementing the index variable twice before using it in mycompare[index]. So, for the first run of the loop, you first set mycompare[0] to some binary matrix, and then you try to set the value of myCounts[1] to the number of non-zero elements of mycompare[2]. And yep, mycompare[2] is still and invalid matrix. Use this: for ( int k = idx + 1; k < N; k ++ ) { mycompare[ index ] = ( A[ idx ] == A[ k ] ); myCounts[ index ] = countNonZero( mycompare[ index ] ); index++; }

You're incrementing the index variable twice before using it in mycompare[index]. So, for the first run of the loop, you first set mycompare[0] to some binary matrix, and then you try to set the value of myCounts[1] to the number of non-zero elements of mycompare[2]. And yep, mycompare[2] is still and invalid matrix. Use this: this:

for ( int k = idx + 1; k < N; k ++ )
    {
         mycompare[ index ] = ( A[ idx ] == A[ k ] );
         myCounts[ index ] = countNonZero( mycompare[ index ] );
         index++;
     }

}

You're incrementing the index variable twice before using it in mycompare[index]. So, for the first run of the loop, you first set mycompare[0] to some binary matrix, and then you try to set the value of myCounts[1] to the number of non-zero elements of mycompare[2]. And yep, mycompare[2] is still and an invalid matrix. Use this:

for ( int k = idx + 1; k < N; k ++ )
    {
         mycompare[ index ] = ( A[ idx ] == A[ k ] );
         myCounts[ index ] = countNonZero( mycompare[ index ] );
         index++;
     }