mirror of
https://github.com/status-im/research.git
synced 2025-01-13 16:44:11 +00:00
A bit more minor optimization
This commit is contained in:
parent
d800eafa2a
commit
8672819248
@ -159,10 +159,10 @@ vector<int> subroot_linear_combination(vector<int> xs, vector<int> factors) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vector<int> derivative(vector<int> p) {
|
vector<int> derivative_and_square_base(vector<int> p) {
|
||||||
vector<int> o(p.size() - 1);
|
vector<int> o((p.size() - 1) / 2);
|
||||||
for (int i = 0; i < o.size(); i+= 2) {
|
for (int i = 0; i < o.size(); i+= 1) {
|
||||||
o[i] = p[i + 1];
|
o[i] = p[i * 2 + 1];
|
||||||
}
|
}
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
@ -181,10 +181,11 @@ vector<int> poly_to_logs(vector<int> p) {
|
|||||||
vector<int> lagrange_interp(vector<int> ys, vector<int> xs) {
|
vector<int> lagrange_interp(vector<int> ys, vector<int> xs) {
|
||||||
int xs_size = xs.size();
|
int xs_size = xs.size();
|
||||||
vector<int> root = mk_root(xs);
|
vector<int> root = mk_root(xs);
|
||||||
vector<int> log_rootprime = poly_to_logs(derivative(root));
|
vector<int> log_rootprime = poly_to_logs(derivative_and_square_base(root));
|
||||||
vector<int> factors(xs_size);
|
vector<int> factors(xs_size);
|
||||||
for (int i = 0; i < xs_size; i++) {
|
for (int i = 0; i < xs_size; i++) {
|
||||||
int denom = eval_log_poly_at(log_rootprime, xs[i]);
|
int x_square = xs[i] ? gexptable[glogtable[xs[i]] * 2] : 0;
|
||||||
|
int denom = eval_log_poly_at(log_rootprime, x_square);
|
||||||
if (ys[i])
|
if (ys[i])
|
||||||
factors[i] = gexptable[glogtable[ys[i]] + 65535 - glogtable[denom]];
|
factors[i] = gexptable[glogtable[ys[i]] + 65535 - glogtable[denom]];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user