Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Rename eval to make it SES compatible #31

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ class PolField {
return v;
}

eval(p,x) {
evaluate(p,x) {
const F = this.F;
if (p.length == 0) return F.zero;
const m = this._next2Power(p.length);
Expand Down Expand Up @@ -853,7 +853,7 @@ class PolField {
let mpol = this.ruffini(roots, points[i][0]);
const factor =
this.F.mul(
this.F.inv(this.eval(mpol, points[i][0])),
this.F.inv(this.evaluate(mpol, points[i][0])),
points[i][1]);
mpol = this.mulScalar(mpol, factor);
sum = this.add(sum, mpol);
Expand Down
4 changes: 2 additions & 2 deletions src/polfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export default class PolField {
return v;
}

eval(p,x) {
evaluate(p,x) {
const F = this.F;
if (p.length == 0) return F.zero;
const m = this._next2Power(p.length);
Expand Down Expand Up @@ -223,7 +223,7 @@ export default class PolField {
let mpol = this.ruffini(roots, points[i][0]);
const factor =
this.F.mul(
this.F.inv(this.eval(mpol, points[i][0])),
this.F.inv(this.evaluate(mpol, points[i][0])),
points[i][1]);
mpol = this.mulScalar(mpol, factor);
sum = this.add(sum, mpol);
Expand Down
10 changes: 5 additions & 5 deletions test/pols.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ describe("Polynomial field", () => {
it("Should evaluate and zero", () => {
const PF = new PolField(new ZqField(r));
const p = [PF.F.neg(PF.F.e(2)), PF.F.e(1)];
const v = PF.eval(p, PF.F.e(2));
const v = PF.evaluate(p, PF.F.e(2));
assert(PF.F.eq(v, PF.F.e(0)));
});
it("Should evaluate bigger number", () => {
const PF = new PolField(new ZqField(r));
const p = [PF.F.e(1), PF.F.e(2), PF.F.e(3)];
const v = PF.eval(p, PF.F.e(2));
const v = PF.evaluate(p, PF.F.e(2));
assert(PF.F.eq(v, PF.F.e(17)));
});
it("Should create lagrange polynomial minmal", () => {
Expand All @@ -148,7 +148,7 @@ describe("Polynomial field", () => {
const p=PF.lagrange(points);

for (let i=0; i<points.length; i++) {
const v = PF.eval(p, points[i][0]);
const v = PF.evaluate(p, points[i][0]);
assert(PF.F.eq(v, points[i][1]));
}
});
Expand All @@ -164,7 +164,7 @@ describe("Polynomial field", () => {
const p=PF.lagrange(points);

for (let i=0; i<points.length; i++) {
const v = PF.eval(p, points[i][0]);
const v = PF.evaluate(p, points[i][0]);
assert(PF.F.eq(v, points[i][1]));
}
});
Expand Down Expand Up @@ -211,7 +211,7 @@ describe("Polynomial field", () => {
const p = PF.ifft(a);

for (let i=0; i<a.length; i++) {
const s = PF.eval(p, PF.oneRoot(8,i));
const s = PF.evaluate(p, PF.oneRoot(8,i));
assert(PF.F.eq(s, a[i]));
}

Expand Down