-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* added subtractScaler * added subtractScaler missing entries * added test cases for 2 or more parameters, test for subtractScalar instead fo subtract * replaced subtract with subtractScalar whereever possible --------- Co-authored-by: Jos de Jong <[email protected]>
- Loading branch information
Showing
22 changed files
with
276 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,5 +233,7 @@ BuildTools <[email protected]> | |
Anik Patel <[email protected]> | ||
Vrushaket Chaudhari <[email protected]> | ||
Praise Nnamonu <[email protected]> | ||
Vincent Tam <[email protected]> | ||
vrushaket <[email protected]> | ||
|
||
# Generated by tools/update-authors.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { factory } from '../../utils/factory.js' | ||
import { subtractNumber } from '../../plain/number/index.js' | ||
|
||
const name = 'subtractScalar' | ||
const dependencies = ['typed'] | ||
|
||
export const createSubtractScalar = /* #__PURE__ */ factory(name, dependencies, ({ typed }) => { | ||
/** | ||
* Subtract two scalar values, `x - y`. | ||
* This function is meant for internal use: it is used by the public function | ||
* `subtract` | ||
* | ||
* This function does not support collections (Array or Matrix). | ||
* | ||
* @param {number | BigNumber | Fraction | Complex | Unit} x First value | ||
* @param {number | BigNumber | Fraction | Complex} y Second value to be subtracted from `x` | ||
* @return {number | BigNumber | Fraction | Complex | Unit} Difference of `x` and `y` | ||
* @private | ||
*/ | ||
return typed(name, { | ||
|
||
'number, number': subtractNumber, | ||
|
||
'Complex, Complex': function (x, y) { | ||
return x.sub(y) | ||
}, | ||
|
||
'BigNumber, BigNumber': function (x, y) { | ||
return x.minus(y) | ||
}, | ||
|
||
'Fraction, Fraction': function (x, y) { | ||
return x.sub(y) | ||
}, | ||
|
||
'Unit, Unit': typed.referToSelf(self => (x, y) => { | ||
if (x.value === null || x.value === undefined) { | ||
throw new Error('Parameter x contains a unit with undefined value') | ||
} | ||
if (y.value === null || y.value === undefined) { | ||
throw new Error('Parameter y contains a unit with undefined value') | ||
} | ||
if (!x.equalBase(y)) throw new Error('Units do not match') | ||
|
||
const res = x.clone() | ||
res.value = | ||
typed.find(self, [res.valueType(), y.valueType()])(res.value, y.value) | ||
res.fixPrefix = false | ||
return res | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.