UNPKG

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

58 lines (53 loc) 1.41 kB
'use strict'; var deepMap = require('../../utils/collection/deepMap'); function factory(type, config, load, typed) { var latex = require('../../utils/latex'); /** * Logical `not`. Flips boolean value of a given parameter. * For matrices, the function is evaluated element wise. * * Syntax: * * math.not(x) * * Examples: * * math.not(2) // returns false * math.not(0) // returns true * math.not(true) // returns false * * a = [2, -7, 0] * math.not(a) // returns [false, false, true] * * See also: * * and, or, xor * * @param {number | BigNumber | Complex | Unit | Array | Matrix} x First value to check * @return {boolean | Array | Matrix} * Returns true when input is a zero or empty value. */ var not = typed('not', { 'number': function number(x) { return !x; }, 'Complex': function Complex(x) { return x.re === 0 && x.im === 0; }, 'BigNumber': function BigNumber(x) { return x.isZero() || x.isNaN(); }, 'Unit': function Unit(x) { return x.value !== null ? not(x.value) : true; }, 'Array | Matrix': function ArrayMatrix(x) { return deepMap(x, not); } }); not.toTex = { 1: latex.operators['not'] + "\\left(${args[0]}\\right)" }; return not; } exports.name = 'not'; exports.factory = factory;