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