mathjs
Version:
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif
51 lines • 1.68 kB
JavaScript
import { factory } from '../../utils/factory.js';
var name = 'isFinite';
var dependencies = ['typed', 'isBounded', 'map'];
export var createIsFinite = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed,
isBounded,
map
} = _ref;
/**
* Test whether a value is finite.
*
* Operates elementwise on Array and Matrix values. To test if all entries
* of an Array or Matrix are finite, use isBounded.
*
* Syntax:
*
* math.isFinite(x)
*
* Examples:
*
* math.isFinite(0) // returns true
* math.isFinite(NaN) // returns false
* math.isFinite(math.bignumber(Infinity)) // returns false
* math.isFinite(math.fraction(1,3)) // returns true
* math.isFinite(math.complex('2 - 4i')) // returns true
* math.isFinite(-10000000000000000n) // returns true
* math.isFinite(undefined) // returns false
* math.isFinite(null) // returns false
* math.isFinite([0.001, -3n, 0]) // Array [true, true, true]
* math.isFinite([2, -Infinity, -3]) // Array [true, false, true]
*
* See also:
*
* isBounded isNumeric, isPositive, isNegative, isNaN
*
* History:
*
* v15.1 Created
*
* @param {number | BigNumber | bigint | Complex | Fraction | Unit | Array | Matrix} x
* Value to be tested
* @return {boolean | Array | Matrix}
* Whether the value, or its entries, are finite, as appropriate
* to its type
*/
return typed(name, {
'Array | Matrix': A => map(A, isBounded),
any: x => isBounded(x)
});
});