これは本当にばかげているように聞こえるかもしれません..そして、私はおそらく本当にばかげた何かを見逃しています..なぜ私のアルゴリズムには最小の数が欠けているようで、その理由がわかりません..
コードは次のとおりです。
int min_val = 0;
double comp = 0;
const int ROW_BOUNDS(mat1Rows-mat2Rows+1);
const int COL_BOUNDS(mat1Cols-mat2Cols+1);
for(int i=0; (i < ROW_BOUNDS); i++) {
for(int j=0; (j < COL_BOUNDS); j++) {
m3.clear();
for (int row(0); row < mat2Rows; row++){
for (int col(0); col < mat2Cols; col++){
//cout << matrix1[i*mat1Cols+row*mat1Cols+col+j] << ' ';
m3.push_back( matrix1[i*mat1Cols+row*mat1Cols+col+j] );
currentRow = i;
currentCol = j;
}
}
comp = compMatrix1(matrix2, m3);
//printMatrix(m3, 2, 2);
//cout << endl << " = " << comp << endl;
if(comp < min_val)
{
minRow = currentRow;
minCol = currentCol;
m4 = m3;
min_val = comp;
cout << min_val;
}
}
}
//printMatrix(m4, 2, 2);
出力は次のとおりです。
0 0
0 0
= 2
0 1
0 1
= 4
1 0
1 0
= 0
0 0
1 1
= 2
0 1
1 1
= 3
1 0
1 0
= 0
1 1
0 1
= 3
1 1
1 0
= 1
1 0
0 0
= 1
それは印刷します:
0 0
0 0
実際の結果は次のようになります。
1 0
1 0
誰か助けてください。