for (int i = 0; i < HalfSize; i++)
{
for (int j = 0; j < HalfSize; j++)
{
A11[i][j] = MatrixA[i][j];
A12[i][j] = MatrixA[i][j + HalfSize];
A21[i][j] = MatrixA[i + HalfSize][j];
A22[i][j] = MatrixA[i + HalfSize][j + HalfSize];
B11[i][j] = MatrixB[i][j];
B12[i][j] = MatrixB[i][j + HalfSize];
B21[i][j] = MatrixB[i + HalfSize][j];
B22[i][j] = MatrixB[i + HalfSize][j + HalfSize];
}
}
N/2
, можно так: for (int i = 0; i < HalfSize; i++)
{
int k = i + HalfSize;
for (int j = 0; j < HalfSize; j++)
{
int l = j + HalfSize;
A11[i][j] = MatrixA[i][j];
A12[i][j] = MatrixA[i][l];
A21[i][j] = MatrixA[k][j];
A22[i][j] = MatrixA[k][l];
B11[i][j] = MatrixB[i][j];
B12[i][j] = MatrixB[i][l];
B21[i][j] = MatrixB[k][j];
B22[i][j] = MatrixB[k][l];
}
}
7*HalfSize^2 – HalfSize
сложений =)for (int i = 0; i < HalfSize ; i++)
{
for (int j = 0 ; j < HalfSize ; j++)
{
MatrixC[i][j] = C11[i][j];
MatrixC[i][j + HalfSize] = C12[i][j];
MatrixC[i + HalfSize][j] = C21[i][j];
MatrixC[i + HalfSize][j + HalfSize] = C22[i][j];
}
}
for (int i = 0; i < HalfSize ; i++)
{
int k = i + HalfSize;
for (int j = 0 ; j < HalfSize ; j++)
{
int l = j + HalfSize;
MatrixC[i][j] = C11[i][j];
MatrixC[i][l] = C12[i][j];
MatrixC[k][j] = C21[i][j];
MatrixC[k][l] = C22[i][j];
}
}
3*HalfSize^2 – HalfSize
сэкономленных сложений.N/2
(17 это количество вхождений, а не вычислений), выгода составляет12*HalfSize^2 + 2*HalfSize + 3
операций целочисленного деления пополам и 10*HalfSize^2 – 2*HalfSize
целочисленных сложений на один проход функции Strassen
без учета рекурсии.