UNPKG

1.55 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.createNot = void 0;
7
8var _collection = require("../../utils/collection.js");
9
10var _factory = require("../../utils/factory.js");
11
12var _index = require("../../plain/number/index.js");
13
14var name = 'not';
15var dependencies = ['typed'];
16var createNot = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
17 var typed = _ref.typed;
18
19 /**
20 * Logical `not`. Flips boolean value of a given parameter.
21 * For matrices, the function is evaluated element wise.
22 *
23 * Syntax:
24 *
25 * math.not(x)
26 *
27 * Examples:
28 *
29 * math.not(2) // returns false
30 * math.not(0) // returns true
31 * math.not(true) // returns false
32 *
33 * a = [2, -7, 0]
34 * math.not(a) // returns [false, false, true]
35 *
36 * See also:
37 *
38 * and, or, xor
39 *
40 * @param {number | BigNumber | Complex | Unit | Array | Matrix} x First value to check
41 * @return {boolean | Array | Matrix}
42 * Returns true when input is a zero or empty value.
43 */
44 return typed(name, {
45 number: _index.notNumber,
46 Complex: function Complex(x) {
47 return x.re === 0 && x.im === 0;
48 },
49 BigNumber: function BigNumber(x) {
50 return x.isZero() || x.isNaN();
51 },
52 Unit: function Unit(x) {
53 return x.value !== null ? this(x.value) : true;
54 },
55 'Array | Matrix': function ArrayMatrix(x) {
56 return (0, _collection.deepMap)(x, this);
57 }
58 });
59});
60exports.createNot = createNot;
\No newline at end of file