mathjs 10.4.0 → 10.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types/index.d.ts CHANGED
@@ -352,6 +352,8 @@ declare namespace math {
352
352
  RelationalNode: RelationalNodeCtor;
353
353
  SymbolNode: SymbolNodeCtor;
354
354
 
355
+ Matrix: MatrixCtor;
356
+
355
357
  /**
356
358
  * If null were to be included in this interface, it would be
357
359
  * auto-suggested as an import in VSCode. This causes issues because
@@ -365,7 +367,11 @@ declare namespace math {
365
367
  version: string;
366
368
 
367
369
  expression: MathNode;
368
- json: MathJsJson;
370
+
371
+ /**
372
+ * Returns reviver function that can be used as reviver in JSON.parse function.
373
+ */
374
+ reviver(): (key: any, value: any) => any;
369
375
 
370
376
  /*************************************************************************
371
377
  * Core functions
@@ -570,6 +576,11 @@ declare namespace math {
570
576
  * @returns The created unit
571
577
  */
572
578
  unit(unit: string): Unit;
579
+ /**
580
+ * @param unit The unit to be created
581
+ * @returns The created unit
582
+ */
583
+ unit(unit: Unit): Unit;
573
584
  /**
574
585
  * @param value The value of the unit to be created
575
586
  * @param unit The unit to be created
@@ -767,6 +778,7 @@ declare namespace math {
767
778
  * @param y Second value to add
768
779
  * @returns Sum of x and y
769
780
  */
781
+ add<T extends MathType>(x: T, y: T): T;
770
782
  add(x: MathType, y: MathType): MathType;
771
783
 
772
784
  /**
@@ -1116,8 +1128,7 @@ declare namespace math {
1116
1128
  * @param y Value to subtract from x
1117
1129
  * @returns Subtraction of x and y
1118
1130
  */
1119
- subtract(x: number, y: number): number;
1120
- subtract(x: Unit, y: Unit): Unit;
1131
+ subtract<T extends MathType>(x: T, y: T): T;
1121
1132
  subtract(x: MathType, y: MathType): MathType;
1122
1133
 
1123
1134
  /**
@@ -2254,7 +2265,7 @@ declare namespace math {
2254
2265
  * ‘unbiased’.
2255
2266
  * @returns The standard deviation array
2256
2267
  */
2257
- std(array: MathArray | Matrix, dimension: number, normalization?: 'unbiased' | 'uncorrected' | 'biased'): number[]
2268
+ std(array: MathArray | Matrix, dimension?: number, normalization?: 'unbiased' | 'uncorrected' | 'biased'): number[]
2258
2269
  /**
2259
2270
  * Compute the standard deviation of a matrix or a list with values. The
2260
2271
  * standard deviations is defined as the square root of the variance:
@@ -2335,7 +2346,7 @@ declare namespace math {
2335
2346
  * Default value: ‘unbiased’.
2336
2347
  * @returns variance matrix.
2337
2348
  */
2338
- variance(array: MathArray | Matrix, dimension: number, normalization?: 'unbiased' | 'uncorrected' | 'biased'): number[];
2349
+ variance(array: MathArray | Matrix, dimension?: number, normalization?: 'unbiased' | 'uncorrected' | 'biased'): number[];
2339
2350
  /**
2340
2351
  * @param array A single matrix
2341
2352
  * @param normalization normalization Determines how to normalize the
@@ -2343,7 +2354,7 @@ declare namespace math {
2343
2354
  * Default value: ‘unbiased’.
2344
2355
  * @returns The variance
2345
2356
  */
2346
- variance(array: MathArray | Matrix, normalization?: 'unbiased' | 'uncorrected' | 'biased'): number;
2357
+ variance(array: MathArray | Matrix, normalization: 'unbiased' | 'uncorrected' | 'biased'): number;
2347
2358
 
2348
2359
  /*************************************************************************
2349
2360
  * String functions
@@ -2688,7 +2699,86 @@ declare namespace math {
2688
2699
  to(x: Unit | MathArray | Matrix, unit: Unit | string): Unit | MathArray | Matrix;
2689
2700
 
2690
2701
  /*************************************************************************
2691
- * Utils functions
2702
+ * Utils
2703
+ ************************************************************************/
2704
+ isNumber(x: unknown): x is number;
2705
+
2706
+ isBigNumber(x: unknown): x is BigNumber;
2707
+
2708
+ isComplex(x: unknown): x is Complex;
2709
+
2710
+ isFraction(x: unknown): x is Fraction;
2711
+
2712
+ isUnit(x: unknown): x is Unit;
2713
+
2714
+ isString(x: unknown): x is string;
2715
+
2716
+ isArray: ArrayConstructor['isArray'];
2717
+
2718
+ isMatrix(x: unknown): x is Matrix;
2719
+
2720
+ isCollection(x: unknown): x is (Matrix | any[]);
2721
+
2722
+ isDenseMatrix(x: unknown): x is Matrix;
2723
+
2724
+ isSparseMatrix(x: unknown): x is Matrix;
2725
+
2726
+ isRange(x: unknown): boolean;
2727
+
2728
+ isIndex(x: unknown): x is Index;
2729
+
2730
+ isBoolean(x: unknown): x is boolean;
2731
+
2732
+ isResultSet(x: unknown): boolean;
2733
+
2734
+ isHelp(x: unknown): x is Help;
2735
+
2736
+ isFunction(x: unknown): boolean;
2737
+
2738
+ isDate(x: unknown): x is Date;
2739
+
2740
+ isRegExp(x: unknown): x is RegExp;
2741
+
2742
+ isObject(x: unknown): boolean;
2743
+
2744
+ isNull(x: unknown): x is null;
2745
+
2746
+ isUndefined(x: unknown): x is undefined;
2747
+
2748
+ isAccessorNode(x: unknown): x is AccessorNode;
2749
+
2750
+ isArrayNode(x: unknown): x is ArrayNode;
2751
+
2752
+ isAssignmentNode(x: unknown): x is AssignmentNode;
2753
+
2754
+ isBlockNode(x: unknown): x is BlockNode;
2755
+
2756
+ isConditionalNode(x: unknown): x is ConditionalNode;
2757
+
2758
+ isConstantNode(x: unknown): x is ConstantNode;
2759
+
2760
+ isFunctionAssignmentNode(x: unknown): x is FunctionAssignmentNode;
2761
+
2762
+ isFunctionNode(x: unknown): x is FunctionNode;
2763
+
2764
+ isIndexNode(x: unknown): x is IndexNode;
2765
+
2766
+ isNode(x: unknown): x is MathNodeCommon;
2767
+
2768
+ isObjectNode(x: unknown): x is ObjectNode;
2769
+
2770
+ isOperatorNode(x: unknown): x is OperatorNode;
2771
+
2772
+ isParenthesisNode(x: unknown): x is ParenthesisNode;
2773
+
2774
+ isRangeNode(x: unknown): x is RangeNode;
2775
+
2776
+ isSymbolNode(x: unknown): x is SymbolNode;
2777
+
2778
+ isChain(x: unknown): x is MathJsChain;
2779
+
2780
+ /*************************************************************************
2781
+ * Functions -> Utils
2692
2782
  ************************************************************************/
2693
2783
 
2694
2784
  /**
@@ -3165,6 +3255,10 @@ declare namespace math {
3165
3255
  swapRows(i: number, j: number): Matrix;
3166
3256
  }
3167
3257
 
3258
+ interface MatrixCtor {
3259
+ new(): Matrix;
3260
+ }
3261
+
3168
3262
  interface BigNumber extends Decimal {} // tslint:disable-line no-empty-interface
3169
3263
 
3170
3264
  interface Fraction {
@@ -3522,13 +3616,6 @@ declare namespace math {
3522
3616
  randomSeed?: string | null;
3523
3617
  }
3524
3618
 
3525
- interface MathJsJson {
3526
- /**
3527
- * Returns reviver function that can be used as reviver in JSON.parse function.
3528
- */
3529
- reviver(): (key: any, value: any) => any;
3530
- }
3531
-
3532
3619
  interface MathJsChain {
3533
3620
  done(): any;
3534
3621
 
@@ -4782,14 +4869,13 @@ declare namespace math {
4782
4869
  * values: 'unbiased' (default) The sum of squared errors is divided by
4783
4870
  * (n - 1) 'uncorrected' The sum of squared errors is divided by n
4784
4871
  * 'biased' The sum of squared errors is divided by (n + 1)
4785
- * @param array A single matrix or multiple scalar values
4786
4872
  * @param dim A dimension to compute standard deviation.
4787
4873
  * @param normalization Determines how to normalize the variance. Choose
4788
4874
  * ‘unbiased’ (default), ‘uncorrected’, or ‘biased’. Default value:
4789
4875
  * ‘unbiased’.
4790
4876
  * @returns The standard deviation
4791
4877
  */
4792
- std(dim: number, normalization?: 'unbiased' | 'uncorrected' | 'biased'): MathJsChain;
4878
+ std(dim?: number, normalization?: 'unbiased' | 'uncorrected' | 'biased'): MathJsChain;
4793
4879
  /**
4794
4880
  * Compute the standard deviation of a matrix or a list with values. The
4795
4881
  * standard deviations is defined as the square root of the variance:
@@ -4800,13 +4886,12 @@ declare namespace math {
4800
4886
  * values: 'unbiased' (default) The sum of squared errors is divided by
4801
4887
  * (n - 1) 'uncorrected' The sum of squared errors is divided by n
4802
4888
  * 'biased' The sum of squared errors is divided by (n + 1)
4803
- * @param array A single matrix or multiple scalar values
4804
4889
  * @param normalization Determines how to normalize the variance. Choose
4805
4890
  * ‘unbiased’ (default), ‘uncorrected’, or ‘biased’. Default value:
4806
4891
  * ‘unbiased’.
4807
4892
  * @returns The standard deviation
4808
4893
  */
4809
- std(normalization?: 'unbiased' | 'uncorrected' | 'biased'): MathJsChain;
4894
+ std(normalization: 'unbiased' | 'uncorrected' | 'biased'): MathJsChain;
4810
4895
 
4811
4896
  /**
4812
4897
  * Compute the sum of a matrix or a list with values. In case of a
@@ -4831,7 +4916,7 @@ declare namespace math {
4831
4916
  * Default value: ‘unbiased’.
4832
4917
  * @returns The variance
4833
4918
  */
4834
- variance(dim: number, normalization?: 'unbiased' | 'uncorrected' | 'biased'): MathJsChain;
4919
+ variance(dim?: number, normalization?: 'unbiased' | 'uncorrected' | 'biased'): MathJsChain;
4835
4920
  /**
4836
4921
  * Compute the variance of a matrix or a list with values. In case of a
4837
4922
  * (multi dimensional) array or matrix, the variance over all elements
@@ -4848,7 +4933,7 @@ declare namespace math {
4848
4933
  * Default value: ‘unbiased’.
4849
4934
  * @returns The variance
4850
4935
  */
4851
- variance(normalization?: 'unbiased' | 'uncorrected' | 'biased'): MathJsChain;
4936
+ variance(normalization: 'unbiased' | 'uncorrected' | 'biased'): MathJsChain;
4852
4937
 
4853
4938
  /*************************************************************************
4854
4939
  * String functions
@@ -5126,4 +5211,5 @@ declare namespace math {
5126
5211
  interface ImportObject {
5127
5212
  [key: string]: any;
5128
5213
  }
5214
+
5129
5215
  }