Что у меня не так в реализации? Почему-то вектор после преобразования получается не такой, какой получился в Maple
Код:
inline constexpr int FT_LENGTH = 12;
// Таблица для 2^n mod 13
int exp_table[13] = {
1,
2,
4,
8,
3,
6,
12,
11,
9,
5,
10,
7,
1
};
int mul_table[13][13] = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 },
{ 0, 2, 4, 6, 8, 10, 12, 1, 3, 5, 7, 9, 11 },
{ 0, 3, 6, 9, 12, 2, 5, 8, 11, 1, 4, 7, 10 },
{ 0, 4, 8, 12, 3, 7, 11, 2, 6, 10, 1, 5, 9 },
{ 0, 5, 10, 2, 7, 12, 4, 9, 1, 6, 11, 3, 8 },
{ 0, 6, 12, 5, 11, 4, 10, 3, 9, 2, 8, 1, 7 },
{ 0, 7, 1, 8, 2, 9, 3, 10, 4, 11, 5, 12, 6 },
{ 0, 8, 3, 11, 6, 1, 9, 4, 12, 7, 2, 10, 5 },
{ 0, 9, 5, 1, 10, 6, 2, 11, 7, 3, 12, 8, 4 },
{ 0, 10, 7, 4, 1, 11, 8, 5, 2, 12, 9, 6, 3 },
{ 0, 11, 9, 7, 5, 3, 1, 12, 10, 8, 6, 4, 2 },
{ 0, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }
};
void forward_transform(const int(&source)[FT_LENGTH], int(&target)[FT_LENGTH])
{
for (int k = 0; k < FT_LENGTH; ++k)
{
int sum = 0;
for (int i = 0; i < FT_LENGTH; ++i)
{
sum += exp_table[(i * k) % 13] * source[i];
}
target[k] = sum % 13;
}
}
int main()
{
int a[12] = {1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0};
int b[12] = { 0 };
int c[12] = { 0 };
forward_transform(a, b);
inverse_transform(b, c);
return 0;
}