polynomial squaring

This commit is contained in:
Mirek Kratochvil 2012-04-02 19:16:32 +02:00
parent 575cdca736
commit ec5b6c36b1
2 changed files with 18 additions and 1 deletions

View file

@ -100,7 +100,7 @@ public:
polynomial gcd (polynomial);
bool is_irreducible();
void generate_random_irreducible (uint n, prng&);
vector operator<< (uint);
void compute_mod_squaring_matrix (matrix&);
};
/*

View file

@ -118,3 +118,20 @@ void polynomial::generate_random_irreducible (uint s, prng & rng)
}
}
void polynomial::compute_mod_squaring_matrix (matrix&r)
{
int d = degree();
if (d < 0) return;
r.resize (d);
polynomial col, t;
for (int i = 0; i < d; ++i) {
col.clear();
col.resize (i + 1, 0);
col[i] = 1;
t = col;
col.mult (t);
col.mod (*this);
col.resize (d, 0);
r[i] = col;
}
}