@danielsimonjr/mathts-core 0.10.0 → 0.11.0

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.
@@ -1,5 +1,5 @@
1
- import { F as FactoryFunction, b as UnitConstructor, c as UnitDependencies } from './index-zKEDY9aj.js';
2
- export { B as BaseUnitDef, d as BigNumber, e as BigNumberConstructor, f as BigNumberValue, C as Complex, g as ComplexConstructor, h as ComplexValue, j as ConverterFn, U as CoreUnit, k as CreateUnitDefObject, l as CreateUnitOptions, D as DenseMatrix, m as Fraction, n as FractionConstructor, o as FractionValue, I as Index, p as IndexDimension, M as Matrix, N as Numeric, P as ParseOptions, q as PrefixDef, r as PrefixTable, R as Range, S as ScalarBinaryOp, s as ScalarUnaryOp, t as SparseMatrix, u as SubtractScalar, T as TypeConverters, v as Unit, w as UnitComponent, x as UnitConfig, y as UnitDef, z as UnitFormatOptions, a as UnitInstance, A as UnitJSON, E as UnitSystem, G as UnitSystemEntry, H as isArray, J as isBigInt, K as isBigNumber, L as isBoolean, O as isCollection, Q as isComplex, V as isDate, W as isDenseMatrix, X as isFraction, Y as isFunction, Z as isIndex, _ as isMap, $ as isMatrix, a0 as isNull, a1 as isNumber, a2 as isObject, a3 as isRange, a4 as isRegExp, a5 as isSparseMatrix, a6 as isString, a7 as isUndefined, i as isUnit, a8 as typeOf } from './index-zKEDY9aj.js';
1
+ import { F as FactoryFunction, b as UnitConstructor, c as UnitDependencies, I as Index, M as Matrix$1 } from './index-B4LIOfHN.js';
2
+ export { B as BaseUnitDef, d as BigNumber, e as BigNumberConstructor, C as Complex, f as ComplexConstructor, g as ComplexValue, h as ConverterFn, U as CoreUnit, j as CreateFunction, k as CreateUnitDefObject, l as CreateUnitOptions, D as DenseMatrix, m as DependencyName, n as FactoryMeta, o as Fraction, p as FractionConstructor, q as FractionValue, r as IndexDimension, L as LegacyFactory, N as Numeric, P as ParseOptions, s as PrefixDef, t as PrefixTable, R as Range, S as ScalarBinaryOp, u as ScalarUnaryOp, v as SparseMatrix, w as SubtractScalar, T as TypeConverters, x as Unit, y as UnitComponent, z as UnitConfig, A as UnitDef, E as UnitFormatOptions, a as UnitInstance, G as UnitJSON, H as UnitSystem, J as UnitSystemEntry, K as assertDependencies, O as create, Q as factory, V as isArray, W as isBigInt, X as isBigNumber, Y as isBoolean, Z as isCollection, _ as isComplex, $ as isDate, a0 as isDenseMatrix, a1 as isFactory, a2 as isFraction, a3 as isFunction, a4 as isIndex, a5 as isMap, a6 as isMatrix, a7 as isNull, a8 as isNumber, a9 as isObject, aa as isOptionalDependency, ab as isRange, ac as isRegExp, ad as isSparseMatrix, ae as isString, af as isUndefined, i as isUnit, ag as sortFactories, ah as stripOptionalNotation, ai as typeOf } from './index-B4LIOfHN.js';
3
3
 
4
4
  declare const createUnitClass: FactoryFunction<UnitConstructor>;
5
5
 
@@ -185,7 +185,7 @@ declare const expm1: (x: number) => number;
185
185
  * @param options Optional formatting options or custom formatter function or precision
186
186
  * @return The formatted value
187
187
  */
188
- declare function format(value: number, options?: FormatOptions | ((value: number) => string) | number): string;
188
+ declare function format$2(value: number, options?: FormatOptions | ((value: number) => string) | number): string;
189
189
  /**
190
190
  * Normalize format options into an object:
191
191
  * {
@@ -209,21 +209,21 @@ declare function splitNumber(value: number | string): SplitValue;
209
209
  * @param precision Optional number of significant figures to return
210
210
  * @returns The formatted string
211
211
  */
212
- declare function toEngineering(value: number | string, precision?: number): string;
212
+ declare function toEngineering$1(value: number | string, precision?: number): string;
213
213
  /**
214
214
  * Format a number with fixed notation.
215
215
  * @param value The number or string to format
216
216
  * @param precision Optional number of decimals after the decimal point
217
217
  * @returns The formatted string
218
218
  */
219
- declare function toFixed(value: number | string, precision?: number): string;
219
+ declare function toFixed$1(value: number | string, precision?: number): string;
220
220
  /**
221
221
  * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3'
222
222
  * @param value The number or string to format
223
223
  * @param precision Number of digits in formatted output
224
224
  * @returns The formatted string
225
225
  */
226
- declare function toExponential(value: number | string, precision?: number): string;
226
+ declare function toExponential$1(value: number | string, precision?: number): string;
227
227
  /**
228
228
  * Format a number with a certain precision
229
229
  * @param value The number or string to format
@@ -372,7 +372,7 @@ declare function memoize(fn: (...args: unknown[]) => unknown, { hasher, limit }?
372
372
  * @param {*} x
373
373
  * @return {*} clone
374
374
  */
