Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mathigon/fermat

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mathigon/fermat - npm Package Compare versions

Comparing version 1.1.8 to 1.1.9

116

dist/index.cjs.js

@@ -347,3 +347,3 @@ "use strict";

};
var Complex = class {
var Complex = class _Complex {
constructor(re = 0, im = 0) {

@@ -360,3 +360,3 @@ this.re = re;

get conjugate() {
return new Complex(this.re, -this.im);
return new _Complex(this.re, -this.im);
}

@@ -367,3 +367,3 @@ /** Returns the ith nth-root of this complex number. */

const th = (this.argument + i * 2 * Math.PI) / n;
return new Complex(r * Math.cos(th), r * Math.sin(th));
return new _Complex(r * Math.cos(th), r * Math.sin(th));
}

@@ -381,12 +381,12 @@ toString(precision = 2) {

add(a) {
return Complex.sum(this, a);
return _Complex.sum(this, a);
}
subtract(a) {
return Complex.difference(this, a);
return _Complex.difference(this, a);
}
multiply(a) {
return Complex.product(this, a);
return _Complex.product(this, a);
}
divide(a) {
return Complex.quotient(this, a);
return _Complex.quotient(this, a);
}

@@ -396,6 +396,6 @@ /** Calculates the sum of two complex numbers c1 and c2. */

if (typeof c1 === "number")
c1 = new Complex(c1, 0);
c1 = new _Complex(c1, 0);
if (typeof c2 === "number")
c2 = new Complex(c2, 0);
return new Complex(c1.re + c2.re, c1.im + c2.im);
c2 = new _Complex(c2, 0);
return new _Complex(c1.re + c2.re, c1.im + c2.im);
}

@@ -405,6 +405,6 @@ /** Calculates the difference of two complex numbers c1 and c2. */

if (typeof c1 === "number")
c1 = new Complex(c1, 0);
c1 = new _Complex(c1, 0);
if (typeof c2 === "number")
c2 = new Complex(c2, 0);
return new Complex(c1.re - c2.re, c1.im - c2.im);
c2 = new _Complex(c2, 0);
return new _Complex(c1.re - c2.re, c1.im - c2.im);
}

@@ -414,8 +414,8 @@ /** Calculates the product of two complex numbers c1 and c2. */

if (typeof c1 === "number")
c1 = new Complex(c1, 0);
c1 = new _Complex(c1, 0);
if (typeof c2 === "number")
c2 = new Complex(c2, 0);
c2 = new _Complex(c2, 0);
const re = c1.re * c2.re - c1.im * c2.im;
const im = c1.im * c2.re + c1.re * c2.im;
return new Complex(re, im);
return new _Complex(re, im);
}

@@ -425,7 +425,7 @@ /** Calculates the quotient of two complex numbers c1 and c2. */

if (typeof c1 === "number")
c1 = new Complex(c1, 0);
c1 = new _Complex(c1, 0);
if (typeof c2 === "number")
c2 = new Complex(c2, 0);
c2 = new _Complex(c2, 0);
if (Math.abs(c2.re) < Number.EPSILON || Math.abs(c2.im) < Number.EPSILON) {
return new Complex(Infinity, Infinity);
return new _Complex(Infinity, Infinity);
}

@@ -435,3 +435,3 @@ const denominator = c2.re * c2.re + c2.im * c2.im;

const im = (c1.im * c2.re - c1.re * c2.im) / denominator;
return new Complex(re, im);
return new _Complex(re, im);
}

@@ -441,5 +441,5 @@ /** Calculates e^c for a complex number c. */

if (typeof c === "number")
c = new Complex(c, 0);
c = new _Complex(c, 0);
const r = Math.exp(c.re);
return new Complex(r * Math.cos(c.im), r * Math.sin(c.im));
return new _Complex(r * Math.cos(c.im), r * Math.sin(c.im));
}

@@ -552,3 +552,3 @@ };

