feat:node-modules
This commit is contained in:
64
node_modules/mathjs/lib/cjs/function/set/setCartesian.js
generated
vendored
Normal file
64
node_modules/mathjs/lib/cjs/function/set/setCartesian.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createSetCartesian = void 0;
|
||||
var _array = require("../../utils/array.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'setCartesian';
|
||||
const dependencies = ['typed', 'size', 'subset', 'compareNatural', 'Index', 'DenseMatrix'];
|
||||
const createSetCartesian = exports.createSetCartesian = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
size,
|
||||
subset,
|
||||
compareNatural,
|
||||
Index,
|
||||
DenseMatrix
|
||||
} = _ref;
|
||||
/**
|
||||
* Create the cartesian product of two (multi)sets.
|
||||
* Multi-dimension arrays will be converted to single-dimension arrays
|
||||
* and the values will be sorted in ascending order before the operation.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.setCartesian(set1, set2)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.setCartesian([1, 2], [3, 4]) // returns [[1, 3], [1, 4], [2, 3], [2, 4]]
|
||||
* math.setCartesian([4, 3], [2, 1]) // returns [[3, 1], [3, 2], [4, 1], [4, 2]]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* setUnion, setIntersect, setDifference, setPowerset
|
||||
*
|
||||
* @param {Array | Matrix} a1 A (multi)set
|
||||
* @param {Array | Matrix} a2 A (multi)set
|
||||
* @return {Array | Matrix} The cartesian product of two (multi)sets
|
||||
*/
|
||||
return typed(name, {
|
||||
'Array | Matrix, Array | Matrix': function (a1, a2) {
|
||||
let result = [];
|
||||
if (subset(size(a1), new Index(0)) !== 0 && subset(size(a2), new Index(0)) !== 0) {
|
||||
// if any of them is empty, return empty
|
||||
const b1 = (0, _array.flatten)(Array.isArray(a1) ? a1 : a1.toArray()).sort(compareNatural);
|
||||
const b2 = (0, _array.flatten)(Array.isArray(a2) ? a2 : a2.toArray()).sort(compareNatural);
|
||||
result = [];
|
||||
for (let i = 0; i < b1.length; i++) {
|
||||
for (let j = 0; j < b2.length; j++) {
|
||||
result.push([b1[i], b2[j]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// return an array, if both inputs were arrays
|
||||
if (Array.isArray(a1) && Array.isArray(a2)) {
|
||||
return result;
|
||||
}
|
||||
// return a matrix otherwise
|
||||
return new DenseMatrix(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
77
node_modules/mathjs/lib/cjs/function/set/setDifference.js
generated
vendored
Normal file
77
node_modules/mathjs/lib/cjs/function/set/setDifference.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createSetDifference = void 0;
|
||||
var _array = require("../../utils/array.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'setDifference';
|
||||
const dependencies = ['typed', 'size', 'subset', 'compareNatural', 'Index', 'DenseMatrix'];
|
||||
const createSetDifference = exports.createSetDifference = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
size,
|
||||
subset,
|
||||
compareNatural,
|
||||
Index,
|
||||
DenseMatrix
|
||||
} = _ref;
|
||||
/**
|
||||
* Create the difference of two (multi)sets: every element of set1, that is not the element of set2.
|
||||
* Multi-dimension arrays will be converted to single-dimension arrays before the operation.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.setDifference(set1, set2)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.setDifference([1, 2, 3, 4], [3, 4, 5, 6]) // returns [1, 2]
|
||||
* math.setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]]) // returns [1, 2]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* setUnion, setIntersect, setSymDifference
|
||||
*
|
||||
* @param {Array | Matrix} a1 A (multi)set
|
||||
* @param {Array | Matrix} a2 A (multi)set
|
||||
* @return {Array | Matrix} The difference of two (multi)sets
|
||||
*/
|
||||
return typed(name, {
|
||||
'Array | Matrix, Array | Matrix': function (a1, a2) {
|
||||
let result;
|
||||
if (subset(size(a1), new Index(0)) === 0) {
|
||||
// empty-anything=empty
|
||||
result = [];
|
||||
} else if (subset(size(a2), new Index(0)) === 0) {
|
||||
// anything-empty=anything
|
||||
return (0, _array.flatten)(a1.toArray());
|
||||
} else {
|
||||
const b1 = (0, _array.identify)((0, _array.flatten)(Array.isArray(a1) ? a1 : a1.toArray()).sort(compareNatural));
|
||||
const b2 = (0, _array.identify)((0, _array.flatten)(Array.isArray(a2) ? a2 : a2.toArray()).sort(compareNatural));
|
||||
result = [];
|
||||
let inb2;
|
||||
for (let i = 0; i < b1.length; i++) {
|
||||
inb2 = false;
|
||||
for (let j = 0; j < b2.length; j++) {
|
||||
if (compareNatural(b1[i].value, b2[j].value) === 0 && b1[i].identifier === b2[j].identifier) {
|
||||
// the identifier is always a decimal int
|
||||
inb2 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!inb2) {
|
||||
result.push(b1[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// return an array, if both inputs were arrays
|
||||
if (Array.isArray(a1) && Array.isArray(a2)) {
|
||||
return (0, _array.generalize)(result);
|
||||
}
|
||||
// return a matrix otherwise
|
||||
return new DenseMatrix((0, _array.generalize)(result));
|
||||
}
|
||||
});
|
||||
});
|
||||
63
node_modules/mathjs/lib/cjs/function/set/setDistinct.js
generated
vendored
Normal file
63
node_modules/mathjs/lib/cjs/function/set/setDistinct.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createSetDistinct = void 0;
|
||||
var _array = require("../../utils/array.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'setDistinct';
|
||||
const dependencies = ['typed', 'size', 'subset', 'compareNatural', 'Index', 'DenseMatrix'];
|
||||
const createSetDistinct = exports.createSetDistinct = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
size,
|
||||
subset,
|
||||
compareNatural,
|
||||
Index,
|
||||
DenseMatrix
|
||||
} = _ref;
|
||||
/**
|
||||
* Collect the distinct elements of a multiset.
|
||||
* A multi-dimension array will be converted to a single-dimension array before the operation.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.setDistinct(set)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.setDistinct([1, 1, 1, 2, 2, 3]) // returns [1, 2, 3]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* setMultiplicity
|
||||
*
|
||||
* @param {Array | Matrix} a A multiset
|
||||
* @return {Array | Matrix} A set containing the distinc elements of the multiset
|
||||
*/
|
||||
return typed(name, {
|
||||
'Array | Matrix': function (a) {
|
||||
let result;
|
||||
if (subset(size(a), new Index(0)) === 0) {
|
||||
// if empty, return empty
|
||||
result = [];
|
||||
} else {
|
||||
const b = (0, _array.flatten)(Array.isArray(a) ? a : a.toArray()).sort(compareNatural);
|
||||
result = [];
|
||||
result.push(b[0]);
|
||||
for (let i = 1; i < b.length; i++) {
|
||||
if (compareNatural(b[i], b[i - 1]) !== 0) {
|
||||
result.push(b[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// return an array, if the input was an array
|
||||
if (Array.isArray(a)) {
|
||||
return result;
|
||||
}
|
||||
// return a matrix otherwise
|
||||
return new DenseMatrix(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
69
node_modules/mathjs/lib/cjs/function/set/setIntersect.js
generated
vendored
Normal file
69
node_modules/mathjs/lib/cjs/function/set/setIntersect.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createSetIntersect = void 0;
|
||||
var _array = require("../../utils/array.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'setIntersect';
|
||||
const dependencies = ['typed', 'size', 'subset', 'compareNatural', 'Index', 'DenseMatrix'];
|
||||
const createSetIntersect = exports.createSetIntersect = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
size,
|
||||
subset,
|
||||
compareNatural,
|
||||
Index,
|
||||
DenseMatrix
|
||||
} = _ref;
|
||||
/**
|
||||
* Create the intersection of two (multi)sets.
|
||||
* Multi-dimension arrays will be converted to single-dimension arrays before the operation.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.setIntersect(set1, set2)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.setIntersect([1, 2, 3, 4], [3, 4, 5, 6]) // returns [3, 4]
|
||||
* math.setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]]) // returns [3, 4]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* setUnion, setDifference
|
||||
*
|
||||
* @param {Array | Matrix} a1 A (multi)set
|
||||
* @param {Array | Matrix} a2 A (multi)set
|
||||
* @return {Array | Matrix} The intersection of two (multi)sets
|
||||
*/
|
||||
return typed(name, {
|
||||
'Array | Matrix, Array | Matrix': function (a1, a2) {
|
||||
let result;
|
||||
if (subset(size(a1), new Index(0)) === 0 || subset(size(a2), new Index(0)) === 0) {
|
||||
// of any of them is empty, return empty
|
||||
result = [];
|
||||
} else {
|
||||
const b1 = (0, _array.identify)((0, _array.flatten)(Array.isArray(a1) ? a1 : a1.toArray()).sort(compareNatural));
|
||||
const b2 = (0, _array.identify)((0, _array.flatten)(Array.isArray(a2) ? a2 : a2.toArray()).sort(compareNatural));
|
||||
result = [];
|
||||
for (let i = 0; i < b1.length; i++) {
|
||||
for (let j = 0; j < b2.length; j++) {
|
||||
if (compareNatural(b1[i].value, b2[j].value) === 0 && b1[i].identifier === b2[j].identifier) {
|
||||
// the identifier is always a decimal int
|
||||
result.push(b1[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// return an array, if both inputs were arrays
|
||||
if (Array.isArray(a1) && Array.isArray(a2)) {
|
||||
return (0, _array.generalize)(result);
|
||||
}
|
||||
// return a matrix otherwise
|
||||
return new DenseMatrix((0, _array.generalize)(result));
|
||||
}
|
||||
});
|
||||
});
|
||||
68
node_modules/mathjs/lib/cjs/function/set/setIsSubset.js
generated
vendored
Normal file
68
node_modules/mathjs/lib/cjs/function/set/setIsSubset.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createSetIsSubset = void 0;
|
||||
var _array = require("../../utils/array.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'setIsSubset';
|
||||
const dependencies = ['typed', 'size', 'subset', 'compareNatural', 'Index'];
|
||||
const createSetIsSubset = exports.createSetIsSubset = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
size,
|
||||
subset,
|
||||
compareNatural,
|
||||
Index
|
||||
} = _ref;
|
||||
/**
|
||||
* Check whether a (multi)set is a subset of another (multi)set. (Every element of set1 is the element of set2.)
|
||||
* Multi-dimension arrays will be converted to single-dimension arrays before the operation.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.setIsSubset(set1, set2)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.setIsSubset([1, 2], [3, 4, 5, 6]) // returns false
|
||||
* math.setIsSubset([3, 4], [3, 4, 5, 6]) // returns true
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* setUnion, setIntersect, setDifference
|
||||
*
|
||||
* @param {Array | Matrix} a1 A (multi)set
|
||||
* @param {Array | Matrix} a2 A (multi)set
|
||||
* @return {boolean} Returns true when a1 is a subset of a2, returns false otherwise
|
||||
*/
|
||||
return typed(name, {
|
||||
'Array | Matrix, Array | Matrix': function (a1, a2) {
|
||||
if (subset(size(a1), new Index(0)) === 0) {
|
||||
// empty is a subset of anything
|
||||
return true;
|
||||
} else if (subset(size(a2), new Index(0)) === 0) {
|
||||
// anything is not a subset of empty
|
||||
return false;
|
||||
}
|
||||
const b1 = (0, _array.identify)((0, _array.flatten)(Array.isArray(a1) ? a1 : a1.toArray()).sort(compareNatural));
|
||||
const b2 = (0, _array.identify)((0, _array.flatten)(Array.isArray(a2) ? a2 : a2.toArray()).sort(compareNatural));
|
||||
let inb2;
|
||||
for (let i = 0; i < b1.length; i++) {
|
||||
inb2 = false;
|
||||
for (let j = 0; j < b2.length; j++) {
|
||||
if (compareNatural(b1[i].value, b2[j].value) === 0 && b1[i].identifier === b2[j].identifier) {
|
||||
// the identifier is always a decimal int
|
||||
inb2 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (inb2 === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
56
node_modules/mathjs/lib/cjs/function/set/setMultiplicity.js
generated
vendored
Normal file
56
node_modules/mathjs/lib/cjs/function/set/setMultiplicity.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createSetMultiplicity = void 0;
|
||||
var _array = require("../../utils/array.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'setMultiplicity';
|
||||
const dependencies = ['typed', 'size', 'subset', 'compareNatural', 'Index'];
|
||||
const createSetMultiplicity = exports.createSetMultiplicity = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
size,
|
||||
subset,
|
||||
compareNatural,
|
||||
Index
|
||||
} = _ref;
|
||||
/**
|
||||
* Count the multiplicity of an element in a multiset.
|
||||
* A multi-dimension array will be converted to a single-dimension array before the operation.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.setMultiplicity(element, set)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.setMultiplicity(1, [1, 2, 2, 4]) // returns 1
|
||||
* math.setMultiplicity(2, [1, 2, 2, 4]) // returns 2
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* setDistinct, setSize
|
||||
*
|
||||
* @param {number | BigNumber | Fraction | Complex} e An element in the multiset
|
||||
* @param {Array | Matrix} a A multiset
|
||||
* @return {number} The number of how many times the multiset contains the element
|
||||
*/
|
||||
return typed(name, {
|
||||
'number | BigNumber | Fraction | Complex, Array | Matrix': function (e, a) {
|
||||
if (subset(size(a), new Index(0)) === 0) {
|
||||
// if empty, return 0
|
||||
return 0;
|
||||
}
|
||||
const b = (0, _array.flatten)(Array.isArray(a) ? a : a.toArray());
|
||||
let count = 0;
|
||||
for (let i = 0; i < b.length; i++) {
|
||||
if (compareNatural(b[i], e) === 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
});
|
||||
});
|
||||
81
node_modules/mathjs/lib/cjs/function/set/setPowerset.js
generated
vendored
Normal file
81
node_modules/mathjs/lib/cjs/function/set/setPowerset.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createSetPowerset = void 0;
|
||||
var _array = require("../../utils/array.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'setPowerset';
|
||||
const dependencies = ['typed', 'size', 'subset', 'compareNatural', 'Index'];
|
||||
const createSetPowerset = exports.createSetPowerset = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
size,
|
||||
subset,
|
||||
compareNatural,
|
||||
Index
|
||||
} = _ref;
|
||||
/**
|
||||
* Create the powerset of a (multi)set. (The powerset contains very possible subsets of a (multi)set.)
|
||||
* A multi-dimension array will be converted to a single-dimension array before the operation.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.setPowerset(set)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.setPowerset([1, 2, 3]) // returns [[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* setCartesian
|
||||
*
|
||||
* @param {Array | Matrix} a A (multi)set
|
||||
* @return {Array} The powerset of the (multi)set
|
||||
*/
|
||||
return typed(name, {
|
||||
'Array | Matrix': function (a) {
|
||||
if (subset(size(a), new Index(0)) === 0) {
|
||||
// if empty, return empty
|
||||
return [];
|
||||
}
|
||||
const b = (0, _array.flatten)(Array.isArray(a) ? a : a.toArray()).sort(compareNatural);
|
||||
const result = [];
|
||||
let number = 0;
|
||||
while (number.toString(2).length <= b.length) {
|
||||
result.push(_subset(b, number.toString(2).split('').reverse()));
|
||||
number++;
|
||||
}
|
||||
// can not return a matrix, because of the different size of the subarrays
|
||||
return _sort(result);
|
||||
}
|
||||
});
|
||||
|
||||
// create subset
|
||||
function _subset(array, bitarray) {
|
||||
const result = [];
|
||||
for (let i = 0; i < bitarray.length; i++) {
|
||||
if (bitarray[i] === '1') {
|
||||
result.push(array[i]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// sort subsests by length
|
||||
function _sort(array) {
|
||||
let temp = [];
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
for (let j = 0; j < i; j++) {
|
||||
if (array[j].length > array[j + 1].length) {
|
||||
temp = array[j];
|
||||
array[j] = array[j + 1];
|
||||
array[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
});
|
||||
57
node_modules/mathjs/lib/cjs/function/set/setSize.js
generated
vendored
Normal file
57
node_modules/mathjs/lib/cjs/function/set/setSize.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createSetSize = void 0;
|
||||
var _array = require("../../utils/array.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'setSize';
|
||||
const dependencies = ['typed', 'compareNatural'];
|
||||
const createSetSize = exports.createSetSize = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
compareNatural
|
||||
} = _ref;
|
||||
/**
|
||||
* Count the number of elements of a (multi)set. When a second parameter is 'true', count only the unique values.
|
||||
* A multi-dimension array will be converted to a single-dimension array before the operation.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.setSize(set)
|
||||
* math.setSize(set, unique)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.setSize([1, 2, 2, 4]) // returns 4
|
||||
* math.setSize([1, 2, 2, 4], true) // returns 3
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* setUnion, setIntersect, setDifference
|
||||
*
|
||||
* @param {Array | Matrix} a A multiset
|
||||
* @param {boolean} [unique] If true, only the unique values are counted. False by default
|
||||
* @return {number} The number of elements of the (multi)set
|
||||
*/
|
||||
return typed(name, {
|
||||
'Array | Matrix': function (a) {
|
||||
return Array.isArray(a) ? (0, _array.flatten)(a).length : (0, _array.flatten)(a.toArray()).length;
|
||||
},
|
||||
'Array | Matrix, boolean': function (a, unique) {
|
||||
if (unique === false || a.length === 0) {
|
||||
return Array.isArray(a) ? (0, _array.flatten)(a).length : (0, _array.flatten)(a.toArray()).length;
|
||||
} else {
|
||||
const b = (0, _array.flatten)(Array.isArray(a) ? a : a.toArray()).sort(compareNatural);
|
||||
let count = 1;
|
||||
for (let i = 1; i < b.length; i++) {
|
||||
if (compareNatural(b[i], b[i - 1]) !== 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
54
node_modules/mathjs/lib/cjs/function/set/setSymDifference.js
generated
vendored
Normal file
54
node_modules/mathjs/lib/cjs/function/set/setSymDifference.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createSetSymDifference = void 0;
|
||||
var _array = require("../../utils/array.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'setSymDifference';
|
||||
const dependencies = ['typed', 'size', 'concat', 'subset', 'setDifference', 'Index'];
|
||||
const createSetSymDifference = exports.createSetSymDifference = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
size,
|
||||
concat,
|
||||
subset,
|
||||
setDifference,
|
||||
Index
|
||||
} = _ref;
|
||||
/**
|
||||
* Create the symmetric difference of two (multi)sets.
|
||||
* Multi-dimension arrays will be converted to single-dimension arrays before the operation.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.setSymDifference(set1, set2)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.setSymDifference([1, 2, 3, 4], [3, 4, 5, 6]) // returns [1, 2, 5, 6]
|
||||
* math.setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]]) // returns [1, 2, 5, 6]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* setUnion, setIntersect, setDifference
|
||||
*
|
||||
* @param {Array | Matrix} a1 A (multi)set
|
||||
* @param {Array | Matrix} a2 A (multi)set
|
||||
* @return {Array | Matrix} The symmetric difference of two (multi)sets
|
||||
*/
|
||||
return typed(name, {
|
||||
'Array | Matrix, Array | Matrix': function (a1, a2) {
|
||||
if (subset(size(a1), new Index(0)) === 0) {
|
||||
// if any of them is empty, return the other one
|
||||
return (0, _array.flatten)(a2);
|
||||
} else if (subset(size(a2), new Index(0)) === 0) {
|
||||
return (0, _array.flatten)(a1);
|
||||
}
|
||||
const b1 = (0, _array.flatten)(a1);
|
||||
const b2 = (0, _array.flatten)(a2);
|
||||
return concat(setDifference(b1, b2), setDifference(b2, b1));
|
||||
}
|
||||
});
|
||||
});
|
||||
55
node_modules/mathjs/lib/cjs/function/set/setUnion.js
generated
vendored
Normal file
55
node_modules/mathjs/lib/cjs/function/set/setUnion.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createSetUnion = void 0;
|
||||
var _array = require("../../utils/array.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'setUnion';
|
||||
const dependencies = ['typed', 'size', 'concat', 'subset', 'setIntersect', 'setSymDifference', 'Index'];
|
||||
const createSetUnion = exports.createSetUnion = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
size,
|
||||
concat,
|
||||
subset,
|
||||
setIntersect,
|
||||
setSymDifference,
|
||||
Index
|
||||
} = _ref;
|
||||
/**
|
||||
* Create the union of two (multi)sets.
|
||||
* Multi-dimension arrays will be converted to single-dimension arrays before the operation.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.setUnion(set1, set2)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.setUnion([1, 2, 3, 4], [3, 4, 5, 6]) // returns [1, 2, 3, 4, 5, 6]
|
||||
* math.setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]]) // returns [1, 2, 3, 4, 5, 6]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* setIntersect, setDifference
|
||||
*
|
||||
* @param {Array | Matrix} a1 A (multi)set
|
||||
* @param {Array | Matrix} a2 A (multi)set
|
||||
* @return {Array | Matrix} The union of two (multi)sets
|
||||
*/
|
||||
return typed(name, {
|
||||
'Array | Matrix, Array | Matrix': function (a1, a2) {
|
||||
if (subset(size(a1), new Index(0)) === 0) {
|
||||
// if any of them is empty, return the other one
|
||||
return (0, _array.flatten)(a2);
|
||||
} else if (subset(size(a2), new Index(0)) === 0) {
|
||||
return (0, _array.flatten)(a1);
|
||||
}
|
||||
const b1 = (0, _array.flatten)(a1);
|
||||
const b2 = (0, _array.flatten)(a2);
|
||||
return concat(setSymDifference(b1, b2), setIntersect(b1, b2));
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user