375
- declare function clone<T>(x: T): T;
375
+ declare function clone$1<T>(x: T): T;
376
376
  /**
377
377
  * Apply map to all properties of an object
378
378
  * @param {Object} object
@@ -451,7 +451,7 @@ declare function isLegacyFactory(object: unknown): boolean;
451
451
  * @param {string | string[]} path
452
452
  * @returns {Object}
453
453
  */
454
- declare function get(object: Record<string, unknown>, path: string | string[]): unknown;
454
+ declare function get$1(object: Record<string, unknown>, path: string | string[]): unknown;
455
455
  /**
456
456
  * Set a nested property in an object
457
457
  * Mutates the object itself
@@ -479,4 +479,710 @@ declare function pick(object: Record<string, unknown>, properties: string[], tra
479
479
  */
480
480
  declare function pickShallow(object: Record<string, unknown>, properties: string[]): Record<string, unknown>;
481
481
 
482
- export { type FormatOptions, type MemoizedFunction, type NormalizedFormatOptions, type NumberTypeConfig, type SplitValue, UnitConstructor, UnitDependencies, acosh, asinh, atanh, canDefineProperty, cbrt, clone, copysign, cosh, createUnitClass, deepExtend, deepFlatten, deepStrictEqual, digits, endsWith, expm1, extend, format, get, hasOwnProperty, isInteger, isLegacyFactory, isPowZeroAtInfinity, lazy, log10, log1p, log2, mapObject, memoize, nearlyEqual, normalizeFormatOptions, pick, pickShallow, roundDigits, safeNumberType, set, sign, sinh, splitNumber, tanh, toEngineering, toExponential, toFixed, toPrecision, traverse, unitDependencies, warnOnce };
482
+ /**
483
+ * Custom error type for Mathjs errors
484
+ * @extends Error
485
+ */
486
+ declare class MathjsError extends Error {
487
+ isMathjsError: true;
488
+ /**
489
+ * Create a MathjsError
490
+ * @param message Error message
491
+ */
492
+ constructor(message: string);
493
+ }
494
+
495
+ /**
496
+ * Create a range error with the message:
497
+ * 'Dimension mismatch (<actual size> != <expected size>)'
498
+ * Or with a custom message when called with a single string argument.
499
+ *
500
+ * The single canonical `DimensionError` for the whole monorepo (Bucket B, commit 1),
501
+ * exposed via the `@danielsimonjr/mathts-core/internal` subpath. `expression/src/error/
502
+ * DimensionError.ts` and `functions/src/error/DimensionError.ts` are now thin
503
+ * re-export shims of this class — a `DimensionError` thrown in one package is
504
+ * `instanceof DimensionError` in any other, since there is only ever one class
505
+ * identity. `core/src/array.ts` (and the ~20 other call sites across matrix algos,
506
+ * subset, resize, concat, reshape, ...) all throw this same class.
507
+ */
508
+ declare class DimensionError extends RangeError {
509
+ actual?: number | number[];
510
+ expected?: number | number[];
511
+ relation?: string;
512
+ isDimensionError: true;
513
+ /**
514
+ * @param actual - The actual size or custom error message
515
+ * @param expected - The expected size (optional if actual is a custom message)
516
+ * @param relation - Optional relation between actual and expected size: '!=', '<', etc.
517
+ */
518
+ constructor(actual: number | number[] | string, expected?: number | number[], relation?: string);
519
+ }
520
+
521
+ /**
522
+ * Custom error type for index out of range errors.
523
+ *
524
+ * The single canonical `IndexError` for the whole monorepo (Bucket B, commit 1),
525
+ * exposed via the `@danielsimonjr/mathts-core/internal` subpath. `expression/src/error/
526
+ * IndexError.ts` and `functions/src/error/IndexError.ts` are now thin re-export shims
527
+ * of this class — an `IndexError` thrown in one package is `instanceof IndexError`
528
+ * in any other, since there is only ever one class identity. `core/src/array.ts` /
529
+ * `core/src/collection.ts` (and the many other call sites across concat, subset,
530
+ * cumsum, mapSlices, ...) all throw this same class.
531
+ *
532
+ * @extends RangeError
533
+ */
534
+ declare class IndexError extends RangeError {
535
+ index: number;
536
+ min: number | undefined;
537
+ max: number | undefined;
538
+ isIndexError: true;
539
+ /**
540
+ * Create an IndexError
541
+ *
542
+ * Can be called in two ways:
543
+ * - IndexError(index, max) - assumes min=0
544
+ * - IndexError(index, min, max)
545
+ *
546
+ * @param index The actual index
547
+ * @param min Minimum index (included), or max if only 2 args provided
548
+ * @param max Maximum index (excluded)
549
+ */
550
+ constructor(index: number, min?: number, max?: number);
551
+ }
552
+ declare function createIndexError(index: number, min?: number, max?: number): IndexError;
553
+
554
+ /**
555
+ * Formatting options accepted by the generic `format` helper. Extends the
556
+ * numeric {@link FormatOptions} with the string-level `truncate` and the
557
+ * fraction rendering mode, or is a precision number, or a custom formatter.
558
+ */
559
+ type GeneralFormatOptions = number | ((value: unknown) => string) | (FormatOptions & {
560
+ truncate?: number;
561
+ fraction?: 'ratio' | 'decimal';
562
+ });
563
+ /**
564
+ * Format a value of any type into a string.
565
+ *
566
+ * Usage:
567
+ * math.format(value)
568
+ * math.format(value, precision)
569
+ * math.format(value, options)
570
+ *
571
+ * When value is a function:
572
+ *
573
+ * - When the function has a property `syntax`, it returns this
574
+ * syntax description.
575
+ * - In other cases, a string `'function'` is returned.
576
+ *
577
+ * When `value` is an Object:
578
+ *
579
+ * - When the object contains a property `format` being a function, this
580
+ * function is invoked as `value.format(options)` and the result is returned.
581
+ * - When the object has its own `toString` method, this method is invoked
582
+ * and the result is returned.
583
+ * - In other cases the function will loop over all object properties and
584
+ * return JSON object notation like '{"a": 2, "b": 3}'.
585
+ *
586
+ * Example usage:
587
+ * math.format(2/7) // '0.2857142857142857'
588
+ * math.format(math.pi, 3) // '3.14'
589
+ * math.format(new Complex(2, 3)) // '2 + 3i'
590
+ * math.format('hello') // '"hello"'
591
+ *
592
+ * @param {*} value Value to be stringified
593
+ * @param {Object | number | Function} [options]
594
+ * Formatting options. See src/utils/number.js:format for a
595
+ * description of the available options controlling number output.
596
+ * This generic "format" also supports the option property `truncate: NN`
597
+ * giving the maximum number NN of characters to return (if there would
598
+ * have been more, they are deleted and replaced by an ellipsis).
599
+ * @return {string} str
600
+ */
601
+ declare function format$1(value: unknown, options?: unknown): string;
602
+ /**
603
+ * Stringify a value into a string enclosed in double quotes.
604
+ * Unescaped double quotes and backslashes inside the value are escaped.
605
+ * @param {*} value
606
+ * @return {string}
607
+ */
608
+ declare function stringify(value: unknown): string;
609
+ /**
610
+ * Escape special HTML characters
611
+ * @param {*} value
612
+ * @return {string}
613
+ */
614
+ declare function escape(value: unknown): string;
615
+ /**
616
+ * Compare two strings
617
+ * @param {string} x
618
+ * @param {string} y
619
+ * @returns {number}
620
+ */
621
+ declare function compareText(x: unknown, y: unknown): number;
622
+
623
+ /**
624
+ * Structural contract for the BigNumber values handled by this formatter.
625
+ * Captures exactly the methods/properties used here. The configured BigNumber
626
+ * implementation (e.g. decimal.js) provides these; the project's `BigNumber`
627
+ * type alias points at a minimal local Decimal that does not declare them all,
628
+ * so we model the runtime contract explicitly.
629
+ */
630
+ interface BigNumberValue {
631
+ e: number;
632
+ constructor: new (value: number | string) => BigNumberValue;
633
+ isFinite(): boolean;
634
+ isNaN(): boolean;
635
+ isZero(): boolean;
636
+ isInteger(): boolean;
637
+ gt(other: number | BigNumberValue): boolean;
638
+ greaterThan(other: number | BigNumberValue): boolean;
639
+ lessThan(other: number | BigNumberValue): boolean;
640
+ add(other: number | BigNumberValue): BigNumberValue;
641
+ sub(other: number | BigNumberValue): BigNumberValue;
642
+ mul(other: number | BigNumberValue): BigNumberValue;
643
+ pow(exp: number | BigNumberValue): BigNumberValue;
644
+ toNumber(): number;
645
+ toFixed(places?: number): string;
646
+ toExponential(places?: number): string;
647
+ toPrecision(sd?: number): string;
648
+ toSignificantDigits(sd?: number): BigNumberValue;
649
+ toBinary(): string;
650
+ toOctal(): string;
651
+ toHexadecimal(): string;
652
+ }
653
+ /**
654
+ * Convert a BigNumber to a formatted string representation.
655
+ *
656
+ * Syntax:
657
+ *
658
+ * format(value)
659
+ * format(value, options)
660
+ * format(value, precision)
661
+ * format(value, fn)
662
+ *
663
+ * Where:
664
+ *
665
+ * {number} value The value to be formatted
666
+ * {Object} options An object with formatting options. Available options:
667
+ * {string} notation
668
+ * Number notation. Choose from:
669
+ * 'fixed' Always use regular number notation.
670
+ * For example '123.40' and '14000000'
671
+ * 'exponential' Always use exponential notation.
672
+ * For example '1.234e+2' and '1.4e+7'
673
+ * 'auto' (default) Regular number notation for numbers
674
+ * having an absolute value between
675
+ * `lower` and `upper` bounds, and uses
676
+ * exponential notation elsewhere.
677
+ * Lower bound is included, upper bound
678
+ * is excluded.
679
+ * For example '123.4' and '1.4e7'.
680
+ * 'bin', 'oct, or
681
+ * 'hex' Format the number using binary, octal,
682
+ * or hexadecimal notation.
683
+ * For example '0b1101' and '0x10fe'.
684
+ * {number} wordSize The word size in bits to use for formatting
685
+ * in binary, octal, or hexadecimal notation.
686
+ * To be used only with 'bin', 'oct', or 'hex'
687
+ * values for 'notation' option. When this option
688
+ * is defined the value is formatted as a signed
689
+ * twos complement integer of the given word size
690
+ * and the size suffix is appended to the output.
691
+ * For example
692
+ * format(-1, {notation: 'hex', wordSize: 8}) === '0xffi8'.
693
+ * Default value is undefined.
694
+ * {number} precision A number between 0 and 16 to round
695
+ * the digits of the number.
696
+ * In case of notations 'exponential',
697
+ * 'engineering', and 'auto',
698
+ * `precision` defines the total
699
+ * number of significant digits returned.
700
+ * In case of notation 'fixed',
701
+ * `precision` defines the number of
702
+ * significant digits after the decimal
703
+ * point.
704
+ * `precision` is undefined by default.
705
+ * {number} lowerExp Exponent determining the lower boundary
706
+ * for formatting a value with an exponent
707
+ * when `notation='auto`.
708
+ * Default value is `-3`.
709
+ * {number} upperExp Exponent determining the upper boundary
710
+ * for formatting a value with an exponent
711
+ * when `notation='auto`.
712
+ * Default value is `5`.
713
+ * {Function} fn A custom formatting function. Can be used to override the
714
+ * built-in notations. Function `fn` is called with `value` as
715
+ * parameter and must return a string. Is useful for example to
716
+ * format all values inside a matrix in a particular way.
717
+ *
718
+ * Examples:
719
+ *
720
+ * format(6.4) // '6.4'
721
+ * format(1240000) // '1.24e6'
722
+ * format(1/3) // '0.3333333333333333'
723
+ * format(1/3, 3) // '0.333'
724
+ * format(21385, 2) // '21000'
725
+ * format(12e8, {notation: 'fixed'}) // returns '1200000000'
726
+ * format(2.3, {notation: 'fixed', precision: 4}) // returns '2.3000'
727
+ * format(52.8, {notation: 'exponential'}) // returns '5.28e+1'
728
+ * format(12400, {notation: 'engineering'}) // returns '12.400e+3'
729
+ *
730
+ * @param {BigNumber} value
731
+ * @param {Object | Function | number | BigNumber} [options]
732
+ * @return {string} str The formatted value
733
+ */
734
+ declare function format(value: unknown, options?: unknown): string;
735
+ /**
736
+ * Format a BigNumber in engineering notation. Like '1.23e+6', '2.3e+0', '3.500e-3'
737
+ * @param {BigNumber} value
738
+ * @param {number} [precision] Optional number of significant figures to return.
739
+ */
740
+ declare function toEngineering(value: BigNumberValue, precision?: number): string;
741
+ /**
742
+ * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3'
743
+ * @param {BigNumber} value
744
+ * @param {number} [precision] Number of digits in formatted output.
745
+ * If not provided, the maximum available digits
746
+ * is used.
747
+ * @returns {string} str
748
+ */
749
+ declare function toExponential(value: BigNumberValue, precision?: number): string;
750
+ /**
751
+ * Format a number with fixed notation.
752
+ * @param {BigNumber} value
753
+ * @param {number} [precision=undefined] Optional number of decimals after the
754
+ * decimal point. Undefined by default.
755
+ */
756
+ declare function toFixed(value: BigNumberValue, precision?: number): string;
757
+
758
+ type NestedArray<T> = T | NestedArray<T>[];
759
+ interface IdentifiedValue<T> {
760
+ value: T;
761
+ identifier: number;
762
+ }
763
+ /**
764
+ * Calculate the size of a multi dimensional array.
765
+ * This function checks the size of the first entry, it does not validate
766
+ * whether all dimensions match. (use function `validate` for that)
767
+ * @param {Array} x
768
+ * @return {number[]} size
769
+ */
770
+ declare function arraySize<T>(x: NestedArray<T>): number[];
771
+ /**
772
+ * Validate whether each element in a multi dimensional array has
773
+ * a size corresponding to the provided size array.
774
+ * @param {Array} array Array to be validated
775
+ * @param {number[]} size Array with the size of each dimension
776
+ * @throws DimensionError
777
+ */
778
+ declare function validate<T>(array: NestedArray<T>, size: number[]): void;
779
+ /**
780
+ * Validate whether the source of the index matches the size of the Array
781
+ * @param {Array | Matrix} value Array to be validated
782
+ * @param {Index} index Index with the source information to validate
783
+ * @throws DimensionError
784
+ */
785
+ declare function validateIndexSourceSize(value: unknown[] | Matrix$1, index: Index): void;
786
+ /**
787
+ * Test whether index is an integer number with index >= 0 and index < length
788
+ * when length is provided
789
+ * @param {number} index Zero-based index
790
+ * @param {number} [length] Length of the array
791
+ */
792
+ declare function validateIndex(index: number | undefined, length?: number): void;
793
+ /**
794
+ * Test if an index has empty values
795
+ * @param {Index} index Zero-based index
796
+ */
797
+ declare function isEmptyIndex(index: Index): boolean;
798
+ /**
799
+ * Resize a multi dimensional array. The resized array is returned.
800
+ * @param {Array | number} array Array to be resized
801
+ * @param {number[]} size Array with the size of each dimension
802
+ * @param {*} [defaultValue=0] Value to be filled in new entries,
803
+ * zero by default. Specify for example `null`,
804
+ * to clearly see entries that are not explicitly
805
+ * set.
806
+ * @return {Array} array The resized array
807
+ */
808
+ declare function resize<T = unknown>(array: T | T[] | NestedArray<T>, size: number[], defaultValue?: T): NestedArray<T>;
809
+ /**
810
+ * Re-shape a multi dimensional array to fit the specified dimensions
811
+ * @param {Array} array Array to be reshaped
812
+ * @param {number[]} sizes List of sizes for each dimension
813
+ * @returns {Array} Array whose data has been formatted to fit the
814
+ * specified dimensions
815
+ *
816
+ * @throws {DimensionError} If the product of the new dimension sizes does
817
+ * not equal that of the old ones
818
+ */
819
+ declare function reshape<T = unknown>(array: NestedArray<T>, sizes: number[]): NestedArray<T>;
820
+ /**
821
+ * Replaces the wildcard -1 in the sizes array.
822
+ * @param {number[]} sizes List of sizes for each dimension. At most one wildcard.
823
+ * @param {number} currentLength Number of elements in the array.
824
+ * @throws {Error} If more than one wildcard or unable to replace it.
825
+ * @returns {number[]} The sizes array with wildcard replaced.
826
+ */
827
+ declare function processSizesWildcard(sizes: number[], currentLength: number): number[];
828
+ /**
829
+ * Squeeze a multi dimensional array
830
+ * @param {Array} array
831
+ * @param {Array} [size]
832
+ * @returns {Array} returns the array itself
833
+ */
834
+ declare function squeeze<T>(array: NestedArray<T>, size?: number[]): T | NestedArray<T>;
835
+ /**
836
+ * Unsqueeze a multi dimensional array: add dimensions when missing
837
+ *
838
+ * Parameter `size` will be mutated to match the new, unsqueezed matrix size.
839
+ *
840
+ * @param {Array} array
841
+ * @param {number} dims Desired number of dimensions of the array
842
+ * @param {number} [outer] Number of outer dimensions to be added
843
+ * @param {Array} [size] Current size of array.
844
+ * @returns {Array} returns the array itself
845
+ * @private
846
+ */
847
+ declare function unsqueeze<T>(array: NestedArray<T>, dims: number, outer?: number, size?: number[]): NestedArray<T>;
848
+ /**
849
+ * Flatten a multi dimensional array, put all elements in a one dimensional
850
+ * array
851
+ * @param {Array} array A multi dimensional array
852
+ * @param {boolean} isRectangular Optional. If the array is rectangular (not jagged)
853
+ * @return {Array} The flattened array (1 dimensional)
854
+ */
855
+ declare function flatten<T>(array: NestedArray<T>, isRectangular?: boolean): T[];
856
+ /**
857
+ * A safe map
858
+ * @param {Array} array
859
+ * @param {function} callback
860
+ */
861
+ declare function map<T, U>(array: T[], callback: (value: T, index: number, array: T[]) => U): U[];
862
+ /**
863
+ * A safe forEach
864
+ * @param {Array} array
865
+ * @param {function} callback
866
+ */
867
+ declare function forEach<T>(array: T[], callback: (value: T, index: number, array: T[]) => void): void;
868
+ /**
869
+ * A safe filter
870
+ * @param {Array} array
871
+ * @param {function} callback
872
+ */
873
+ declare function filter<T>(array: T[], callback: (value: T, index: number, array: T[]) => boolean): T[];
874
+ /**
875
+ * Filter values in an array given a regular expression
876
+ * @param {Array} array
877
+ * @param {RegExp} regexp
878
+ * @return {Array} Returns the filtered array
879
+ * @private
880
+ */
881
+ declare function filterRegExp(array: string[], regexp: RegExp): string[];
882
+ /**
883
+ * A safe join
884
+ * @param {Array} array
885
+ * @param {string} separator
886
+ */
887
+ declare function join<T>(array: T[], separator: string): string;
888
+ /**
889
+ * Assign a numeric identifier to every element of a sorted array
890
+ * @param {Array} a An array
891
+ * @return {Array} An array of objects containing the original value and its identifier
892
+ */
893
+ declare function identify<T>(a: T[]): IdentifiedValue<T>[];
894
+ /**
895
+ * Remove the numeric identifier from the elements
896
+ * @param {array} a An array
897
+ * @return {array} An array of values without identifiers
898
+ */
899
+ declare function generalize<T>(a: IdentifiedValue<T>[]): T[];
900
+ /**
901
+ * Check the datatype of a given object
902
+ * This is a low level implementation that should only be used by
903
+ * parent Matrix classes such as SparseMatrix or DenseMatrix
904
+ * This method does not validate Array Matrix shape
905
+ * @param {Array} array
906
+ * @param {function} typeOf Callback function to use to determine the type of a value
907
+ * @return {string}
908
+ */
909
+ declare function getArrayDataType(array: unknown[], typeOf: (value: unknown) => string): string | undefined;
910
+ /**
911
+ * Return the last item from an array
912
+ * @param {Array} array
913
+ * @returns {*}
914
+ */
915
+ declare function last<T>(array: T[]): T;
916
+ /**
917
+ * Get all but the last element of array.
918
+ *
919
+ * KNOWN DIVERGENCE (Bucket B slice 2): only `expression/src/utils/array.ts` had
920
+ * this; `functions/src/utils/array.ts` never defined it, and it was dead code
921
+ * even in expression (unused outside its own definition). Re-exported from
922
+ * expression's shim only — see the module header.
923
+ * @param {Array} array
924
+ * @returns {Array}
925
+ */
926
+ declare function initial<T>(array: T[]): T[];
927
+ /**
928
+ * Concatenates many arrays in the specified direction
929
+ * @param {...Array} arrays All the arrays to concatenate
930
+ * @param {number} concatDim The dimension on which to concatenate (zero-based)
931
+ * @returns {Array}
932
+ */
933
+ declare function concat<T>(...args: [...NestedArray<T>[], number]): NestedArray<T>[];
934
+ /**
935
+ * Receives two or more sizes and gets the broadcasted size for both.
936
+ * @param {...number[]} sizes Sizes to broadcast together
937
+ * @returns {number[]} The broadcasted size
938
+ */
939
+ declare function broadcastSizes(...sizes: number[][]): number[];
940
+ /**
941
+ * Checks if it's possible to broadcast a size to another size
942
+ * @param {number[]} size The size of the array to check
943
+ * @param {number[]} toSize The size of the array to validate if it can be broadcasted to
944
+ */
945
+ declare function checkBroadcastingRules(size: number[], toSize: number[]): void;
946
+ /**
947
+ * Broadcasts a single array to a certain size
948
+ * @param {Array} array Array to be broadcasted
949
+ * @param {number[]} toSize Size to broadcast the array
950
+ * @returns {Array} The broadcasted array
951
+ */
952
+ declare function broadcastTo<T>(array: NestedArray<T>, toSize: number[]): NestedArray<T>;
953
+ /**
954
+ * Broadcasts arrays and returns the broadcasted arrays in an array
955
+ * @param {...Array | any} arrays
956
+ * @returns {Array[]} The broadcasted arrays
957
+ */
958
+ declare function broadcastArrays<T>(...arrays: NestedArray<T>[]): NestedArray<T>[];
959
+ /**
960
+ * Stretches a matrix up to a certain size in a certain dimension
961
+ * @param {Array} arrayToStretch
962
+ * @param {number[]} sizeToStretch
963
+ * @param {number} dimToStretch
964
+ * @returns {Array} The stretched array
965
+ */
966
+ declare function stretch<T>(arrayToStretch: NestedArray<T>, sizeToStretch: number, dimToStretch: number): NestedArray<T>;
967
+ /**
968
+ * Retrieves a single element from an array given an index.
969
+ *
970
+ * @param {Array} array - The array from which to retrieve the value.
971
+ * @param {Array<number>} index - An array of indices specifying the position of the desired element in each dimension.
972
+ * @returns {*} - The value at the specified position in the array.
973
+ *
974
+ * @example
975
+ * const arr = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];
976
+ * const index = [1, 0, 1];
977
+ * console.log(get(arr, index)); // 6
978
+ */
979
+ declare function get<T>(array: NestedArray<T>, index: number[]): T;
980
+ /**
981
+ * Recursively maps over each element of nested array using a provided callback function.
982
+ *
983
+ * @param {Array} array - The array to be mapped.
984
+ * @param {Function} callback - The function to execute on each element, taking three arguments:
985
+ * - `value` (any): The current element being processed in the array.
986
+ * - `index` (Array<number>): The index of the current element being processed in the array.
987
+ * - `array` (Array): The array `deepMap` was called upon.
988
+ * @param {boolean} [skipIndex=false] - If true, the callback function is called with only the value.
989
+ * @returns {Array} A new array with each element being the result of the callback function.
990
+ */
991
+ declare function deepMap$1<T, U>(array: NestedArray<T>, callback: ((value: T, index: number[], array: NestedArray<T>) => U) | ((value: T) => U), skipIndex?: boolean): NestedArray<U>;
992
+ /**
993
+ * Recursively iterates over each element in a multi-dimensional array and applies a callback function.
994
+ *
995
+ * @param {Array} array - The multi-dimensional array to iterate over.
996
+ * @param {Function} callback - The function to execute for each element. It receives three arguments:
997
+ * - {any} value: The current element being processed in the array.
998
+ * - {Array<number>} index: The index of the current element in each dimension.
999
+ * - {Array} array: The original array being processed.
1000
+ * @param {boolean} [skipIndex=false] - If true, the callback function is called with only the value.
1001
+ */
1002
+ declare function deepForEach$1<T>(array: NestedArray<T>, callback: ((value: T, index: number[], array: NestedArray<T>) => void) | ((value: T) => void), skipIndex?: boolean): void;
1003
+ /**
1004
+ * Deep clones a multidimensional array
1005
+ * @param {Array} array
1006
+ * @returns {Array} cloned array
1007
+ */
1008
+ declare function clone<T>(array: T[]): T[];
1009
+
1010
+ interface Matrix<T = unknown> {
1011
+ forEach(callback: (value: T) => void, skipZeros: boolean, recurse: boolean): void;
1012
+ map<U>(callback: (value: T) => U, skipZeros: boolean, recurse: boolean): Matrix<U>;
1013
+ size(): number[];
1014
+ valueOf(): T[];
1015
+ create(data: T[], datatype?: string): Matrix<T>;
1016
+ datatype(): string | undefined;
1017
+ }
1018
+ interface SparseMatrix<T = unknown> {
1019
+ _values: T[];
1020
+ _index: number[];
1021
+ _ptr: number[];
1022
+ }
1023
+ /**
1024
+ * Test whether an array contains collections
1025
+ * @param array - Array to test
1026
+ * @returns Returns true when the array contains one or multiple
1027
+ * collections (Arrays or Matrices). Returns false otherwise.
1028
+ */
1029
+ declare function containsCollections(array: unknown[]): boolean;
1030
+ /**
1031
+ * Recursively loop over all elements in a given multi dimensional array
1032
+ * and invoke the callback on each of the elements.
1033
+ * @param array - Array or Matrix to iterate over
1034
+ * @param callback - The callback method is invoked with one parameter: the current element in the array
1035
+ */
1036
+ declare function deepForEach<T>(array: T[] | Matrix<T>, callback: (value: T) => void): void;
1037
+ /**
1038
+ * Execute the callback function element wise for each element in array and any
1039
+ * nested array
1040
+ * Returns an array with the results
1041
+ * @param array - Array or Matrix to map over
1042
+ * @param callback - The callback is called with two parameters:
1043
+ * value1 and value2, which contain the current
1044
+ * element of both arrays.
1045
+ * @param skipZeros - Invoke callback function for non-zero values only.
1046
+ *
1047
+ * @return Mapped result
1048
+ */
1049
+ declare function deepMap<T, U>(array: T[] | Matrix<T>, callback: (value: T) => U, skipZeros?: boolean): U[] | Matrix<U>;
1050
+ /**
1051
+ * Reduce a given matrix or array to a new matrix or
1052
+ * array with one less dimension, applying the given
1053
+ * callback in the selected dimension.
1054
+ * @param mat - Array or Matrix to reduce
1055
+ * @param dim - Dimension to reduce
1056
+ * @param callback - Callback function
1057
+ * @return Reduced result
1058
+ */
1059
+ declare function reduce<T, U>(mat: T[] | Matrix<T>, dim: number, callback: (acc: U | T, val: T) => U): U[] | Matrix<U>;
1060
+ /**
1061
+ * Scatter function for sparse matrix operations
1062
+ * @param a - Sparse matrix
1063
+ * @param j - Column index
1064
+ * @param w - Work array for marking visited rows
1065
+ * @param x - Work array for storing values
1066
+ * @param u - Work array for marking updated rows
1067
+ * @param mark - Current mark value
1068
+ * @param cindex - Column index array to update
1069
+ * @param f - Binary function to apply
1070
+ * @param inverse - Whether to inverse the function arguments
1071
+ * @param update - Whether to update existing values
1072
+ * @param value - Value to use in binary function
1073
+ */
1074
+ declare function scatter<T>(a: SparseMatrix<T>, j: number, w: number[], x: T[] | null, u: number[], mark: number, cindex: number[], f?: (a: T, b: T) => T, inverse?: boolean, update?: boolean, value?: T): void;
1075
+
1076
+ /**
1077
+ * A map facade on a bare object.
1078
+ *
1079
+ * The small number of methods needed to implement a scope,
1080
+ * forwarding on to the SafeProperty functions. Over time, the codebase
1081
+ * will stop using this method, as all objects will be Maps, rather than
1082
+ * more security prone objects.
1083
+ */
1084
+ /**
1085
+ * The iterator type `Map` itself declares, derived from the installed TS lib
1086
+ * rather than hard-coded: older libs say `IterableIterator<[K, V]>`, TS >= 5.6
1087
+ * says `MapIterator<[K, V]>` (which additionally requires `[Symbol.dispose]`).
1088
+ * Deriving it keeps `implements Map<K, V>` honest on every TS version.
1089
+ */
1090
+ type MapEntryIterator<K, V> = ReturnType<Map<K, V>[typeof Symbol.iterator]>;
1091
+ declare class ObjectWrappingMap<K = string, V = unknown> implements Map<K, V> {
1092
+ wrappedObject: Record<string, V>;
1093
+ readonly [Symbol.toStringTag]: string;
1094
+ constructor(object: Record<string, V>);
1095
+ /**
1096
+ * Declared as a real method rather than assigned in the constructor through a
1097
+ * cast. The old form satisfied the runtime but never appeared in the emitted
1098
+ * type, so `implements Map<K, V>` was a lie that only surfaced downstream:
1099
+ * consumers compiling with `skipLibCheck: false` got TS2420 ("incorrectly
1100
+ * implements interface 'Map'... '[Symbol.iterator]' is missing").
1101
+ */
1102
+ [Symbol.iterator](): MapEntryIterator<K, V>;
1103
+ keys(): IterableIterator<K>;
1104
+ get(key: K): V | undefined;
1105
+ set(key: K, value: V): this;
1106
+ has(key: K): boolean;
1107
+ entries(): IterableIterator<[K, V]>;
1108
+ values(): IterableIterator<V>;
1109
+ forEach(callback: (value: V, key: K, map: Map<K, V>) => void): void;
1110
+ delete(key: K): boolean;
1111
+ clear(): void;
1112
+ get size(): number;
1113
+ }
1114
+ /**
1115
+ * Create a map with two partitions: a and b.
1116
+ * The set with bKeys determines which keys/values are read/written to map b,
1117
+ * all other values are read/written to map a
1118
+ *
1119
+ * For example:
1120
+ *
1121
+ * const a = new Map()
1122
+ * const b = new Map()
1123
+ * const p = new PartitionedMap(a, b, new Set(['x', 'y']))
1124
+ *
1125
+ * In this case, values `x` and `y` are read/written to map `b`,
1126
+ * all other values are read/written to map `a`.
1127
+ */
1128
+ declare class PartitionedMap<K = unknown, V = unknown> implements Map<K, V> {
1129
+ a: Map<K, V>;
1130
+ b: Map<K, V>;
1131
+ bKeys: Set<K>;
1132
+ readonly [Symbol.toStringTag]: string;
1133
+ /**
1134
+ * @param a - Primary map
1135
+ * @param b - Secondary map
1136
+ * @param bKeys - Set of keys that should be read/written to map b
1137
+ */
1138
+ constructor(a: Map<K, V>, b: Map<K, V>, bKeys: Set<K>);
1139
+ /** See the note on `ObjectWrappingMap[Symbol.iterator]` — same fix. */
1140
+ [Symbol.iterator](): MapEntryIterator<K, V>;
1141
+ get(key: K): V | undefined;
1142
+ set(key: K, value: V): this;
1143
+ has(key: K): boolean;
1144
+ keys(): IterableIterator<K>;
1145
+ values(): IterableIterator<V>;
1146
+ entries(): IterableIterator<[K, V]>;
1147
+ forEach(callback: (value: V, key: K, map: Map<K, V>) => void): void;
1148
+ delete(key: K): boolean;
1149
+ clear(): void;
1150
+ get size(): number;
1151
+ }
1152
+ /**
1153
+ * Creates an empty map, or whatever your platform's polyfill is.
1154
+ *
1155
+ * @returns an empty Map or Map like object.
1156
+ */
1157
+ declare function createEmptyMap<K = string, V = unknown>(): Map<K, V>;
1158
+ /**
1159
+ * Creates a Map from the given object.
1160
+ *
1161
+ * @param mapOrObject - Map or object to convert
1162
+ * @returns Map instance
1163
+ */
1164
+ declare function createMap<K = string, V = unknown>(mapOrObject?: Map<K, V> | Record<string, V> | null): Map<K, V>;
1165
+ /**
1166
+ * Unwraps a map into an object.
1167
+ *
1168
+ * @param map - Map to convert to object
1169
+ * @returns Plain object
1170
+ */
1171
+ declare function toObject<V = unknown>(map: Map<unknown, V>): Record<string, V>;
1172
+ /**
1173
+ * Copies the contents of key-value pairs from each `objects` in to `map`.
1174
+ *
1175
+ * Object is `objects` can be a `Map` or object.
1176
+ *
1177
+ * This is the `Map` analog to `Object.assign`.
1178
+ */
1179
+ declare function assign<K = unknown, V = unknown>(map: Map<K, V>, ...objects: (Map<K, V> | Record<string, V> | null | undefined)[]): Map<K, V>;
1180
+ /**
1181
+ * Returns `true` if `object` is an {@link ObjectWrappingMap}.
1182
+ *
1183
+ * Defined here, next to the class it guards, so `is.ts` need not import
1184
+ * `map.ts` — that import was the sole edge closing the `is`/`map` cycle.
1185
+ */
1186
+ declare function isObjectWrappingMap(object: unknown): object is ObjectWrappingMap;
1187
+
1188
+ export { type BigNumberValue, DimensionError, FactoryFunction, type FormatOptions, type GeneralFormatOptions, type IdentifiedValue, Index, IndexError, MathjsError, Matrix$1 as Matrix, type MemoizedFunction, type NestedArray, type NormalizedFormatOptions, type NumberTypeConfig, ObjectWrappingMap, PartitionedMap, type SplitValue, UnitConstructor, UnitDependencies, acosh, arraySize, asinh, assign as assignMap, atanh, broadcastArrays, broadcastSizes, broadcastTo, canDefineProperty, cbrt, checkBroadcastingRules, clone$1 as clone, clone as cloneArray, compareText, concat, containsCollections, copysign, cosh, createEmptyMap, createIndexError, createMap, createUnitClass, deepExtend, deepFlatten, deepForEach, deepForEach$1 as deepForEachArray, deepMap, deepMap$1 as deepMapArray, deepStrictEqual, digits, endsWith, escape, expm1, extend, filter, filterRegExp, flatten, forEach, format$2 as format, format as formatBigNumber, format$1 as formatGeneric, generalize, get$1 as get, getArrayDataType, get as getArrayElement, hasOwnProperty, identify, initial, isEmptyIndex, isInteger, isLegacyFactory, isObjectWrappingMap, isPowZeroAtInfinity, join, last, lazy, log10, log1p, log2, map, mapObject, memoize, nearlyEqual, normalizeFormatOptions, pick, pickShallow, processSizesWildcard, reduce, reshape, resize, roundDigits, safeNumberType, scatter, set, sign, sinh, splitNumber, squeeze, stretch, stringify, tanh, toEngineering$1 as toEngineering, toEngineering as toEngineeringBigNumber, toExponential$1 as toExponential, toExponential as toExponentialBigNumber, toFixed$1 as toFixed, toFixed as toFixedBigNumber, toObject, toPrecision, traverse, unitDependencies, unsqueeze, validate, validateIndex, validateIndexSourceSize, warnOnce };