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
83 lines (81 loc) • 2.73 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createXor = void 0;
var _matAlgo03xDSf = require("../../type/matrix/utils/matAlgo03xDSf.js");
var _matAlgo07xSSf = require("../../type/matrix/utils/matAlgo07xSSf.js");
var _matAlgo12xSfs = require("../../type/matrix/utils/matAlgo12xSfs.js");
var _factory = require("../../utils/factory.js");
var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
var _index = require("../../plain/number/index.js");
var name = 'xor';
var dependencies = ['typed', 'matrix', 'DenseMatrix', 'concat'];
var createXor = exports.createXor = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
var typed = _ref.typed,
matrix = _ref.matrix,
DenseMatrix = _ref.DenseMatrix,
concat = _ref.concat;
var matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
typed: typed
});
var matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
typed: typed,
DenseMatrix: DenseMatrix
});
var matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
typed: typed,
DenseMatrix: DenseMatrix
});
var matrixAlgorithmSuite = (0, _matrixAlgorithmSuite.createMatrixAlgorithmSuite)({
typed: typed,
matrix: matrix,
concat: concat
});
/**
* Logical `xor`. Test whether one and only one value is defined with a nonzero/nonempty value.
* For matrices, the function is evaluated element wise.
*
* Syntax:
*
* math.xor(x, y)
*
* Examples:
*
* math.xor(2, 4) // returns false
*
* a = [2, 0, 0]
* b = [2, 7, 0]
* c = 0
*
* math.xor(a, b) // returns [false, true, false]
* math.xor(a, c) // returns [true, false, false]
*
* See also:
*
* and, not, or
*
* @param {number | BigNumber | Complex | Unit | Array | Matrix} x First value to check
* @param {number | BigNumber | Complex | Unit | Array | Matrix} y Second value to check
* @return {boolean | Array | Matrix}
* Returns true when one and only one input is defined with a nonzero/nonempty value.
*/
return typed(name, {
'number, number': _index.xorNumber,
'Complex, Complex': function ComplexComplex(x, y) {
return (x.re !== 0 || x.im !== 0) !== (y.re !== 0 || y.im !== 0);
},
'BigNumber, BigNumber': function BigNumberBigNumber(x, y) {
return (!x.isZero() && !x.isNaN()) !== (!y.isZero() && !y.isNaN());
},
'Unit, Unit': typed.referToSelf(function (self) {
return function (x, y) {
return self(x.value || 0, y.value || 0);
};
})
}, matrixAlgorithmSuite({
SS: matAlgo07xSSf,
DS: matAlgo03xDSf,
Ss: matAlgo12xSfs
}));
});
;