var FORMAT = /^([0-9\-.]*)([%πkmbtq]?)(\/([0-9\-.]+))?([%π]?)$/;
var XNumber = class {
var XNumber = class _XNumber {
/** Only used for fractions and always ≥ 0. */

@@ -600,3 +600,3 @@ constructor(num, den, unit) {

const factor = gcd(Math.abs(this.num), this.den);
return new XNumber(this.num / factor, this.den / factor, this.unit);
return new _XNumber(this.num / factor, this.den / factor, this.unit);
}

@@ -606,8 +606,8 @@ /** Returns 1/x of this number. */

if (!this.den)
return new XNumber(this.den, this.num);
return new XNumber(1 / this.num, void 0, this.unit);
return new _XNumber(this.den, this.num);
return new _XNumber(1 / this.num, void 0, this.unit);
}
/** Returns -x of this number. */
get negative() {
return new XNumber(-this.num, this.den, this.unit);
return new _XNumber(-this.num, this.den, this.unit);
}

@@ -634,8 +634,8 @@ // ---------------------------------------------------------------------------

if (den === void 0)
return new XNumber(num, void 0, suffix);
return new _XNumber(num, void 0, suffix);
if (isNaN(den) || nearlyEquals(den, 0))
return;
if (!isInteger(num) || !isInteger(den))
return new XNumber(num / den, void 0, suffix);
return new XNumber(num, den, suffix);
return new _XNumber(num / den, void 0, suffix);
return new _XNumber(num, den, suffix);
}

@@ -655,7 +655,7 @@ /** Converts a decimal into the closest fraction with a given maximum denominator. */

if (b + d <= maxDen) {
return new XNumber(sign2 * (whole * (b + d) + a + c), b + d);
return new _XNumber(sign2 * (whole * (b + d) + a + c), b + d);
} else if (d > b) {
return new XNumber(sign2 * (whole * d + c), d);
return new _XNumber(sign2 * (whole * d + c), d);
} else {
return new XNumber(sign2 * (whole * b + a), b);
return new _XNumber(sign2 * (whole * b + a), b);
}

@@ -669,4 +669,4 @@ } else if (x > mediant) {

if (b > maxDen)
return new XNumber(sign2 * (whole * d + c), d);
return new XNumber(sign2 * (whole * b + a), b);
return new _XNumber(sign2 * (whole * d + c), d);
return new _XNumber(sign2 * (whole * b + a), b);
}

@@ -677,18 +677,18 @@ // ---------------------------------------------------------------------------

if (min !== void 0 && v < min)
return new XNumber(min);
return new _XNumber(min);
if (max !== void 0 && v > max)
return new XNumber(max);
return new _XNumber(max);
return this;
}
add(a) {
return XNumber.sum(this, a);
return _XNumber.sum(this, a);
}
subtract(a) {
return XNumber.difference(this, a);
return _XNumber.difference(this, a);
}
multiply(a) {
return XNumber.product(this, a);
return _XNumber.product(this, a);
}
divide(a) {
return XNumber.quotient(this, a);
return _XNumber.quotient(this, a);
}

@@ -698,17 +698,17 @@ /** Calculates the sum of two fractions a and b. */

if (typeof b === "number")
b = new XNumber(b);
b = new _XNumber(b);
if (a.num === 0)
return b;
if (a.unit !== b.unit)
return new XNumber(a.value + b.value);
return new _XNumber(a.value + b.value);
if (!a.den && !b.den)
return new XNumber(a.num + b.num, void 0, a.unit);
return new _XNumber(a.num + b.num, void 0, a.unit);
if (!a.den)
[a, b] = [b, a];
if (!isInteger(b.num))
return new XNumber(a.value + b.value, void 0, a.unit);
return new _XNumber(a.value + b.value, void 0, a.unit);
const common = lcm(a.den, b.den || 1);
const fa = common / a.den;
const fb = common / (b.den || 1);
return new XNumber(a.num * fa + b.num * fb, common, a.unit);
return new _XNumber(a.num * fa + b.num * fb, common, a.unit);
}

@@ -718,4 +718,4 @@ /** Calculates the difference of two numbers a and b. */

if (typeof b === "number")
b = new XNumber(b);
return XNumber.sum(a, b.negative);
b = new _XNumber(b);
return _XNumber.sum(a, b.negative);
}

@@ -725,11 +725,11 @@ /** Calculates the product of two numbers a and b. */

