From 68f15baed476677dc73c239a85e0099408b709d4 Mon Sep 17 00:00:00 2001 From: Veronica Zheng Date: Thu, 17 Mar 2022 16:17:47 -0500 Subject: [PATCH 1/2] ses compatible - rename eval --- build/main.cjs | 4 ++-- src/polfield.js | 4 ++-- test/pols.js | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build/main.cjs b/build/main.cjs index 04bd6f8..11fe79a 100644 --- a/build/main.cjs +++ b/build/main.cjs @@ -822,7 +822,7 @@ class PolField { return v; } - eval(p,x) { + eval1(p,x) { const F = this.F; if (p.length == 0) return F.zero; const m = this._next2Power(p.length); @@ -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.eval1(mpol, points[i][0])), points[i][1]); mpol = this.mulScalar(mpol, factor); sum = this.add(sum, mpol); diff --git a/src/polfield.js b/src/polfield.js index 6f570cb..465e551 100644 --- a/src/polfield.js +++ b/src/polfield.js @@ -192,7 +192,7 @@ export default class PolField { return v; } - eval(p,x) { + eval1(p,x) { const F = this.F; if (p.length == 0) return F.zero; const m = this._next2Power(p.length); @@ -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.eval1(mpol, points[i][0])), points[i][1]); mpol = this.mulScalar(mpol, factor); sum = this.add(sum, mpol); diff --git a/test/pols.js b/test/pols.js index 6615ba7..5229252 100644 --- a/test/pols.js +++ b/test/pols.js @@ -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.eval1(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.eval1(p, PF.F.e(2)); assert(PF.F.eq(v, PF.F.e(17))); }); it("Should create lagrange polynomial minmal", () => { @@ -148,7 +148,7 @@ describe("Polynomial field", () => { const p=PF.lagrange(points); for (let i=0; i { const p=PF.lagrange(points); for (let i=0; i { const p = PF.ifft(a); for (let i=0; i Date: Sat, 26 Mar 2022 10:45:27 -0700 Subject: [PATCH 2/2] rename to evaluate --- build/main.cjs | 4 ++-- src/polfield.js | 4 ++-- test/pols.js | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build/main.cjs b/build/main.cjs index 11fe79a..f77fd47 100644 --- a/build/main.cjs +++ b/build/main.cjs @@ -822,7 +822,7 @@ class PolField { return v; } - eval1(p,x) { + evaluate(p,x) { const F = this.F; if (p.length == 0) return F.zero; const m = this._next2Power(p.length); @@ -853,7 +853,7 @@ class PolField { let mpol = this.ruffini(roots, points[i][0]); const factor = this.F.mul( - this.F.inv(this.eval1(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); diff --git a/src/polfield.js b/src/polfield.js index 465e551..467645f 100644 --- a/src/polfield.js +++ b/src/polfield.js @@ -192,7 +192,7 @@ export default class PolField { return v; } - eval1(p,x) { + evaluate(p,x) { const F = this.F; if (p.length == 0) return F.zero; const m = this._next2Power(p.length); @@ -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.eval1(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); diff --git a/test/pols.js b/test/pols.js index 5229252..81fa9dd 100644 --- a/test/pols.js +++ b/test/pols.js @@ -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.eval1(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.eval1(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", () => { @@ -148,7 +148,7 @@ describe("Polynomial field", () => { const p=PF.lagrange(points); for (let i=0; i { const p=PF.lagrange(points); for (let i=0; i { const p = PF.ifft(a); for (let i=0; i