@mathigon/fermat
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -361,2 +361,3 @@ "use strict"; | ||
} | ||
/** Returns the ith nth-root of this complex number. */ | ||
root(n, i = 0) { | ||
@@ -376,2 +377,3 @@ const r = Math.pow(this.modulus, 1 / n); | ||
} | ||
// --------------------------------------------------------------------------- | ||
add(a) { | ||
@@ -389,2 +391,3 @@ return Complex.sum(this, a); | ||
} | ||
/** Calculates the sum of two complex numbers c1 and c2. */ | ||
static sum(c1, c2) { | ||
@@ -397,2 +400,3 @@ if (typeof c1 === "number") | ||
} | ||
/** Calculates the difference of two complex numbers c1 and c2. */ | ||
static difference(c1, c2) { | ||
@@ -405,2 +409,3 @@ if (typeof c1 === "number") | ||
} | ||
/** Calculates the product of two complex numbers c1 and c2. */ | ||
static product(c1, c2) { | ||
@@ -415,2 +420,3 @@ if (typeof c1 === "number") | ||
} | ||
/** Calculates the quotient of two complex numbers c1 and c2. */ | ||
static quotient(c1, c2) { | ||
@@ -429,2 +435,3 @@ if (typeof c1 === "number") | ||
} | ||
/** Calculates e^c for a complex number c. */ | ||
static exp(c) { | ||
@@ -543,2 +550,3 @@ if (typeof c === "number") | ||
var XNumber = class { | ||
/** Only used for fractions and always ≥ 0. */ | ||
constructor(num, den, unit) { | ||
@@ -571,2 +579,7 @@ this.unit = unit; | ||
} | ||
// --------------------------------------------------------------------------- | ||
/** | ||
* Returns the value of this number as a decimal. For example, 2/5 and 40% | ||
* would both return 0.4. | ||
*/ | ||
get value() { | ||
@@ -579,2 +592,3 @@ const unit = this.unit === "%" ? 1 / 100 : this.unit === "\u03C0" ? Math.PI : 1; | ||
} | ||
/** Simplifies fractions, e.g. 4/8 would become 1/2. */ | ||
get simplified() { | ||
@@ -586,2 +600,3 @@ if (!this.den) | ||
} | ||
/** Returns 1/x of this number. */ | ||
get inverse() { | ||
@@ -592,5 +607,8 @@ if (!this.den) | ||
} | ||
/** Returns -x of this number. */ | ||
get negative() { | ||
return new XNumber(-this.num, this.den, this.unit); | ||
} | ||
// --------------------------------------------------------------------------- | ||
/** Parses a number string, e.g. '1/2' or '20.7%'. */ | ||
static fromString(s) { | ||
@@ -621,2 +639,3 @@ s = s.toLowerCase().replace(/[\s,]/g, "").replace("\u2013", "-").replace("pi", "\u03C0"); | ||
} | ||
/** Converts a decimal into the closest fraction with a given maximum denominator. */ | ||
static fractionFromDecimal(x, maxDen = 100) { | ||
@@ -650,2 +669,3 @@ const sign2 = Math.sign(x); | ||
} | ||
// --------------------------------------------------------------------------- | ||
clamp(min, max) { | ||
@@ -671,2 +691,3 @@ const v = this.value; | ||
} | ||
/** Calculates the sum of two fractions a and b. */ | ||
static sum(a, b) { | ||
@@ -687,2 +708,3 @@ if (typeof b === "number") | ||
} | ||
/** Calculates the difference of two numbers a and b. */ | ||
static difference(a, b) { | ||
@@ -693,2 +715,3 @@ if (typeof b === "number") | ||
} | ||
/** Calculates the product of two numbers a and b. */ | ||
static product(a, b) { | ||
@@ -706,2 +729,3 @@ if (typeof b === "number") | ||
} | ||
/** Calculates the quotient of two fractions a and b. */ | ||
static quotient(a, b) { | ||
@@ -1188,2 +1212,3 @@ if (typeof b === "number") | ||
} | ||
/** Returns the magnitude of the Vector */ | ||
get magnitude() { | ||
@@ -1195,8 +1220,12 @@ let squares = 0; | ||
} | ||
/** Returns the unitVector of the Vector */ | ||
get unitVector() { | ||
return this.scale(1 / this.magnitude); | ||
} | ||
/** Scales this vector by a factor q. */ | ||
scale(q) { | ||
return this.map((x) => q * x); | ||
} | ||
// ------------------------------------------------------------------------- | ||
/** Calculates the sum of two vectors v1 and v2. */ | ||
static sum(v1, v2) { | ||
@@ -1207,2 +1236,3 @@ if (v1.length !== v2.length) | ||
} | ||
/** Calculates the difference of two vectors v1 and v2. */ | ||
static difference(v1, v2) { | ||
@@ -1213,2 +1243,3 @@ if (v1.length !== v2.length) | ||
} | ||
/** Calculates the element-wise product of two vectors v1 and v2. */ | ||
static product(v1, v2) { | ||
@@ -1219,5 +1250,7 @@ if (v1.length !== v2.length) | ||
} | ||
/** Calculates the dot product of two vectors v1 and v2. */ | ||
static dot(v1, v2) { | ||
return (0, import_core6.total)(Vector.product(v1, v2)); | ||
} | ||
/** Finds the cross product of two 3-dimensional vectors v1 and v2. */ | ||
static cross(v1, v2) { | ||
@@ -1233,2 +1266,3 @@ if (v1.length !== 3 || v2.length !== 3) { | ||
} | ||
/** Checks if two vectors are equal. */ | ||
static equals(v1, v2) { | ||
@@ -1235,0 +1269,0 @@ const n = v1.length; |
@@ -295,2 +295,3 @@ var __defProp = Object.defineProperty; | ||
} | ||
/** Returns the ith nth-root of this complex number. */ | ||
root(n, i = 0) { | ||
@@ -310,2 +311,3 @@ const r = Math.pow(this.modulus, 1 / n); | ||
} | ||
// --------------------------------------------------------------------------- | ||
add(a) { | ||
@@ -323,2 +325,3 @@ return Complex.sum(this, a); | ||
} | ||
/** Calculates the sum of two complex numbers c1 and c2. */ | ||
static sum(c1, c2) { | ||
@@ -331,2 +334,3 @@ if (typeof c1 === "number") | ||
} | ||
/** Calculates the difference of two complex numbers c1 and c2. */ | ||
static difference(c1, c2) { | ||
@@ -339,2 +343,3 @@ if (typeof c1 === "number") | ||
} | ||
/** Calculates the product of two complex numbers c1 and c2. */ | ||
static product(c1, c2) { | ||
@@ -349,2 +354,3 @@ if (typeof c1 === "number") | ||
} | ||
/** Calculates the quotient of two complex numbers c1 and c2. */ | ||
static quotient(c1, c2) { | ||
@@ -363,2 +369,3 @@ if (typeof c1 === "number") | ||
} | ||
/** Calculates e^c for a complex number c. */ | ||
static exp(c) { | ||
@@ -477,2 +484,3 @@ if (typeof c === "number") | ||
var XNumber = class { | ||
/** Only used for fractions and always ≥ 0. */ | ||
constructor(num, den, unit) { | ||
@@ -505,2 +513,7 @@ this.unit = unit; | ||
} | ||
// --------------------------------------------------------------------------- | ||
/** | ||
* Returns the value of this number as a decimal. For example, 2/5 and 40% | ||
* would both return 0.4. | ||
*/ | ||
get value() { | ||
@@ -513,2 +526,3 @@ const unit = this.unit === "%" ? 1 / 100 : this.unit === "\u03C0" ? Math.PI : 1; | ||
} | ||
/** Simplifies fractions, e.g. 4/8 would become 1/2. */ | ||
get simplified() { | ||
@@ -520,2 +534,3 @@ if (!this.den) | ||
} | ||
/** Returns 1/x of this number. */ | ||
get inverse() { | ||
@@ -526,5 +541,8 @@ if (!this.den) | ||
} | ||
/** Returns -x of this number. */ | ||
get negative() { | ||
return new XNumber(-this.num, this.den, this.unit); | ||
} | ||
// --------------------------------------------------------------------------- | ||
/** Parses a number string, e.g. '1/2' or '20.7%'. */ | ||
static fromString(s) { | ||
@@ -555,2 +573,3 @@ s = s.toLowerCase().replace(/[\s,]/g, "").replace("\u2013", "-").replace("pi", "\u03C0"); | ||
} | ||
/** Converts a decimal into the closest fraction with a given maximum denominator. */ | ||
static fractionFromDecimal(x, maxDen = 100) { | ||
@@ -584,2 +603,3 @@ const sign2 = Math.sign(x); | ||
} | ||
// --------------------------------------------------------------------------- | ||
clamp(min, max) { | ||
@@ -605,2 +625,3 @@ const v = this.value; | ||
} | ||
/** Calculates the sum of two fractions a and b. */ | ||
static sum(a, b) { | ||
@@ -621,2 +642,3 @@ if (typeof b === "number") | ||
} | ||
/** Calculates the difference of two numbers a and b. */ | ||
static difference(a, b) { | ||
@@ -627,2 +649,3 @@ if (typeof b === "number") | ||
} | ||
/** Calculates the product of two numbers a and b. */ | ||
static product(a, b) { | ||
@@ -640,2 +663,3 @@ if (typeof b === "number") | ||
} | ||
/** Calculates the quotient of two fractions a and b. */ | ||
static quotient(a, b) { | ||
@@ -1122,2 +1146,3 @@ if (typeof b === "number") | ||
} | ||
/** Returns the magnitude of the Vector */ | ||
get magnitude() { | ||
@@ -1129,8 +1154,12 @@ let squares = 0; | ||
} | ||
/** Returns the unitVector of the Vector */ | ||
get unitVector() { | ||
return this.scale(1 / this.magnitude); | ||
} | ||
/** Scales this vector by a factor q. */ | ||
scale(q) { | ||
return this.map((x) => q * x); | ||
} | ||
// ------------------------------------------------------------------------- | ||
/** Calculates the sum of two vectors v1 and v2. */ | ||
static sum(v1, v2) { | ||
@@ -1141,2 +1170,3 @@ if (v1.length !== v2.length) | ||
} | ||
/** Calculates the difference of two vectors v1 and v2. */ | ||
static difference(v1, v2) { | ||
@@ -1147,2 +1177,3 @@ if (v1.length !== v2.length) | ||
} | ||
/** Calculates the element-wise product of two vectors v1 and v2. */ | ||
static product(v1, v2) { | ||
@@ -1153,5 +1184,7 @@ if (v1.length !== v2.length) | ||
} | ||
/** Calculates the dot product of two vectors v1 and v2. */ | ||
static dot(v1, v2) { | ||
return total3(Vector.product(v1, v2)); | ||
} | ||
/** Finds the cross product of two 3-dimensional vectors v1 and v2. */ | ||
static cross(v1, v2) { | ||
@@ -1167,2 +1200,3 @@ if (v1.length !== 3 || v2.length !== 3) { | ||
} | ||
/** Checks if two vectors are equal. */ | ||
static equals(v1, v2) { | ||
@@ -1169,0 +1203,0 @@ const n = v1.length; |
{ | ||
"name": "@mathigon/fermat", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"license": "MIT", | ||
@@ -38,16 +38,16 @@ "homepage": "https://mathigon.io/fermat", | ||
"dependencies": { | ||
"@mathigon/core": "1.1.4" | ||
"@mathigon/core": "1.1.5" | ||
}, | ||
"devDependencies": { | ||
"@types/tape": "4.13.2", | ||
"@typescript-eslint/eslint-plugin": "5.45.0", | ||
"@typescript-eslint/parser": "5.45.0", | ||
"esbuild": "0.15.16", | ||
"eslint": "8.28.0", | ||
"eslint-plugin-import": "2.26.0", | ||
"tape": "5.6.1", | ||
"@typescript-eslint/eslint-plugin": "5.50.0", | ||
"@typescript-eslint/parser": "5.50.0", | ||
"esbuild": "0.17.5", | ||
"eslint": "8.33.0", | ||
"eslint-plugin-import": "2.27.5", | ||
"tape": "5.6.3", | ||
"ts-node": "10.9.1", | ||
"tslib": "2.4.1", | ||
"typescript": "4.9.3" | ||
"tslib": "2.5.0", | ||
"typescript": "4.9.5" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
299364
4358
+ Added@mathigon/core@1.1.5(transitive)
- Removed@mathigon/core@1.1.4(transitive)
Updated@mathigon/core@1.1.5