# Revision history [back]

This is a solution without STL. It is very ugly, though.

// keep only unique rows
Mat allPairs;       // Mat with duplicate values
Mat uniqueStrides;  // Mat that will contain the unique values
uniqueStrides.push_back( allPairs.row(0) );
for (int i = 1; i < allPairs.rows; ++i) {
int isInside = false;
for (int j = 0; j < uniqueStrides.rows; ++j) {
int count = 0;
for (int k = 0; k < uniqueStrides.cols; ++k) // checks by element of
if(allPairs.at<int>(i,k) == uniqueStrides.at<int>(j,k))
++count;
if (count == 2) {
isInside = true;
break;
}
}
if (isInside == false) uniqueStrides.push_back( allPairs.row(i) );
}


This is a solution without STL. It is very ugly, though.

// keep only unique rows
Mat allPairs;       // Mat with duplicate values
Mat uniqueStrides;  // Mat that will contain the unique values
uniqueStrides.push_back( allPairs.row(0) );
for (int i = 1; i < allPairs.rows; ++i) {
int isInside = false;
for (int j = 0; j < uniqueStrides.rows; ++j) {
int count = 0;
for (int k = 0; k < uniqueStrides.cols; ++k) // checks by element of
if(allPairs.at<int>(i,k) == uniqueStrides.at<int>(j,k))
++count;
if (count == 2) {
isInside = true;
break;
}
}
if (isInside == false) uniqueStrides.push_back( allPairs.row(i) );
}


This algorithm checks for every uniqueStrides entry and for every value. As my matrices are n x 2, I check if the number of equal values is two:

...
if (count == 2)
isInside = true;
...


If positive, then this row is already in my matrix.