if (typeof b === "number")
b = new XNumber(b);
b = new _XNumber(b);
if (!a.unit && !a.den && isInteger(a.num))
return new XNumber(a.num * b.num, b.den, b.unit);
return new _XNumber(a.num * b.num, b.den, b.unit);
if (!b.unit && !b.den && isInteger(b.num))
return new XNumber(a.num * b.num, a.den, a.unit);
return new _XNumber(a.num * b.num, a.den, a.unit);
if (a.unit === "\u03C0" || b.unit === "\u03C0" || !isInteger(a.num) || !isInteger(b.num))
return new XNumber(a.value * b.value);
return new _XNumber(a.value * b.value);
const units = (a.unit === "%" ? 100 : 1) * (b.unit === "%" ? 100 : 1);
return new XNumber(a.num * b.num, (a.den || 1) * (b.den || 1) * units);
return new _XNumber(a.num * b.num, (a.den || 1) * (b.den || 1) * units);
}

@@ -739,4 +739,4 @@ /** Calculates the quotient of two fractions a and b. */

if (typeof b === "number")
b = new XNumber(b);
return XNumber.product(a, b.inverse);
b = new _XNumber(b);
return _XNumber.product(a, b.inverse);
}

@@ -1213,3 +1213,3 @@ };

var import_core6 = require("@mathigon/core");
var Vector = class extends Array {
var Vector = class _Vector extends Array {
constructor(...args) {

@@ -1256,3 +1256,3 @@ super();

static dot(v1, v2) {
return (0, import_core6.total)(Vector.product(v1, v2));
return (0, import_core6.total)(_Vector.product(v1, v2));
}

@@ -1264,3 +1264,3 @@ /** Finds the cross product of two 3-dimensional vectors v1 and v2. */

}
return new Vector(
return new _Vector(
v1[1] * v2[2] - v1[2] * v2[1],

@@ -1267,0 +1267,0 @@ v1[2] * v2[0] - v1[0] * v2[2],

@@ -281,3 +281,3 @@ var __defProp = Object.defineProperty;

};
var Complex = class {
var Complex = class _Complex {
constructor(re = 0, im = 0) {

@@ -294,3 +294,3 @@ this.re = re;

get conjugate() {
return new Complex(this.re, -this.im);
return new _Complex(this.re, -this.im);
}

@@ -301,3 +301,3 @@ /** Returns the ith nth-root of this complex number. */

const th = (this.argument + i * 2 * Math.PI) / n;
return new Complex(r * Math.cos(th), r * Math.sin(th));
return new _Complex(r * Math.cos(th), r * Math.sin(th));
}

@@ -315,12 +315,12 @@ toString(precision = 2) {

add(a) {
return Complex.sum(this, a);
return _Complex.sum(this, a);
}
subtract(a) {
return Complex.difference(this, a);
return _Complex.difference(this, a);
}
multiply(a) {
return Complex.product(this, a);
return _Complex.product(this, a);
}
divide(a) {
return Complex.quotient(this, a);
return _Complex.quotient(this, a);
}

@@ -330,6 +330,6 @@ /** Calculates the sum of two complex numbers c1 and c2. */

if (typeof c1 === "number")
c1 = new Complex(c1, 0);
c1 = new _Complex(c1, 0);
if (typeof c2 === "number")
c2 = new Complex(c2, 0);
return new Complex(c1.re + c2.re, c1.im + c2.im);
c2 = new _Complex(c2, 0);
return new _Complex(c1.re + c2.re, c1.im + c2.im);
}

@@ -339,6 +339,6 @@ /** Calculates the difference of two complex numbers c1 and c2. */

if (typeof c1 === "number")
c1 = new Complex(c1, 0);
c1 = new _Complex(c1, 0);
if (typeof c2 === "number")
c2 = new Complex(c2, 0);
return new Complex(c1.re - c2.re, c1.im - c2.im);
c2 = new _Complex(c2, 0);
return new _Complex(c1.re - c2.re, c1.im - c2.im);
}

@@ -348,8 +348,8 @@ /** Calculates the product of two complex numbers c1 and c2. */

if (typeof c1 === "number")
c1 = new Complex(c1, 0);
c1 = new _Complex(c1, 0);
if (typeof c2 === "number")
c2 = new Complex(c2, 0);
c2 = new _Complex(c2, 0);
const re = c1.re * c2.re - c1.im * c2.im;
const im = c1.im * c2.re + c1.re * c2.im;
return new Complex(re, im);
return new _Complex(re, im);
}

@@ -359,7 +359,7 @@ /** Calculates the quotient of two complex numbers c1 and c2. */

if (typeof c1 === "number")
c1 = new Complex(c1, 0);
c1 = new _Complex(c1, 0);
if (typeof c2 === "number")
c2 = new Complex(c2, 0);
c2 = new _Complex(c2, 0);
if (Math.abs(c2.re) < Number.EPSILON || Math.abs(c2.im) < Number.EPSILON) {
return new Complex(Infinity, Infinity);
return new _Complex(Infinity, Infinity);
}

@@ -369,3 +369,3 @@ const denominator = c2.re * c2.re + c2.im * c2.im;

const im = (c1.im * c2.re - c1.re * c2.im) / denominator;
return new Complex(re, im);
return new _Complex(re, im);
}

@@ -375,5 +375,5 @@ /** Calculates e^c for a complex number c. */

if (typeof c === "number")
c = new Complex(c, 0);
c = new _Complex(c, 0);
const r = Math.exp(c.re);
return new Complex(r * Math.cos(c.im), r * Math.sin(c.im));
return new _Complex(r * Math.cos(c.im), r * Math.sin(c.im));
}

@@ -486,3 +486,3 @@ };

