Skip to content

Commit

Permalink
Merge pull request #31 from veronicaz41/vzheng/ses
Browse files Browse the repository at this point in the history
[fix] Rename eval to make it SES compatible
  • Loading branch information
OBrezhniev authored Apr 9, 2024
2 parents c37d3a4 + 530e79e commit 0d30b77
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions build/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,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 @@ -527,7 +527,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

0 comments on commit 0d30b77

Please sign in to comment.