forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mathjs.d.ts
2138 lines (1837 loc) · 84.6 KB
/
mathjs.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for mathjs
// Project: http://mathjs.org/
// Definitions by: Ilya Shestakov <https://github.com/siavol/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare var math: mathjs.IMathJsStatic;
declare module mathjs {
type MathArray = number[]|number[][];
type MathType = number|BigNumber|Fraction|Complex|Unit|MathArray|Matrix;
type MathExpression = string|string[]|MathArray|Matrix;
export interface IMathJsStatic {
e: number;
pi: number;
uninitialized: any;
config(options: any): void;
/**
* Solves the linear equation system by forwards substitution. Matrix must be a lower triangular matrix.
* @param L A N x N matrix or array (L)
* @param b A column vector with the b values
* @returns A column vector with the linear system solution (x)
*/
lsolve(L: Matrix|MathArray, b: Matrix|MathArray): Matrix|MathArray;
/**
* Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in two matrices (L, U)
* and a row permutation vector p where A[p,:] = L * U
* @param A A two dimensional matrix or array for which to get the LUP decomposition.
* @returns The lower triangular matrix, the upper triangular matrix and the permutation matrix.
*/
lup(A?: Matrix|MathArray): MathArray;
/**
* Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.
* @param A Invertible Matrix or the Matrix LU decomposition
* @param b Column Vector
* @returns Column vector with the solution to the linear system A * x = b
*/
lusolve(A: Matrix|MathArray|Number, b: Matrix|MathArray): Matrix|MathArray;
/**
* Calculate the Sparse Matrix LU decomposition with full pivoting. Sparse Matrix A is decomposed in
* two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U
* @param A A two dimensional sparse matrix for which to get the LU decomposition.
* @param order The Symbolic Ordering and Analysis order: 0 - Natural ordering, no permutation vector q is
* returned 1 - Matrix must be square, symbolic ordering and analisis is performed on M = A + A' 2 - Symbolic
* ordering and analisis is performed on M = A' * A. Dense columns from A' are dropped, A recreated from A'.
* This is appropriatefor LU factorization of unsymmetric matrices. 3 - Symbolic ordering and analisis is performed
* on M = A' * A. This is best used for LU factorization is matrix M has no dense rows. A dense row is a row with
* more than 10*sqr(columns) entries.
* @param threshold Partial pivoting threshold (1 for partial pivoting)
* @returns The lower triangular matrix, the upper triangular matrix and the permutation vectors.
*/
slu(A: Matrix, order: Number, threshold: Number): any;
/**
* Solves the linear equation system by backward substitution. Matrix must be an upper triangular matrix. U * x = b
* @param U A N x N matrix or array (U)
* @param b A column vector with the b values
* @returns A column vector with the linear system solution (x)
*/
usolve(U: Matrix|MathArray, b:Matrix|MathArray): Matrix|MathArray;
/**
* Calculate the absolute value of a number. For matrices, the function is evaluated element wise.
* @param x A number or matrix for which to get the absolute value
* @returns Absolute value of x
*/
abs(x: number): number;
abs(x: BigNumber): BigNumber;
abs(x: Fraction): Fraction;
abs(x: Complex): Complex;
abs(x: MathArray): MathArray;
abs(x: Matrix): Matrix;
abs(x: Unit): Unit;
/**
* Add two values, x + y. For matrices, the function is evaluated element wise.
* @param x First value to add
* @param y Second value to add
* @returns Sum of x and y
*/
add(x: MathType, y: MathType): MathType;
/**
* Calculate the cubic root of a value. For matrices, the function is evaluated element wise.
* @param x Value for which to calculate the cubic root.
* @param allRoots Optional, false by default. Only applicable when x is a number or complex number. If true, all complex roots are returned, if false (default) the principal root is returned.
* @returns Returns the cubic root of x
*/
cbrt(x: number, allRoots?: boolean): number;
cbrt(x: BigNumber, allRoots?: boolean): BigNumber;
cbrt(x: Fraction, allRoots?: boolean): Fraction;
cbrt(x: Complex, allRoots?: boolean): Complex;
cbrt(x: MathArray, allRoots?: boolean): MathArray;
cbrt(x: Matrix, allRoots?: boolean): Matrix;
cbrt(x: Unit, allRoots?: boolean): Unit;
/**
* Round a value towards plus infinity If x is complex, both real and imaginary part are rounded towards plus infinity. For matrices, the function is evaluated element wise.
* @param x Number to be rounded
* @returns Rounded value
*/
ceil(x: number): number;
ceil(x: BigNumber): BigNumber;
ceil(x: Fraction): Fraction;
ceil(x: Complex): Complex;
ceil(x: MathArray): MathArray;
ceil(x: Matrix): Matrix;
ceil(x: Unit): Unit;
/**
* Compute the cube of a value, x * x * x. For matrices, the function is evaluated element wise.
* @param x Number for which to calculate the cube
* @returns Cube of x
*/
cube(x: number): number;
cube(x: BigNumber): BigNumber;
cube(x: Fraction): Fraction;
cube(x: Complex): Complex;
cube(x: MathArray): MathArray;
cube(x: Matrix): Matrix;
cube(x: Unit): Unit;
/**
* Divide two values, x / y. To divide matrices, x is multiplied with the inverse of y: x * inv(y).
* @param x Numerator
* @param y Denominator
* @returns Quotient, x / y
*/
divide(x: Unit, y: Unit): Unit;
divide(x: number, y: number): number;
divide(x:MathType, y:MathType): MathType;
/**
* Divide two matrices element wise. The function accepts both matrices and scalar values.
* @param x Numerator
* @param y Denominator
* @returns Quotient, x ./ y
*/
dotDivide(x: MathType, y: MathType): MathType;
/**
* Multiply two matrices element wise. The function accepts both matrices and scalar values.
* @param x Left hand value
* @param y Right hand value
* @returns Multiplication of x and y
*/
dotMultiply(x: MathType, y: MathType): MathType;
/**
* Calculates the power of x to y element wise.
* @param x The base
* @param y The exponent
* @returns The value of x to the power y
*/
dotPow(x: MathType, y: MathType): MathType;
/**
* Calculate the exponent of a value. For matrices, the function is evaluated element wise.
* @param x A number or matrix to exponentiate
* #returns Exponent of x
*/
exp(x: number): number;
exp(x: BigNumber ): BigNumber ;
exp(x: Complex ): Complex ;
exp(x: MathArray ): MathArray ;
exp(x: Matrix): Matrix;
/**
* Round a value towards zero. For matrices, the function is evaluated element wise.
* @param x Number to be rounded
* @returns Rounded value
*/
fix(x: number): number;
fix(x: BigNumber ): BigNumber ;
fix(x: Fraction ): Fraction ;
fix(x: Complex ): Complex ;
fix(x: MathArray ): MathArray ;
fix(x: Matrix): Matrix;
/**
* Round a value towards minus infinity. For matrices, the function is evaluated element wise.
* @param Number to be rounded
* @returns Rounded value
*/
floor(x: number): number;
floor(x: BigNumber ): BigNumber ;
floor(x: Fraction ): Fraction ;
floor(x: Complex ): Complex ;
floor(x: MathArray ): MathArray ;
floor(x: Matrix): Matrix;
/**
* Calculate the greatest common divisor for two or more values or arrays. For matrices, the function is evaluated element wise.
*/
gcd(...args: number[]): number;
gcd(...args: BigNumber[]): BigNumber ;
gcd(...args: Fraction[]): Fraction ;
gcd(...args: MathArray[]): MathArray ;
gcd(...args: Matrix[]): Matrix;
/**
* Calculate the hypotenusa of a list with values. The hypotenusa is defined as:
* hypot(a, b, c, ...) = sqrt(a^2 + b^2 + c^2 + ...)
* For matrix input, the hypotenusa is calculated for all values in the matrix.
*/
hypot(...args: number[]): number;
hypot(...args: BigNumber[]): BigNumber;
/**
* Calculate the least common multiple for two or more values or arrays. lcm is defined as:
* lcm(a, b) = abs(a * b) / gcd(a, b)
* For matrices, the function is evaluated element wise.
*/
lcm(a: number, b: number): number;
lcm(a: BigNumber , b: BigNumber ): BigNumber ;
lcm(a: MathArray, b: MathArray): MathArray;
lcm(a: Matrix, b: Matrix): Matrix;
/**
* Calculate the logarithm of a value. For matrices, the function is evaluated element wise.
* @param x Value for which to calculate the logarithm.
* @param base Optional base for the logarithm. If not provided, the natural logarithm of x is calculated. Default value: e.
*/
log(x: number|BigNumber|Complex|MathArray|Matrix, base?: number|BigNumber|Complex): number|BigNumber|Complex|MathArray|Matrix;
/**
* Calculate the 10-base of a value. This is the same as calculating log(x, 10). For matrices, the function is evaluated element wise.
* @param x Value for which to calculate the logarithm.
*/
log10(x: number): number;
log10(x: BigNumber): BigNumber;
log10(x: Complex): Complex;
log10(x: MathArray): MathArray;
log10(x: Matrix): Matrix;
/**
* Calculates the modulus, the remainder of an integer division. For matrices, the function is evaluated element wise.
* The modulus is defined as:
* x - y * floor(x / y)
* See http://en.wikipedia.org/wiki/Modulo_operation.
* @param x Dividend
* @param y Divisor
*/
mod(x: number|BigNumber|Fraction|MathArray|Matrix, y: number|BigNumber|Fraction|MathArray|Matrix): number|BigNumber|Fraction|MathArray|Matrix;
/**
* Multiply two values, x * y. The result is squeezed. For matrices, the matrix product is calculated.
*/
multiply(x: MathArray|Matrix, y: MathArray|Matrix): Matrix;
multiply(x: MathArray|Matrix, y: MathType): Matrix;
multiply(x: Unit, y: Unit): Unit;
multiply(x: number, y: number): number;
multiply(x: MathType, y: MathType): MathType;
/**
* Calculate the norm of a number, vector or matrix. The second parameter p is optional. If not provided, it defaults to 2.
* @param x Value for which to calculate the norm
* @param p Vector space. Supported numbers include Infinity and -Infinity. Supported strings are: 'inf', '-inf', and 'fro' (The Frobenius norm) Default value: 2.
* @returns the p-norm
*/
norm(x: number|BigNumber|Complex|MathArray|Matrix, p?: number|BigNumber|string): number|BigNumber;
/**
* Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation
* x^root = A
* For matrices, the function is evaluated element wise.
* @param a Value for which to calculate the nth root
* @param root The root. Default value: 2.
*/
nthRoot(a: number|BigNumber|MathArray|Matrix|Complex, root?: number|BigNumber): number|Complex|MathArray|Matrix;
/**
* Calculates the power of x to y, x ^ y. Matrix exponentiation is supported for square matrices x, and positive integer exponents y.
* @param x The base
* @param y The exponent
*/
pow(x: number|BigNumber|Complex|MathArray|Matrix, y: number|BigNumber|Complex): number|BigNumber|Complex|MathArray|Matrix;
/**
* Round a value towards the nearest integer. For matrices, the function is evaluated element wise.
* @param x Number to be rounded
* @param n Number of decimals Default value: 0.
*/
round(x: number|BigNumber|Fraction|Complex|MathArray|Matrix, n?: number|BigNumber|MathArray): number|BigNumber|Fraction|Complex|MathArray|Matrix;
/**
* Compute the sign of a value. The sign of a value x is:
* 1 when x > 1
* -1 when x < 0
* 0 when x == 0
* For matrices, the function is evaluated element wise.
*/
sign(x: number): number;
sign(x: BigNumber ): BigNumber;
sign(x: Fraction ): Fraction ;
sign(x: Complex ): Complex ;
sign(x: MathArray): MathArray;
sign(x: Matrix): Matrix;
sign(x: Unit): Unit;
/**
* Calculate the square root of a value. For matrices, the function is evaluated element wise.
*/
sqrt(x: number): number;
sqrt(x: BigNumber ): BigNumber;
sqrt(x: Complex ): Complex ;
sqrt(x: MathArray): MathArray;
sqrt(x: Matrix): Matrix;
sqrt(x: Unit): Unit;
/**
* Compute the square of a value, x * x. For matrices, the function is evaluated element wise.
*/
square(x: number): number;
square(x: BigNumber ): BigNumber;
square(x: Fraction ): Fraction ;
square(x: Complex ): Complex ;
square(x: MathArray): MathArray;
square(x: Matrix): Matrix;
square(x: Unit): Unit;
/**
* Subtract two values, x - y. For matrices, the function is evaluated element wise.
*/
subtract(x: MathType, y: MathType): MathType;
/**
* Inverse the sign of a value, apply a unary minus operation.
* For matrices, the function is evaluated element wise. Boolean values and strings will be converted to a number. For complex numbers, both real and complex value are inverted.
*/
unaryMinus(x: number): number;
unaryMinus(x: BigNumber ): BigNumber;
unaryMinus(x: Fraction ): Fraction ;
unaryMinus(x: Complex ): Complex ;
unaryMinus(x: MathArray): MathArray;
unaryMinus(x: Matrix): Matrix;
unaryMinus(x: Unit): Unit;
/**
* Unary plus operation. Boolean values and strings will be converted to a number, numeric values will be returned as is.
* For matrices, the function is evaluated element wise.
*/
unaryPlus(x: number): number;
unaryPlus(x: BigNumber ): BigNumber;
unaryPlus(x: Fraction ): Fraction ;
unaryPlus(x: string): string;
unaryPlus(x: Complex ): Complex ;
unaryPlus(x: MathArray): MathArray;
unaryPlus(x: Matrix): Matrix;
unaryPlus(x: Unit): Unit;
/**
* Calculate the extended greatest common divisor for two values. See http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm.
*/
xgcd(a: number|BigNumber, b: number|BigNumber): MathArray;
/**
* Bitwise AND two values, x & y. For matrices, the function is evaluated element wise.
*/
bitAnd(x: number|BigNumber|MathArray|Matrix, y: number|BigNumber|MathArray|Matrix): number|BigNumber|MathArray|Matrix;
/**
* Bitwise NOT value, ~x. For matrices, the function is evaluated element wise. For units, the function is evaluated on the best prefix base.
*/
bitNot(x: number): number;
bitNot(x: BigNumber ): BigNumber ;
bitNot(x: MathArray): MathArray;
bitNot(x: Matrix): Matrix;
/**
* Bitwise OR two values, x | y. For matrices, the function is evaluated element wise. For units, the function is evaluated on the lowest print base.
*/
bitOr(x: number): number;
bitOr(x: BigNumber ): BigNumber ;
bitOr(x: MathArray): MathArray;
bitOr(x: Matrix): Matrix;
/**
* Bitwise XOR two values, x ^ y. For matrices, the function is evaluated element wise.
*/
bitXor(x: number|BigNumber|MathArray|Matrix, y: number|BigNumber|MathArray|Matrix): number|BigNumber|MathArray|Matrix;
/**
* Bitwise left logical shift of a value x by y number of bits, x << y. For matrices, the function is evaluated element wise. For units, the function is evaluated on the best prefix base.
* @param x Value to be shifted
* @param y Amount of shifts
*/
leftShift(x: number|BigNumber|MathArray|Matrix, y: number|BigNumber): number|BigNumber|MathArray|Matrix;
/**
* Bitwise right arithmetic shift of a value x by y number of bits, x >> y. For matrices, the function is evaluated element wise. For units, the function is evaluated on the best prefix base.
* @param x Value to be shifted
* @param y Amount of shifts
*/
rightArithShift(x: number|BigNumber|MathArray|Matrix, y: number|BigNumber): number|BigNumber|MathArray|Matrix;
/**
* Bitwise right logical shift of value x by y number of bits, x >>> y. For matrices, the function is evaluated element wise. For units, the function is evaluated on the best prefix base.
* @param x Value to be shifted
* @param y Amount of shifts
*/
rightLogShift(x: number|MathArray|Matrix, y: number): number|MathArray|Matrix;
/**
* The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. bellNumbers only takes integer arguments. The following condition must be enforced: n >= 0
* @param n Total number of objects in the set
*/
bellNumbers(n: Number): Number;
bellNumbers(n: BigNumber): BigNumber;
/**
* The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0
* @pararm n nth Catalan number
*/
catalan(n: Number): Number;
catalan(n: BigNumber): BigNumber;
/**
* The composition counts of n into k parts. Composition only takes integer arguments. The following condition must be enforced: k <= n.
* @param n Total number of objects in the set
* @param k Number of objects in the subset
* @returns Returns the composition counts of n into k parts.
*/
composition(n: Number|BigNumber, k: Number|BigNumber): Number|BigNumber
/**
* The Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. stirlingS2 only takes integer arguments. The following condition must be enforced: k <= n.
* If n = k or k = 1, then s(n,k) = 1
* @param n Total number of objects in the set
* @param k Number of objects in the subset
*/
stirlingS2(n: Number|BigNumber, k: Number|BigNumber): Number|BigNumber;
/**
* Compute the argument of a complex value. For a complex number a + bi, the argument is computed as atan2(b, a). For matrices, the function is evaluated element wise.
* @param x A complex number or array with complex numbers
*/
arg(x: number): number;
arg(x: Complex): number;
arg(x: MathArray): MathArray;
arg(x: Matrix): Matrix;
/**
* Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate of x is a - bi. For matrices, the function is evaluated element wise.
* @param x A complex number or array with complex numbers
*/
conj(x: number|BigNumber|Complex|MathArray|Matrix): number|BigNumber|Complex|MathArray|Matrix;
/**
* Get the imaginary part of a complex number. For a complex number a + bi, the function returns b.
* For matrices, the function is evaluated element wise.
*/
im(x: number|BigNumber|Complex|MathArray|Matrix): number|BigNumber|MathArray|Matrix;
/**
* Get the real part of a complex number. For a complex number a + bi, the function returns a.
* For matrices, the function is evaluated element wise.
*/
re(x: number|BigNumber|Complex|MathArray|Matrix): number|BigNumber|MathArray|Matrix;
/**
* Create a BigNumber, which can store numbers with arbitrary precision. When a matrix is provided, all elements will be converted to BigNumber.
*/
bignumber(x?: number|string|MathArray|Matrix|boolean): BigNumber;
/**
* Create a boolean or convert a string or number to a boolean. In case of a number, true is returned for non-zero numbers, and false in case of zero. Strings can be 'true' or 'false', or can contain a number. When value is a matrix, all elements will be converted to boolean.
*/
boolean(x: string|number|boolean|MathArray|Matrix ): boolean|MathArray|Matrix;
/**
* Wrap any value in a chain, allowing to perform chained operations on the value.
* All methods available in the math.js library can be called upon the chain, and then will be evaluated with the value itself as first argument. The chain can be closed by executing chain.done(), which returns the final value.
* The chain has a number of special functions:
* done() Finalize the chain and return the chain's value.
* valueOf() The same as done()
* toString() Executes math.format() onto the chain's value, returning a string representation of the value.
*/
chain(value?: any): IMathJsChain;
/**
* Create a complex value or convert a value to a complex value.
*/
complex(): Complex;
complex(re: number, im: number): Complex;
complex(complex: Complex): Complex;
complex(arg: string): Complex;
complex(array: MathArray): Complex;
complex(obj: IPolarCoordinates): Complex;
/**
* Create a fraction convert a value to a fraction.
*/
fraction(numerator: number|string|MathArray|Matrix, denominator?: number|string|MathArray|Matrix): Fraction|MathArray|Matrix;
/**
* Create an index. An Index can store ranges having start, step, and end for multiple dimensions. Matrix.get, Matrix.set, and math.subset accept an Index as input.
*/
index(...ranges: any[]): Index;
/**
* Create a Matrix. The function creates a new math.type.Matrix object from an Array. A Matrix has utility functions
* to manipulate the data in the matrix, like getting the size and getting or setting values in the matrix. Supported
* storage formats are 'dense' and 'sparse'.
*/
matrix(format?: string): Matrix;
matrix(data: MathArray|Matrix, format?: string, dataType?:string): Matrix;
/**
* Create a number or convert a string, boolean, or unit to a number. When value is a matrix, all elements will be converted to number.
*/
number(value?: string|number|boolean|MathArray|Matrix|Unit): number|MathArray|Matrix;
number(unit: Unit, valuelessUnit: Unit|string): number|MathArray|Matrix;
/**
* Create a Sparse Matrix. The function creates a new math.type.Matrix object from an Array. A Matrix has utility
* functions to manipulate the data in the matrix, like getting the size and getting or setting values in the matrix.
* @param data A two dimensional array
*/
sparse(data?: MathArray|Matrix, dataType?:string): Matrix;
/**
* Create a string or convert any object into a string. Elements of Arrays and Matrices are processed element wise.
* @param value A value to convert to a string
*/
string(value: any): string|MathArray|Matrix;
/**
* Create a unit. Depending on the passed arguments, the function will create and return a new math.type.Unit object.
* When a matrix is provided, all elements will be converted to units.
*/
unit(unit: string): Unit;
unit(value: number, unit: string): Unit;
/**
* Parse and compile an expression. Returns a an object with a function eval([scope]) to evaluate the compiled expression.
*/
compile(expr: MathExpression): EvalFunction;
compile(exprs: MathExpression[]): EvalFunction[];
/**
* Evaluate an expression.
*/
eval(expr: MathExpression, scope?: any): any;
eval(exprs: MathExpression[], scope?: any): any;
/**
* Retrieve help on a function or data type. Help files are retrieved from the documentation in math.expression.docs.
*/
help(search: any): Help;
/**
* Parse an expression. Returns a node tree, which can be evaluated by invoking node.eval();
*/
parse(expr: MathExpression, options?: any): MathNode;
parse(exprs: MathExpression[], options?: any): MathNode[];
/**
* Create a parser. The function creates a new math.expression.Parser object.
*/
parser(): Parser;
/**
* Calculates: The eucledian distance between two points in 2 and 3 dimensional spaces. Distance between point
* and a line in 2 and 3 dimensional spaces. Pairwise distance between a set of 2D or 3D points NOTE: When
* substituting coefficients of a line(a, b and c), use ax + by + c = 0 instead of ax + by = c For parametric
* equation of a 3D line, x0, y0, z0, a, b, c are from: (x−x0, y−y0, z−z0) = t(a, b, c)
*/
distance(x: MathArray|Matrix|any, y: MathArray|Matrix|any): Number | BigNumber;
/**
* Calculates the point of intersection of two lines in two or three dimensions and of a line and a plane in
* three dimensions. The inputs are in the form of arrays or 1 dimensional matrices. The line intersection functions
* return null if the lines do not meet.
* Note: Fill the plane coefficients as x + y + z = c and not as x + y + z + c = 0.
* @param w Co-ordinates of first end-point of first line
* @param x Co-ordinates of second end-point of first line
* @param y Co-ordinates of first end-point of second line OR Co-efficients of the plane's equation
* @param z Co-ordinates of second end-point of second line OR null if the calculation is for line and plane
* @returns Returns the point of intersection of lines/lines-planes
*/
intersect(w: MathArray|Matrix, x: MathArray|Matrix, y: MathArray|Matrix, z: MathArray|Matrix): MathArray;
/**
* Logical and. Test whether two values are both defined with a nonzero/nonempty value. For matrices, the function is evaluated element wise.
*/
and(x: number|BigNumber|Complex|Unit|MathArray|Matrix, y: number|BigNumber|Complex|Unit|MathArray|Matrix): boolean|MathArray|Matrix;
/**
* Logical not. Flips boolean value of a given parameter. For matrices, the function is evaluated element wise.
*/
not(x: number|BigNumber|Complex|Unit|MathArray|Matrix): boolean|MathArray|Matrix;
/**
* Logical or. Test if at least one value is defined with a nonzero/nonempty value. For matrices, the function is evaluated element wise.
*/
or(x: number|BigNumber|Complex|Unit|MathArray|Matrix, y: number|BigNumber|Complex|Unit|MathArray|Matrix): boolean|MathArray|Matrix;
/**
* Logical xor. Test whether one and only one value is defined with a nonzero/nonempty value. For matrices, the function is evaluated element wise.
*/
xor(x: number|BigNumber|Complex|Unit|MathArray|Matrix, y: number|BigNumber|Complex|Unit|MathArray|Matrix): boolean|MathArray|Matrix;
/**
* Concatenate two or more matrices.
* dim: number is a zero-based dimension over which to concatenate the matrices. By default the last dimension of the matrices.
*/
concat(...args: (MathArray|Matrix|number)[]): MathArray|Matrix;
/**
* Calculate the cross product for two vectors in three dimensional space. The cross product of A = [a1, a2, a3]
* and B =[b1, b2, b3] is defined as:
* cross(A, B) = [ a2 * b3 - a3 * b2, a3 * b1 - a1 * b3, a1 * b2 - a2 * b1 ]
*/
cross(x: MathArray|Matrix, y: MathArray|Matrix): Matrix;
/**
* Calculate the determinant of a matrix.
*/
det(x: MathArray|Matrix): number;
/**
* Create a diagonal matrix or retrieve the diagonal of a matrix.
* When x is a vector, a matrix with vector x on the diagonal will be returned. When x is a two dimensional matrix,
* the matrixes kth diagonal will be returned
* as vector. When k is positive, the values are placed on the super diagonal. When k is negative, the values are
* placed on the sub diagonal.
* @param X A two dimensional matrix or a vector
* @param k The diagonal where the vector will be filled in or retrieved. Default value: 0.
* @param format The matrix storage format. Default value: 'dense'.
*/
diag(X: MathArray|Matrix, format?: string): Matrix;
diag(X: MathArray|Matrix, k: number|BigNumber, format?: string): Matrix;
/**
* Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn]
* is defined as:
* dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn
*/
dot(x: MathArray|Matrix, y: MathArray|Matrix): number;
/**
* Create a 2-dimensional identity matrix with size m x n or n x n. The matrix has ones on the diagonal and zeros elsewhere.
*/
eye(n: number, format?: string): Matrix;
eye(m: number, n: number, format?: string): Matrix;
eye(size: number[], format?: string): Matrix;
/**
* Flatten a multi dimensional matrix into a single dimensional matrix.
*/
flatten(x: MathArray|Matrix): MathArray|Matrix;
/**
* Calculate the inverse of a square matrix.
*/
inv(x: number|Complex|MathArray|Matrix): number|Complex|MathArray|Matrix;
/**
* Create a matrix filled with ones. The created matrix can have one or multiple dimensions.
*/
ones(n: number, format?: string): MathArray|Matrix;
ones(m: number, n: number, format?: string): MathArray|Matrix;
ones(size: number[], format?: string): MathArray|Matrix;
/**
* Create an array from a range. By default, the range end is excluded. This can be customized by providing an extra parameter includeEnd.
* @param str A string 'start:end' or 'start:step:end'
* @param start Start of the range
* @param end End of the range, excluded by default, included when parameter includeEnd=true
* @param step Step size. Default value is 1.
* @returns Parameters describing the ranges start, end, and optional step.
*/
range(str: string, includeEnd?: boolean): Matrix;
range(start: number|BigNumber, end:number|BigNumber, includeEnd?:boolean): Matrix;
range(start: number|BigNumber, end: number|BigNumber, step: number|BigNumber, includeEnd?:boolean): Matrix;
/**
* Resize a matrix
* @param x Matrix to be resized
* @param size One dimensional array with numbers
* @param defaultValue Zero by default, except in case of a string, in that case defaultValue = ' ' Default value: 0.
*/
resize(x: MathArray|Matrix, size: MathArray|Matrix, defaultValue?: number|string): MathArray|Matrix;
/**
* Calculate the size of a matrix or scalar.
*/
size(x: boolean|number|Complex|Unit|string|MathArray|Matrix): MathArray|Matrix;
/**
* Squeeze a matrix, remove inner and outer singleton dimensions from a matrix.
*/
squeeze(x: MathArray|Matrix): Matrix|MathArray;
/**
* Get or set a subset of a matrix or string.
* @param value An array, matrix, or string
* @param index An index containing ranges for each dimension
* @param replacement An array, matrix, or scalar. If provided, the subset is replaced with replacement. If not provided, the subset is returned
* @param defaultValue Default value, filled in on new entries when the matrix is resized. If not provided, math.matrix elements will be left undefined. Default value: undefined.
*/
subset(value: MathArray|Matrix|string, index: Index, replacement?: any, defaultValue?: any): MathArray|Matrix|string;
/**
* Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.
*/
trace(x: MathArray|Matrix): number;
/**
* Transpose a matrix. All values of the matrix are reflected over its main diagonal. Only two dimensional matrices are supported.
*/
transpose(x: MathArray|Matrix): MathArray|Matrix;
/**
* Create a matrix filled with zeros. The created matrix can have one or multiple dimensions.
*/
zeros(n: number, format?: string): MathArray|Matrix;
zeros(m: number, n: number, format?: string): MathArray|Matrix;
zeros(size: number[], format?: string): MathArray|Matrix;
/**
* Compute the number of ways of picking k unordered outcomes from n possibilities.
* Combinations only takes integer arguments. The following condition must be enforced: k <= n.
*/
combinations(n: number|BigNumber, k: number|BigNumber): number|BigNumber;
/**
* Create a distribution object with a set of random functions for given random distribution.
* @param name Name of a distribution. Choose from 'uniform', 'normal'.
*/
distribution(name: string): Distribution;
/**
* Compute the factorial of a value
* Factorial only supports an integer value as argument. For matrices, the function is evaluated element wise.
*/
factorial(n: number|BigNumber|MathArray|Matrix): number|BigNumber|MathArray|Matrix;
/**
* Compute the gamma function of a value using Lanczos approximation for small values, and an extended
* Stirling approximation for large values.
* For matrices, the function is evaluated element wise.
*/
gamma(n: number|MathArray|Matrix): number|MathArray|Matrix;
/**
* Calculate the Kullback-Leibler (KL) divergence between two distributions
*/
kldivergence(x: MathArray|Matrix, y: MathArray|Matrix): number;
/**
* Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from n possibilities.
* multinomial takes one array of integers as an argument. The following condition must be enforced: every ai <= 0
*/
multinomial(a: number[]|BigNumber[]): number|BigNumber;
/**
* Compute the number of ways of obtaining an ordered subset of k elements from a set of n elements.
* Permutations only takes integer arguments. The following condition must be enforced: k <= n.
* @param n The number of objects in total
* @param k The number of objects in the subset
*/
permutations(n: number|BigNumber, k?:number|BigNumber): number|BigNumber;
/**
* Random pick a value from a one dimensional array. Array element is picked using a random function with uniform distribution.
*/
pickRandom(array: number[]): number;
/**
* Return a random number larger or equal to min and smaller than max using a uniform distribution.
*/
random(): number;
random(max: number): number;
random(min: number, max: number): number;
random(size: MathArray|Matrix, max?: number): MathArray|Matrix;
random(size: MathArray|Matrix, min:number, max: number): MathArray|Matrix;
/**
* Return a random integer number larger or equal to min and smaller than max using a uniform distribution.
*/
randomInt(max: number): number;
randomInt(min: number, max: number): number;
randomInt(size: MathArray|Matrix, max?: number): MathArray|Matrix;
randomInt(size: MathArray|Matrix, min:number, max: number): MathArray|Matrix;
/**
* Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.
* x and y are considered equal when the relative difference between x and y is smaller than the configured epsilon.
* The function cannot be used to compare values smaller than approximately 2.22e-16.
* For matrices, the function is evaluated element wise.
*/
compare(x: MathType, y: MathType): number|BigNumber|Fraction|MathArray|Matrix;
/**
* Test element wise whether two matrices are equal. The function accepts both matrices and scalar values.
*/
deepEqual(x: MathType, y: MathType): number|BigNumber|Fraction|Complex|Unit|MathArray|Matrix;
/**
* Test whether two values are equal.
*
* The function tests whether the relative difference between x and y is smaller than the configured epsilon.
* The function cannot be used to compare values smaller than approximately 2.22e-16.
*
* For matrices, the function is evaluated element wise. In case of complex numbers, x.re must equal y.re, and x.im must equal y.im.
*
* Values null and undefined are compared strictly, thus null is only equal to null and nothing else, and undefined is only equal to undefined and nothing else.
*/
equal(x: MathType, y: MathType): boolean|MathArray|Matrix;
/**
* Test whether value x is larger than y.
*
* The function returns true when x is larger than y and the relative difference between x and y is larger than the configured epsilon.
* The function cannot be used to compare values smaller than approximately 2.22e-16.
*
* For matrices, the function is evaluated element wise.
*/
larger(x: MathType, y: MathType): boolean|MathArray|Matrix;
/**
* Test whether value x is larger or equal to y.
*
* The function returns true when x is larger than y or the relative difference between x and y is smaller than the configured epsilon.
* The function cannot be used to compare values smaller than approximately 2.22e-16.
*
* For matrices, the function is evaluated element wise.
*/
largerEq(x: MathType, y: MathType): boolean|MathArray|Matrix;
/**
* Test whether value x is smaller than y.
*
* The function returns true when x is smaller than y and the relative difference between x and y is smaller than the configured epsilon.
* The function cannot be used to compare values smaller than approximately 2.22e-16.
*
* For matrices, the function is evaluated element wise.
*/
smaller(x: MathType, y: MathType): boolean|MathArray|Matrix;
/**
* Test whether value x is smaller or equal to y.
*
* The function returns true when x is smaller than y or the relative difference between x and y is smaller than the configured epsilon.
* The function cannot be used to compare values smaller than approximately 2.22e-16. For matrices, the function is evaluated element wise.
*/
smallerEq(x: MathType, y: MathType): boolean|MathArray|Matrix;
/**
* Test whether two values are unequal.
*
* The function tests whether the relative difference between x and y is larger than the configured epsilon. The function cannot
* be used to compare values smaller than approximately 2.22e-16.
*
* For matrices, the function is evaluated element wise. In case of complex numbers, x.re must unequal y.re, or x.im must unequal y.im.
*
* Values null and undefined are compared strictly, thus null is unequal with everything except null, and undefined is unequal with
* everying except. undefined.
*/
unequal(x: MathType, y: MathType): boolean|MathArray|Matrix;
/**
* Compute the maximum value of a matrix or a list with values. In case of a multi dimensional array, the maximum of the flattened
* array will be calculated. When dim is provided, the maximum over the selected dimension will be calculated. Parameter dim is zero-based.
*/
max(...args: MathType[]): any;
max(A: MathArray|Matrix, dim?: number): any;
/**
* Compute the mean value of matrix or a list with values. In case of a multi dimensional array, the mean of the flattened array will be
* calculated. When dim is provided, the maximum over the selected dimension will be calculated. Parameter dim is zero-based.
*/
mean(...args: MathType[]): any;
mean(A: MathArray|Matrix, dim?: number): any;
/**
* Compute the median of a matrix or a list with values. The values are sorted and the middle value is returned. In case of an
* even number of values, the average of the two middle values is returned. Supported types of values are: Number, BigNumber, Unit
*
* In case of a (multi dimensional) array or matrix, the median of all elements will be calculated.
*/
median(...args: MathType[]): any;
/**
* Compute the maximum value of a matrix or a list of values. In case of a multi dimensional array, the maximum of the flattened
* array will be calculated. When dim is provided, the maximum over the selected dimension will be calculated. Parameter dim is zero-based.
*/
min(...args: MathType[]): any;
min(A: MathArray|Matrix, dim?: number): any;
/**
* Computes the mode of a set of numbers or a list with values(numbers or characters). If there are more than one modes, it returns a list of those values.
*/
mode(...args: MathType[]): any;
/**
* Compute the product of a matrix or a list with values. In case of a (multi dimensional) array or matrix, the sum of all elements will be calculated.
*/
prod(...args: MathType[]): any;
/**
* Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned.
* Supported types of sequence values are: Number, BigNumber, Unit Supported types of probability are: Number, BigNumber
*
* In case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.
*/
quantileSeq(A: MathArray|Matrix, prob: Number|BigNumber|MathArray, sorted?: boolean): Number|BigNumber|Unit|MathArray;
/**
* Compute the standard deviation of a matrix or a list with values. The standard deviations is defined as the square root of the
* variance: std(A) = sqrt(var(A)). In case of a (multi dimensional) array or matrix, the standard deviation over all elements will
* be calculated.
*
* Optionally, the type of normalization can be specified as second parameter. The parameter normalization can be one of the following
* values:
*
* 'unbiased' (default) The sum of squared errors is divided by (n - 1)
* 'uncorrected' The sum of squared errors is divided by n
* 'biased' The sum of squared errors is divided by (n + 1)
*/
std(array: MathArray|Matrix, normalization?: string): number;
/**
* Compute the sum of a matrix or a list with values. In case of a (multi dimensional) array or matrix, the sum of all elements will be calculated.
*/
sum(...args: (Number|BigNumber|Fraction)[]): any;
sum(array: MathArray|Matrix): any;
/**
* Compute the variance of a matrix or a list with values. In case of a (multi dimensional) array or matrix, the variance over all
* elements will be calculated.
*
* Optionally, the type of normalization can be specified as second parameter. The parameter normalization can be one of the
* following values:
*
* 'unbiased' (default) The sum of squared errors is divided by (n - 1)
* 'uncorrected' The sum of squared errors is divided by n
* 'biased' The sum of squared errors is divided by (n + 1)
* Note that older browser may not like the variable name var. In that case, the function can be called as math['var'](...)
* instead of math.var(...).
*/
var(...args: (Number|BigNumber|Fraction)[]): any;
var(array: MathArray|Matrix, normalization?: string): any;
/**
* Calculate the inverse cosine of a value. For matrices, the function is evaluated element wise.
*/
acos(x: number): number;
acos(x: BigNumber): BigNumber;
acos(x: Complex): Complex;
acos(x: MathArray): MathArray;
acos(x: Matrix): Matrix;
/**
* Calculate the hyperbolic arccos of a value, defined as acosh(x) = ln(sqrt(x^2 - 1) + x).
* For matrices, the function is evaluated element wise.
*/
acosh(x: number): number;
acosh(x: BigNumber): BigNumber;
acosh(x: Complex): Complex;
acosh(x: MathArray): MathArray;
acosh(x: Matrix): Matrix;
/**
* Calculate the inverse cotangent of a value. For matrices, the function is evaluated element wise.
*/
acot(x: number): number;
acot(x: BigNumber): BigNumber;
acot(x: MathArray): MathArray;
acot(x: Matrix): Matrix;
/**
* Calculate the hyperbolic arccotangent of a value, defined as acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2.
* For matrices, the function is evaluated element wise.
*/
acoth(x: number): number;
acoth(x: BigNumber): BigNumber;
acoth(x: MathArray): MathArray;
acoth(x: Matrix): Matrix;
/**
* Calculate the inverse cosecant of a value. For matrices, the function is evaluated element wise.
*/
acsc(x: number): number;
acsc(x: BigNumber): BigNumber;
acsc(x: MathArray): MathArray;
acsc(x: Matrix): Matrix;
/**
* Calculate the hyperbolic arccosecant of a value, defined as acsch(x) = ln(1/x + sqrt(1/x^2 + 1)).
* For matrices, the function is evaluated element wise.