var FORMAT = /^([0-9\-.]*)([%πkmbtq]?)(\/([0-9\-.]+))?([%π]?)$/;
var XNumber = class {
var XNumber = class _XNumber {
/** Only used for fractions and always ≥ 0. */

@@ -534,3 +534,3 @@ constructor(num, den, unit) {

const factor = gcd(Math.abs(this.num), this.den);
return new XNumber(this.num / factor, this.den / factor, this.unit);
return new _XNumber(this.num / factor, this.den / factor, this.unit);
}

@@ -540,8 +540,8 @@ /** Returns 1/x of this number. */

if (!this.den)
return new XNumber(this.den, this.num);
return new XNumber(1 / this.num, void 0, this.unit);
return new _XNumber(this.den, this.num);
return new _XNumber(1 / this.num, void 0, this.unit);
}
/** Returns -x of this number. */
get negative() {
return new XNumber(-this.num, this.den, this.unit);
return new _XNumber(-this.num, this.den, this.unit);
}

@@ -568,8 +568,8 @@ // ---------------------------------------------------------------------------

if (den === void 0)
return new XNumber(num, void 0, suffix);
return new _XNumber(num, void 0, suffix);
if (isNaN(den) || nearlyEquals(den, 0))
return;
if (!isInteger(num) || !isInteger(den))
return new XNumber(num / den, void 0, suffix);
return new XNumber(num, den, suffix);
return new _XNumber(num / den, void 0, suffix);
return new _XNumber(num, den, suffix);
}

@@ -589,7 +589,7 @@ /** Converts a decimal into the closest fraction with a given maximum denominator. */

if (b + d <= maxDen) {
return new XNumber(sign2 * (whole * (b + d) + a + c), b + d);
return new _XNumber(sign2 * (whole * (b + d) + a + c), b + d);
} else if (d > b) {
return new XNumber(sign2 * (whole * d + c), d);
return new _XNumber(sign2 * (whole * d + c), d);
} else {
return new XNumber(sign2 * (whole * b + a), b);
return new _XNumber(sign2 * (whole * b + a), b);
}

@@ -603,4 +603,4 @@ } else if (x > mediant) {

if (b > maxDen)
return new XNumber(sign2 * (whole * d + c), d);
return new XNumber(sign2 * (whole * b + a), b);
return new _XNumber(sign2 * (whole * d + c), d);
return new _XNumber(sign2 * (whole * b + a), b);
}

@@ -611,18 +611,18 @@ // ---------------------------------------------------------------------------

if (min !== void 0 && v < min)
return new XNumber(min);
return new _XNumber(min);
if (max !== void 0 && v > max)
return new XNumber(max);
return new _XNumber(max);
return this;
}
add(a) {
return XNumber.sum(this, a);
return _XNumber.sum(this, a);
}
subtract(a) {
return XNumber.difference(this, a);
return _XNumber.difference(this, a);
}
multiply(a) {
return XNumber.product(this, a);
return _XNumber.product(this, a);
}
divide(a) {
return XNumber.quotient(this, a);
return _XNumber.quotient(this, a);
}

