mathjs 11.9.1 → 11.10.0
Sign up to get free protection for your applications and to get access to all the features.
- package/HISTORY.md +10 -0
- package/lib/browser/math.js +1 -1
- package/lib/browser/math.js.LICENSE.txt +2 -2
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesIndexClass.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesIndexTransform.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesQuantileSeq.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesQuantileSeqTransform.generated.js +28 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSubset.generated.js +4 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSubsetTransform.generated.js +4 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesZeta.generated.js +46 -0
- package/lib/cjs/entry/dependenciesAny.generated.js +14 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesQuantileSeq.generated.js +2 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesZeta.generated.js +42 -0
- package/lib/cjs/entry/dependenciesNumber.generated.js +7 -0
- package/lib/cjs/entry/impureFunctionsAny.generated.js +52 -40
- package/lib/cjs/entry/impureFunctionsNumber.generated.js +1 -0
- package/lib/cjs/entry/pureFunctionsAny.generated.js +159 -136
- package/lib/cjs/entry/pureFunctionsNumber.generated.js +19 -1
- package/lib/cjs/expression/embeddedDocs/construction/index.js +1 -1
- package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +2 -0
- package/lib/cjs/expression/embeddedDocs/function/special/zeta.js +15 -0
- package/lib/cjs/expression/node/utils/assign.js +7 -2
- package/lib/cjs/expression/transform/index.transform.js +9 -6
- package/lib/cjs/expression/transform/quantileSeq.transform.js +50 -0
- package/lib/cjs/expression/transform/subset.transform.js +7 -3
- package/lib/cjs/factoriesAny.js +14 -0
- package/lib/cjs/factoriesNumber.js +7 -0
- package/lib/cjs/function/matrix/concat.js +2 -29
- package/lib/cjs/function/matrix/subset.js +86 -24
- package/lib/cjs/function/special/zeta.js +169 -0
- package/lib/cjs/function/statistics/quantileSeq.js +39 -17
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/type/matrix/DenseMatrix.js +19 -9
- package/lib/cjs/type/matrix/MatrixIndex.js +38 -6
- package/lib/cjs/type/matrix/function/index.js +6 -4
- package/lib/cjs/type/matrix/utils/broadcast.js +8 -14
- package/lib/cjs/utils/array.js +253 -19
- package/lib/cjs/version.js +1 -1
- package/lib/esm/entry/dependenciesAny/dependenciesIndexClass.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesIndexTransform.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesQuantileSeq.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesQuantileSeqTransform.generated.js +20 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSubset.generated.js +4 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSubsetTransform.generated.js +4 -0
- package/lib/esm/entry/dependenciesAny/dependenciesZeta.generated.js +38 -0
- package/lib/esm/entry/dependenciesAny.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesQuantileSeq.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesZeta.generated.js +34 -0
- package/lib/esm/entry/dependenciesNumber.generated.js +1 -0
- package/lib/esm/entry/impureFunctionsAny.generated.js +53 -41
- package/lib/esm/entry/impureFunctionsNumber.generated.js +2 -1
- package/lib/esm/entry/pureFunctionsAny.generated.js +140 -118
- package/lib/esm/entry/pureFunctionsNumber.generated.js +18 -1
- package/lib/esm/expression/embeddedDocs/construction/index.js +1 -1
- package/lib/esm/expression/embeddedDocs/embeddedDocs.js +2 -0
- package/lib/esm/expression/embeddedDocs/function/special/zeta.js +8 -0
- package/lib/esm/expression/node/utils/assign.js +7 -2
- package/lib/esm/expression/transform/index.transform.js +9 -6
- package/lib/esm/expression/transform/quantileSeq.transform.js +41 -0
- package/lib/esm/expression/transform/subset.transform.js +7 -3
- package/lib/esm/factoriesAny.js +2 -0
- package/lib/esm/factoriesNumber.js +1 -1
- package/lib/esm/function/matrix/concat.js +3 -30
- package/lib/esm/function/matrix/subset.js +85 -25
- package/lib/esm/function/special/zeta.js +146 -0
- package/lib/esm/function/statistics/quantileSeq.js +30 -16
- package/lib/esm/type/matrix/DenseMatrix.js +20 -10
- package/lib/esm/type/matrix/MatrixIndex.js +39 -7
- package/lib/esm/type/matrix/function/index.js +6 -4
- package/lib/esm/type/matrix/utils/broadcast.js +8 -14
- package/lib/esm/utils/array.js +241 -20
- package/lib/esm/version.js +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +16 -0
@@ -1,3 +1,4 @@
|
|
1
|
+
import { checkBroadcastingRules } from '../../../utils/array.js';
|
1
2
|
import { factory } from '../../../utils/factory.js';
|
2
3
|
var name = 'broadcast';
|
3
4
|
var dependancies = ['concat'];
|
@@ -32,10 +33,8 @@ export var createBroadcast = /* #__PURE__ */factory(name, dependancies, _ref =>
|
|
32
33
|
}
|
33
34
|
|
34
35
|
// check if the broadcasting rules applyes for both matrices
|
35
|
-
|
36
|
-
|
37
|
-
_checkRules(sizeB, sizeMax, _dim);
|
38
|
-
}
|
36
|
+
checkBroadcastingRules(sizeA, sizeMax);
|
37
|
+
checkBroadcastingRules(sizeB, sizeMax);
|
39
38
|
|
40
39
|
// reshape A or B if needed to make them ready for concat
|
41
40
|
var AA = A.clone();
|
@@ -47,12 +46,12 @@ export var createBroadcast = /* #__PURE__ */factory(name, dependancies, _ref =>
|
|
47
46
|
}
|
48
47
|
|
49
48
|
// stretches the matrices on each dimension to make them the same size
|
50
|
-
for (var
|
51
|
-
if (AA._size[
|
52
|
-
AA = _stretch(AA, sizeMax[
|
49
|
+
for (var _dim = 0; _dim < N; _dim++) {
|
50
|
+
if (AA._size[_dim] < sizeMax[_dim]) {
|
51
|
+
AA = _stretch(AA, sizeMax[_dim], _dim);
|
53
52
|
}
|
54
|
-
if (BB._size[
|
55
|
-
BB = _stretch(BB, sizeMax[
|
53
|
+
if (BB._size[_dim] < sizeMax[_dim]) {
|
54
|
+
BB = _stretch(BB, sizeMax[_dim], _dim);
|
56
55
|
}
|
57
56
|
}
|
58
57
|
|
@@ -67,9 +66,4 @@ export var createBroadcast = /* #__PURE__ */factory(name, dependancies, _ref =>
|
|
67
66
|
// stretches a matrix up to a certain size in a certain dimension
|
68
67
|
return concat(...Array(sizeToStretch).fill(arrayToStretch), dimToStretch);
|
69
68
|
}
|
70
|
-
function _checkRules(shape, sizeMax, dim) {
|
71
|
-
if (shape[dim] < sizeMax[dim] & shape[dim] > 1) {
|
72
|
-
throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(shape, ") not possible to broadcast dimension ").concat(dim, " with size ").concat(shape[dim], " to size ").concat(sizeMax[dim]));
|
73
|
-
}
|
74
|
-
}
|
75
69
|
});
|
package/lib/esm/utils/array.js
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
1
2
|
import { isInteger } from './number.js';
|
2
|
-
import { isNumber } from './is.js';
|
3
|
+
import { isNumber, isBigNumber, isArray, isString } from './is.js';
|
3
4
|
import { format } from './string.js';
|
4
5
|
import { DimensionError } from '../error/DimensionError.js';
|
5
6
|
import { IndexError } from '../error/IndexError.js';
|
7
|
+
import { deepStrictEqual } from './object.js';
|
6
8
|
|
7
9
|
/**
|
8
10
|
* Calculate the size of a multi dimensional array.
|
@@ -75,6 +77,23 @@ export function validate(array, size) {
|
|
75
77
|
}
|
76
78
|
}
|
77
79
|
|
80
|
+
/**
|
81
|
+
* Validate whether the source of the index matches the size of the Array
|
82
|
+
* @param {Array | Matrix} array Array to be validated
|
83
|
+
* @param {Index} index Index with the source information to validate
|
84
|
+
* @throws DimensionError
|
85
|
+
*/
|
86
|
+
export function validateIndexSourceSize(value, index) {
|
87
|
+
var valueSize = value.isMatrix ? value._size : arraySize(value);
|
88
|
+
var sourceSize = index._sourceSize;
|
89
|
+
// checks if the source size is not null and matches the valueSize
|
90
|
+
sourceSize.forEach((sourceDim, i) => {
|
91
|
+
if (sourceDim !== null && sourceDim !== valueSize[i]) {
|
92
|
+
throw new DimensionError(sourceDim, valueSize[i]);
|
93
|
+
}
|
94
|
+
});
|
95
|
+
}
|
96
|
+
|
78
97
|
/**
|
79
98
|
* Test whether index is an integer number with index >= 0 and index < length
|
80
99
|
* when length is provided
|
@@ -82,18 +101,44 @@ export function validate(array, size) {
|
|
82
101
|
* @param {number} [length] Length of the array
|
83
102
|
*/
|
84
103
|
export function validateIndex(index, length) {
|
85
|
-
if (
|
86
|
-
|
104
|
+
if (index !== undefined) {
|
105
|
+
if (!isNumber(index) || !isInteger(index)) {
|
106
|
+
throw new TypeError('Index must be an integer (value: ' + index + ')');
|
107
|
+
}
|
108
|
+
if (index < 0 || typeof length === 'number' && index >= length) {
|
109
|
+
throw new IndexError(index, length);
|
110
|
+
}
|
87
111
|
}
|
88
|
-
|
89
|
-
|
112
|
+
}
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Test if and index has empty values
|
116
|
+
* @param {number} index Zero-based index
|
117
|
+
*/
|
118
|
+
export function isEmptyIndex(index) {
|
119
|
+
for (var i = 0; i < index._dimensions.length; ++i) {
|
120
|
+
var dimension = index._dimensions[i];
|
121
|
+
if (dimension._data && isArray(dimension._data)) {
|
122
|
+
if (dimension._size[0] === 0) {
|
123
|
+
return true;
|
124
|
+
}
|
125
|
+
} else if (dimension.isRange) {
|
126
|
+
if (dimension.start === dimension.end) {
|
127
|
+
return true;
|
128
|
+
}
|
129
|
+
} else if (isString(dimension)) {
|
130
|
+
if (dimension.length === 0) {
|
131
|
+
return true;
|
132
|
+
}
|
133
|
+
}
|
90
134
|
}
|
135
|
+
return false;
|
91
136
|
}
|
92
137
|
|
93
138
|
/**
|
94
139
|
* Resize a multi dimensional array. The resized array is returned.
|
95
|
-
* @param {Array} array Array to be resized
|
96
|
-
* @param {
|
140
|
+
* @param {Array | number} array Array to be resized
|
141
|
+
* @param {number[]} size Array with the size of each dimension
|
97
142
|
* @param {*} [defaultValue=0] Value to be filled in in new entries,
|
98
143
|
* zero by default. Specify for example `null`,
|
99
144
|
* to clearly see entries that are not explicitly
|
@@ -101,10 +146,8 @@ export function validateIndex(index, length) {
|
|
101
146
|
* @return {Array} array The resized array
|
102
147
|
*/
|
103
148
|
export function resize(array, size, defaultValue) {
|
104
|
-
// TODO: add support for scalars, having size=[] ?
|
105
|
-
|
106
149
|
// check the type of the arguments
|
107
|
-
if (!Array.isArray(
|
150
|
+
if (!Array.isArray(size)) {
|
108
151
|
throw new TypeError('Array expected');
|
109
152
|
}
|
110
153
|
if (size.length === 0) {
|
@@ -118,6 +161,11 @@ export function resize(array, size, defaultValue) {
|
|
118
161
|
}
|
119
162
|
});
|
120
163
|
|
164
|
+
// convert number to an array
|
165
|
+
if (isNumber(array) || isBigNumber(array)) {
|
166
|
+
array = [array];
|
167
|
+
}
|
168
|
+
|
121
169
|
// recursively resize the array
|
122
170
|
var _defaultValue = defaultValue !== undefined ? defaultValue : 0;
|
123
171
|
_resize(array, size, 0, _defaultValue);
|
@@ -186,7 +234,7 @@ function _resize(array, size, dim, defaultValue) {
|
|
186
234
|
/**
|
187
235
|
* Re-shape a multi dimensional array to fit the specified dimensions
|
188
236
|
* @param {Array} array Array to be reshaped
|
189
|
-
* @param {
|
237
|
+
* @param {number[]} sizes List of sizes for each dimension
|
190
238
|
* @returns {Array} Array whose data has been formatted to fit the
|
191
239
|
* specified dimensions
|
192
240
|
*
|
@@ -219,10 +267,10 @@ export function reshape(array, sizes) {
|
|
219
267
|
|
220
268
|
/**
|
221
269
|
* Replaces the wildcard -1 in the sizes array.
|
222
|
-
* @param {
|
270
|
+
* @param {number[]} sizes List of sizes for each dimension. At most on wildcard.
|
223
271
|
* @param {number} currentLength Number of elements in the array.
|
224
272
|
* @throws {Error} If more than one wildcard or unable to replace it.
|
225
|
-
* @returns {
|
273
|
+
* @returns {number[]} The sizes array with wildcard replaced.
|
226
274
|
*/
|
227
275
|
export function processSizesWildcard(sizes, currentLength) {
|
228
276
|
var newLength = product(sizes);
|
@@ -247,7 +295,7 @@ export function processSizesWildcard(sizes, currentLength) {
|
|
247
295
|
|
248
296
|
/**
|
249
297
|
* Computes the product of all array elements.
|
250
|
-
* @param {
|
298
|
+
* @param {number[]} array Array of factors
|
251
299
|
* @returns {number} Product of all elements
|
252
300
|
*/
|
253
301
|
function product(array) {
|
@@ -257,7 +305,7 @@ function product(array) {
|
|
257
305
|
/**
|
258
306
|
* Iteratively re-shape a multi dimensional array to fit the specified dimensions
|
259
307
|
* @param {Array} array Array to be reshaped
|
260
|
-
* @param {
|
308
|
+
* @param {number[]} sizes List of sizes for each dimension
|
261
309
|
* @returns {Array} Array whose data has been formatted to fit the
|
262
310
|
* specified dimensions
|
263
311
|
*/
|
@@ -528,18 +576,18 @@ export function getArrayDataType(array, typeOf) {
|
|
528
576
|
|
529
577
|
for (var i = 0; i < array.length; i++) {
|
530
578
|
var item = array[i];
|
531
|
-
var
|
579
|
+
var _isArray = Array.isArray(item);
|
532
580
|
|
533
581
|
// Saving the target matrix row size
|
534
|
-
if (i === 0 &&
|
582
|
+
if (i === 0 && _isArray) {
|
535
583
|
length = item.length;
|
536
584
|
}
|
537
585
|
|
538
586
|
// If the current item is an array but the length does not equal the targetVectorSize
|
539
|
-
if (
|
587
|
+
if (_isArray && item.length !== length) {
|
540
588
|
return undefined;
|
541
589
|
}
|
542
|
-
var itemType =
|
590
|
+
var itemType = _isArray ? getArrayDataType(item, typeOf) // recurse into a nested array
|
543
591
|
: typeOf(item);
|
544
592
|
if (type === undefined) {
|
545
593
|
type = itemType; // first item
|
@@ -554,7 +602,7 @@ export function getArrayDataType(array, typeOf) {
|
|
554
602
|
|
555
603
|
/**
|
556
604
|
* Return the last item from an array
|
557
|
-
* @param array
|
605
|
+
* @param {array}
|
558
606
|
* @returns {*}
|
559
607
|
*/
|
560
608
|
export function last(array) {
|
@@ -563,6 +611,8 @@ export function last(array) {
|
|
563
611
|
|
564
612
|
/**
|
565
613
|
* Get all but the last element of array.
|
614
|
+
* @param {array}
|
615
|
+
* @returns {*}
|
566
616
|
*/
|
567
617
|
export function initial(array) {
|
568
618
|
return array.slice(0, array.length - 1);
|
@@ -576,4 +626,175 @@ export function initial(array) {
|
|
576
626
|
*/
|
577
627
|
export function contains(array, item) {
|
578
628
|
return array.indexOf(item) !== -1;
|
629
|
+
}
|
630
|
+
|
631
|
+
/**
|
632
|
+
* Recursively concatenate two matrices.
|
633
|
+
* The contents of the matrices is not cloned.
|
634
|
+
* @param {Array} a Multi dimensional array
|
635
|
+
* @param {Array} b Multi dimensional array
|
636
|
+
* @param {number} concatDim The dimension on which to concatenate (zero-based)
|
637
|
+
* @param {number} dim The current dim (zero-based)
|
638
|
+
* @return {Array} c The concatenated matrix
|
639
|
+
* @private
|
640
|
+
*/
|
641
|
+
function concatRecursive(a, b, concatDim, dim) {
|
642
|
+
if (dim < concatDim) {
|
643
|
+
// recurse into next dimension
|
644
|
+
if (a.length !== b.length) {
|
645
|
+
throw new DimensionError(a.length, b.length);
|
646
|
+
}
|
647
|
+
var c = [];
|
648
|
+
for (var i = 0; i < a.length; i++) {
|
649
|
+
c[i] = concatRecursive(a[i], b[i], concatDim, dim + 1);
|
650
|
+
}
|
651
|
+
return c;
|
652
|
+
} else {
|
653
|
+
// concatenate this dimension
|
654
|
+
return a.concat(b);
|
655
|
+
}
|
656
|
+
}
|
657
|
+
|
658
|
+
/**
|
659
|
+
* Concatenates many arrays in the specified direction
|
660
|
+
* @param {...Array} arrays All the arrays to concatenate
|
661
|
+
* @param {number} concatDim The dimension on which to concatenate (zero-based)
|
662
|
+
* @returns
|
663
|
+
*/
|
664
|
+
export function concat() {
|
665
|
+
var arrays = Array.prototype.slice.call(arguments, 0, -1);
|
666
|
+
var concatDim = Array.prototype.slice.call(arguments, -1);
|
667
|
+
if (arrays.length === 1) {
|
668
|
+
return arrays[0];
|
669
|
+
}
|
670
|
+
if (arrays.length > 1) {
|
671
|
+
return arrays.slice(1).reduce(function (A, B) {
|
672
|
+
return concatRecursive(A, B, concatDim, 0);
|
673
|
+
}, arrays[0]);
|
674
|
+
} else {
|
675
|
+
throw new Error('Wrong number of arguments in function concat');
|
676
|
+
}
|
677
|
+
}
|
678
|
+
|
679
|
+
/**
|
680
|
+
* Receives two or more sizes and get's the broadcasted size for both.
|
681
|
+
* @param {...number[]} sizes Sizes to broadcast together
|
682
|
+
* @returns
|
683
|
+
*/
|
684
|
+
export function broadcastSizes() {
|
685
|
+
for (var _len = arguments.length, sizes = new Array(_len), _key = 0; _key < _len; _key++) {
|
686
|
+
sizes[_key] = arguments[_key];
|
687
|
+
}
|
688
|
+
var dimensions = sizes.map(s => s.length);
|
689
|
+
var N = Math.max(...dimensions);
|
690
|
+
var sizeMax = new Array(N).fill(null);
|
691
|
+
// check for every size
|
692
|
+
for (var i = 0; i < sizes.length; i++) {
|
693
|
+
var size = sizes[i];
|
694
|
+
var dim = dimensions[i];
|
695
|
+
for (var j = 0; j < dim; j++) {
|
696
|
+
var n = N - dim + j;
|
697
|
+
if (size[j] > sizeMax[n]) {
|
698
|
+
sizeMax[n] = size[j];
|
699
|
+
}
|
700
|
+
}
|
701
|
+
}
|
702
|
+
for (var _i = 0; _i < sizes.length; _i++) {
|
703
|
+
checkBroadcastingRules(sizes[_i], sizeMax);
|
704
|
+
}
|
705
|
+
return sizeMax;
|
706
|
+
}
|
707
|
+
|
708
|
+
/**
|
709
|
+
* Checks if it's possible to broadcast a size to another size
|
710
|
+
* @param {number[]} size The size of the array to check
|
711
|
+
* @param {number[]} toSize The size of the array to validate if it can be broadcasted to
|
712
|
+
*/
|
713
|
+
export function checkBroadcastingRules(size, toSize) {
|
714
|
+
var N = toSize.length;
|
715
|
+
var dim = size.length;
|
716
|
+
for (var j = 0; j < dim; j++) {
|
717
|
+
var n = N - dim + j;
|
718
|
+
if (size[j] < toSize[n] && size[j] > 1 || size[j] > toSize[n]) {
|
719
|
+
throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(size, ") not possible to broadcast dimension ").concat(dim, " with size ").concat(size[j], " to size ").concat(toSize[n]));
|
720
|
+
}
|
721
|
+
}
|
722
|
+
}
|
723
|
+
|
724
|
+
/**
|
725
|
+
* Broadcasts a single array to a certain size
|
726
|
+
* @param {array} array Array to be broadcasted
|
727
|
+
* @param {number[]} toSize Size to broadcast the array
|
728
|
+
* @returns The broadcasted array
|
729
|
+
*/
|
730
|
+
export function broadcastTo(array, toSize) {
|
731
|
+
var Asize = arraySize(array);
|
732
|
+
if (deepStrictEqual(Asize, toSize)) {
|
733
|
+
return array;
|
734
|
+
}
|
735
|
+
checkBroadcastingRules(Asize, toSize);
|
736
|
+
var broadcastedSize = broadcastSizes(Asize, toSize);
|
737
|
+
var N = broadcastedSize.length;
|
738
|
+
var paddedSize = [...Array(N - Asize.length).fill(1), ...Asize];
|
739
|
+
var A = clone(array);
|
740
|
+
// reshape A if needed to make it ready for concat
|
741
|
+
if (Asize.length < N) {
|
742
|
+
A = reshape(A, paddedSize);
|
743
|
+
Asize = arraySize(A);
|
744
|
+
}
|
745
|
+
|
746
|
+
// stretches the array on each dimension to make it the same size as index
|
747
|
+
for (var dim = 0; dim < N; dim++) {
|
748
|
+
if (Asize[dim] < broadcastedSize[dim]) {
|
749
|
+
A = stretch(A, broadcastedSize[dim], dim);
|
750
|
+
Asize = arraySize(A);
|
751
|
+
}
|
752
|
+
}
|
753
|
+
return A;
|
754
|
+
}
|
755
|
+
|
756
|
+
/**
|
757
|
+
* Broadcasts arrays and returns the broadcasted arrays in an array
|
758
|
+
* @param {...Array | any} arrays
|
759
|
+
* @returns
|
760
|
+
*/
|
761
|
+
export function broadcastArrays() {
|
762
|
+
for (var _len2 = arguments.length, arrays = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
763
|
+
arrays[_key2] = arguments[_key2];
|
764
|
+
}
|
765
|
+
if (arrays.length === 0) {
|
766
|
+
throw new Error('Insuficient number of argumnets in function broadcastArrays');
|
767
|
+
}
|
768
|
+
if (arrays.length === 1) {
|
769
|
+
return arrays[0];
|
770
|
+
}
|
771
|
+
var sizes = arrays.map(function (array) {
|
772
|
+
return arraySize(array);
|
773
|
+
});
|
774
|
+
var broadcastedSize = broadcastSizes(...sizes);
|
775
|
+
var broadcastedArrays = [];
|
776
|
+
arrays.forEach(function (array) {
|
777
|
+
broadcastedArrays.push(broadcastTo(array, broadcastedSize));
|
778
|
+
});
|
779
|
+
return broadcastedArrays;
|
780
|
+
}
|
781
|
+
|
782
|
+
/**
|
783
|
+
* stretches a matrix up to a certain size in a certain dimension
|
784
|
+
* @param {Array} arrayToStretch
|
785
|
+
* @param {number[]} sizeToStretch
|
786
|
+
* @param {number} dimToStretch
|
787
|
+
* @returns
|
788
|
+
*/
|
789
|
+
export function stretch(arrayToStretch, sizeToStretch, dimToStretch) {
|
790
|
+
return concat(...Array(sizeToStretch).fill(arrayToStretch), dimToStretch);
|
791
|
+
}
|
792
|
+
|
793
|
+
/**
|
794
|
+
* Deep clones a multidimensional array
|
795
|
+
* @param {Array} array
|
796
|
+
* @returns cloned array
|
797
|
+
*/
|
798
|
+
export function clone(array) {
|
799
|
+
return _extends([], array);
|
579
800
|
}
|
package/lib/esm/version.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mathjs",
|
3
|
-
"version": "11.
|
3
|
+
"version": "11.10.0",
|
4
4
|
"description": "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 different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.",
|
5
5
|
"author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",
|
6
6
|
"homepage": "https://mathjs.org",
|
package/types/index.d.ts
CHANGED
@@ -2600,6 +2600,14 @@ declare namespace math {
|
|
2600
2600
|
*/
|
2601
2601
|
erf<T extends number | MathCollection>(x: T): NoLiteralType<T>
|
2602
2602
|
|
2603
|
+
/**
|
2604
|
+
* Compute the Riemann Zeta function of a value using an infinite series
|
2605
|
+
* and Riemann's Functional equation.
|
2606
|
+
* @param s A real, complex or BigNumber
|
2607
|
+
* @returns The Riemann Zeta of s
|
2608
|
+
*/
|
2609
|
+
zeta<T extends number | Complex | BigNumber>(s: T): T
|
2610
|
+
|
2603
2611
|
/*************************************************************************
|
2604
2612
|
* Statistics functions
|
2605
2613
|
************************************************************************/
|
@@ -5977,6 +5985,14 @@ declare namespace math {
|
|
5977
5985
|
this: MathJsChain<T>
|
5978
5986
|
): MathJsChain<NoLiteralType<T>>
|
5979
5987
|
|
5988
|
+
/**
|
5989
|
+
* Compute the Riemann Zeta function of a value using an infinite series
|
5990
|
+
* and Riemann's Functional equation.
|
5991
|
+
*/
|
5992
|
+
zeta<T extends number | Complex | BigNumber>(
|
5993
|
+
this: MathJsChain<T>
|
5994
|
+
): MathJsChain<T>
|
5995
|
+
|
5980
5996
|
/*************************************************************************
|
5981
5997
|
* Statistics functions
|
5982
5998
|
************************************************************************/
|