mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
Dropped fake BigNumber support from function erf
This commit is contained in:
parent
52dfafe5be
commit
6b6ae1383c
@ -87,6 +87,7 @@
|
||||
`math.Unit` and `math.Parser` respectively.
|
||||
- Fixed #1428: transform iterating over replaced nodes. New behavior
|
||||
is that it stops iterating when a node is replaced.
|
||||
- Dropped fake BigNumber support of function `erf`.
|
||||
- Removed all index.js files used to load specific functions instead of all, like:
|
||||
|
||||
```
|
||||
|
||||
@ -50,13 +50,6 @@ export const createErf = /* #__PURE__ */ factory(name, dependencies, ({ typed })
|
||||
return sign(x) * (1 - erfc3(y))
|
||||
},
|
||||
|
||||
// TODO: Not sure if there's a way to guarantee some degree of accuracy here.
|
||||
// Perhaps it would be best to set the precision of the number to that which
|
||||
// is guaranteed by erf()
|
||||
'BigNumber': function (n) {
|
||||
return new n.constructor(erf(n.toNumber()))
|
||||
},
|
||||
|
||||
'Array | Matrix': function (n) {
|
||||
return deepMap(n, erf)
|
||||
}
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
import assert from 'assert'
|
||||
import math from '../../../src/bundleAny'
|
||||
import actualErfValues from './erf.values.json'
|
||||
const bignumber = math.bignumber
|
||||
const subtract = math.subtract
|
||||
const abs = math.abs
|
||||
const smaller = math.smaller
|
||||
const erf = math.erf
|
||||
|
||||
const DIFF_THRESH = 5e-16
|
||||
@ -58,40 +54,6 @@ describe('erf', function () {
|
||||
assert.ok(Math.abs(erf(-3) - actualErfValues['-3.0']) < DIFF_THRESH)
|
||||
})
|
||||
|
||||
it('should calculate the erf of a rational bignumber', function () {
|
||||
assert.ok(smaller(
|
||||
abs(subtract(erf(bignumber(0.1)), bignumber(actualErfValues['0.1']))),
|
||||
DIFF_THRESH
|
||||
))
|
||||
assert.ok(smaller(
|
||||
abs(subtract(erf(bignumber(0.2)), bignumber(actualErfValues['0.2']))),
|
||||
DIFF_THRESH
|
||||
))
|
||||
assert.ok(smaller(
|
||||
abs(subtract(erf(bignumber(0.3)), bignumber(actualErfValues['0.3']))),
|
||||
DIFF_THRESH
|
||||
))
|
||||
assert.ok(smaller(
|
||||
abs(subtract(erf(bignumber(1.5)), bignumber(actualErfValues['1.5']))),
|
||||
DIFF_THRESH
|
||||
))
|
||||
assert.ok(smaller(
|
||||
abs(subtract(erf(bignumber(2.5)), bignumber(actualErfValues['2.5']))),
|
||||
DIFF_THRESH
|
||||
))
|
||||
|
||||
const bigmath = math.create({ precision: 15 })
|
||||
assert.ok(smaller(
|
||||
abs(subtract(bigmath.erf(bignumber(-1.5)), bigmath.bignumber(actualErfValues['-1.5']))),
|
||||
DIFF_THRESH
|
||||
))
|
||||
bigmath.config({ precision: 13 })
|
||||
assert.ok(smaller(
|
||||
abs(subtract(bigmath.erf(bignumber(-1.5)), bigmath.bignumber(actualErfValues['-1.5']))),
|
||||
DIFF_THRESH
|
||||
))
|
||||
})
|
||||
|
||||
it('should calculate the erf of a boolean (true = 1, false = 0)', function () {
|
||||
assert.ok(Math.abs(erf(true) - actualErfValues['1.0']) < DIFF_THRESH)
|
||||
assert.ok(Math.abs(erf(false) - actualErfValues['0.0']) < DIFF_THRESH)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user