@@ -632,17 +632,17 @@ /** Calculates the sum of two fractions a and b. */

if (typeof b === "number")
b = new XNumber(b);
b = new _XNumber(b);
if (a.num === 0)
return b;
if (a.unit !== b.unit)
return new XNumber(a.value + b.value);
return new _XNumber(a.value + b.value);
if (!a.den && !b.den)
return new XNumber(a.num + b.num, void 0, a.unit);
return new _XNumber(a.num + b.num, void 0, a.unit);
if (!a.den)
[a, b] = [b, a];
if (!isInteger(b.num))
return new XNumber(a.value + b.value, void 0, a.unit);
return new _XNumber(a.value + b.value, void 0, a.unit);
const common = lcm(a.den, b.den || 1);
const fa = common / a.den;
const fb = common / (b.den || 1);
return new XNumber(a.num * fa + b.num * fb, common, a.unit);
return new _XNumber(a.num * fa + b.num * fb, common, a.unit);
}

@@ -652,4 +652,4 @@ /** Calculates the difference of two numbers a and b. */

if (typeof b === "number")
b = new XNumber(b);
return XNumber.sum(a, b.negative);
b = new _XNumber(b);
return _XNumber.sum(a, b.negative);
}

@@ -659,11 +659,11 @@ /** Calculates the product of two numbers a and b. */

if (typeof b === "number")
b = new XNumber(b);
b = new _XNumber(b);
if (!a.unit && !a.den && isInteger(a.num))
return new XNumber(a.num * b.num, b.den, b.unit);
return new _XNumber(a.num * b.num, b.den, b.unit);
if (!b.unit && !b.den && isInteger(b.num))
return new XNumber(a.num * b.num, a.den, a.unit);
return new _XNumber(a.num * b.num, a.den, a.unit);
if (a.unit === "\u03C0" || b.unit === "\u03C0" || !isInteger(a.num) || !isInteger(b.num))
return new XNumber(a.value * b.value);
return new _XNumber(a.value * b.value);
const units = (a.unit === "%" ? 100 : 1) * (b.unit === "%" ? 100 : 1);
return new XNumber(a.num * b.num, (a.den || 1) * (b.den || 1) * units);
return new _XNumber(a.num * b.num, (a.den || 1) * (b.den || 1) * units);
}

@@ -673,4 +673,4 @@ /** Calculates the quotient of two fractions a and b. */

if (typeof b === "number")
b = new XNumber(b);
return XNumber.product(a, b.inverse);
b = new _XNumber(b);
return _XNumber.product(a, b.inverse);
}

@@ -1147,3 +1147,3 @@ };

import { total as total3 } from "@mathigon/core";
var Vector = class extends Array {
var Vector = class _Vector extends Array {
constructor(...args) {

@@ -1190,3 +1190,3 @@ super();

static dot(v1, v2) {
return total3(Vector.product(v1, v2));
return total3(_Vector.product(v1, v2));
}

@@ -1198,3 +1198,3 @@ /** Finds the cross product of two 3-dimensional vectors v1 and v2. */

}
return new Vector(
return new _Vector(
v1[1] * v2[2] - v1[2] * v2[1],

@@ -1201,0 +1201,0 @@ v1[2] * v2[0] - v1[0] * v2[2],

{
"name": "@mathigon/fermat",
"version": "1.1.8",
"version": "1.1.9",
"license": "MIT",

@@ -38,16 +38,16 @@ "homepage": "https://mathigon.io/fermat",

"dependencies": {
"@mathigon/core": "1.1.8"
"@mathigon/core": "1.1.10"
},
"devDependencies": {
"@types/tape": "5.6.0",
"@typescript-eslint/eslint-plugin": "5.59.8",
"@typescript-eslint/parser": "5.59.8",
"esbuild": "0.17.19",
"eslint": "8.42.0",
"@typescript-eslint/eslint-plugin": "5.61.0",
"@typescript-eslint/parser": "5.61.0",
"esbuild": "0.18.11",
"eslint": "8.44.0",
"eslint-plugin-import": "2.27.5",
"tape": "5.6.3",
"tape": "5.6.4",
"ts-node": "10.9.1",
"tslib": "2.5.3",
"typescript": "5.1.3"
"tslib": "2.6.0",
"typescript": "5.1.6"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc