@obinexusmk2/hypernum 0.1.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.
- package/LICENSE +21 -0
- package/README.md +256 -0
- package/dist/index.cjs +3425 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1449 -0
- package/dist/index.js +3284 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +8 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/types/config/config-loader.d.ts +56 -0
- package/dist/types/config/config-loader.d.ts.map +1 -0
- package/dist/types/config/config-parser.d.ts +28 -0
- package/dist/types/config/config-parser.d.ts.map +1 -0
- package/dist/types/config/config-resolver.d.ts +21 -0
- package/dist/types/config/config-resolver.d.ts.map +1 -0
- package/dist/types/config/config-source.d.ts +27 -0
- package/dist/types/config/config-source.d.ts.map +1 -0
- package/dist/types/config/index.d.ts +68 -0
- package/dist/types/config/index.d.ts.map +1 -0
- package/dist/types/core/common.d.ts +169 -0
- package/dist/types/core/common.d.ts.map +1 -0
- package/dist/types/core/config.d.ts +197 -0
- package/dist/types/core/config.d.ts.map +1 -0
- package/dist/types/core/constants.d.ts +88 -0
- package/dist/types/core/constants.d.ts.map +1 -0
- package/dist/types/core/errors.d.ts +97 -0
- package/dist/types/core/errors.d.ts.map +1 -0
- package/dist/types/core/hypernum.d.ts +60 -0
- package/dist/types/core/hypernum.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +6 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +33 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/operations/arithmetic.d.ts +72 -0
- package/dist/types/operations/arithmetic.d.ts.map +1 -0
- package/dist/types/operations/bitwise.d.ts +98 -0
- package/dist/types/operations/bitwise.d.ts.map +1 -0
- package/dist/types/operations/comparison.d.ts +94 -0
- package/dist/types/operations/comparison.d.ts.map +1 -0
- package/dist/types/operations/conversion.d.ts +79 -0
- package/dist/types/operations/conversion.d.ts.map +1 -0
- package/dist/types/operations/factorial.d.ts +58 -0
- package/dist/types/operations/factorial.d.ts.map +1 -0
- package/dist/types/operations/index.d.ts +6 -0
- package/dist/types/operations/index.d.ts.map +1 -0
- package/dist/types/operations/power.d.ts +49 -0
- package/dist/types/operations/power.d.ts.map +1 -0
- package/dist/types/storage/Heap.d.ts +95 -0
- package/dist/types/storage/Heap.d.ts.map +1 -0
- package/dist/types/storage/index.d.ts +2 -0
- package/dist/types/storage/index.d.ts.map +1 -0
- package/dist/types/structures/ackermann.d.ts +74 -0
- package/dist/types/structures/ackermann.d.ts.map +1 -0
- package/dist/types/structures/big-array.d.ts +102 -0
- package/dist/types/structures/big-array.d.ts.map +1 -0
- package/dist/types/structures/index.d.ts +5 -0
- package/dist/types/structures/index.d.ts.map +1 -0
- package/dist/types/structures/number-tree.d.ts +114 -0
- package/dist/types/structures/number-tree.d.ts.map +1 -0
- package/dist/types/structures/power-tower.d.ts +74 -0
- package/dist/types/structures/power-tower.d.ts.map +1 -0
- package/dist/types/utils/formatting.d.ts +45 -0
- package/dist/types/utils/formatting.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +5 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/parser.d.ts +39 -0
- package/dist/types/utils/parser.d.ts.map +1 -0
- package/dist/types/utils/precision.d.ts +57 -0
- package/dist/types/utils/precision.d.ts.map +1 -0
- package/dist/types/utils/validation.d.ts +28 -0
- package/dist/types/utils/validation.d.ts.map +1 -0
- package/package.json +164 -0
- package/rollup.config.js +162 -0
- package/src/config/config-loader.ts +226 -0
- package/src/config/config-parser.ts +161 -0
- package/src/config/config-resolver.ts +52 -0
- package/src/config/config-source.ts +32 -0
- package/src/config/index.ts +159 -0
- package/src/core/common.ts +185 -0
- package/src/core/config.ts +393 -0
- package/src/core/constants.ts +102 -0
- package/src/core/errors.ts +203 -0
- package/src/core/hypernum.ts +241 -0
- package/src/core/index.ts +5 -0
- package/src/index.ts +183 -0
- package/src/operations/arithmetic.ts +333 -0
- package/src/operations/bitwise.ts +367 -0
- package/src/operations/comparison.ts +272 -0
- package/src/operations/conversion.ts +400 -0
- package/src/operations/factorial.ts +279 -0
- package/src/operations/index.ts +5 -0
- package/src/operations/power.ts +316 -0
- package/src/storage/Heap.ts +238 -0
- package/src/storage/index.ts +1 -0
- package/src/structures/ackermann.ts +233 -0
- package/src/structures/big-array.ts +306 -0
- package/src/structures/index.ts +4 -0
- package/src/structures/number-tree.ts +404 -0
- package/src/structures/power-tower.ts +278 -0
- package/src/types/common.d.ts +357 -0
- package/src/types/core.d.ts +161 -0
- package/src/types/index.d.ts +2 -0
- package/src/utils/formatting.ts +246 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/parser.ts +245 -0
- package/src/utils/precision.ts +217 -0
- package/src/utils/validation.ts +183 -0
- package/tsconfig.json +84 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1449 @@
|
|
|
1
|
+
import { Comparator as Comparator$1 } from '@/core';
|
|
2
|
+
import { MinHeap as MinHeap$1, MaxHeap as MaxHeap$1 } from '@/storage';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Precision utilities for Hypernum library
|
|
6
|
+
* Provides functions for handling decimal precision and rounding operations
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Rounding modes for decimal operations
|
|
10
|
+
*/
|
|
11
|
+
declare enum RoundingMode {
|
|
12
|
+
FLOOR = "FLOOR",// Round towards negative infinity
|
|
13
|
+
CEIL = "CEIL",// Round towards positive infinity
|
|
14
|
+
DOWN = "DOWN",// Round towards zero
|
|
15
|
+
UP = "UP",// Round away from zero
|
|
16
|
+
HALF_EVEN = "HALF_EVEN",// Round to nearest even number when tied (Banker's rounding)
|
|
17
|
+
HALF_UP = "HALF_UP",// Round up when tied
|
|
18
|
+
HALF_DOWN = "HALF_DOWN"
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Scale a bigint by a power of 10
|
|
22
|
+
*/
|
|
23
|
+
declare const scaleByPowerOfTen: (value: bigint, power: number) => bigint;
|
|
24
|
+
/**
|
|
25
|
+
* Round a number according to specified mode and precision
|
|
26
|
+
*/
|
|
27
|
+
declare const round: (value: bigint, precision?: number, mode?: RoundingMode) => bigint;
|
|
28
|
+
/**
|
|
29
|
+
* Normalize two numbers to the same precision
|
|
30
|
+
*/
|
|
31
|
+
declare const normalizePrecision: (a: bigint, b: bigint, precisionA: number, precisionB: number) => [bigint, bigint];
|
|
32
|
+
/**
|
|
33
|
+
* Scale a division operation to achieve desired precision
|
|
34
|
+
*/
|
|
35
|
+
declare const scaledDivision: (numerator: bigint, denominator: bigint, precision: number, roundingMode?: RoundingMode) => bigint;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Common type definitions for Hypernum library
|
|
39
|
+
* Contains shared types used throughout the library's modules
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Valid input types for numeric values
|
|
44
|
+
*/
|
|
45
|
+
type NumericInput = bigint | string | number;
|
|
46
|
+
/**
|
|
47
|
+
* Result type for operations that may fail
|
|
48
|
+
*/
|
|
49
|
+
type Result<T> = {
|
|
50
|
+
/** Whether the operation succeeded */
|
|
51
|
+
success: boolean;
|
|
52
|
+
/** The operation result if successful */
|
|
53
|
+
value?: T;
|
|
54
|
+
/** Error message if operation failed */
|
|
55
|
+
error?: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Base options interface for operations
|
|
59
|
+
*/
|
|
60
|
+
interface BaseOptions {
|
|
61
|
+
/** Decimal precision for operations */
|
|
62
|
+
precision?: number;
|
|
63
|
+
/** Rounding mode for decimal operations */
|
|
64
|
+
roundingMode?: RoundingMode;
|
|
65
|
+
/** Whether to check for overflow */
|
|
66
|
+
checkOverflow?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Options for number formatting
|
|
70
|
+
*/
|
|
71
|
+
interface FormatOptions$1 extends BaseOptions {
|
|
72
|
+
/** Number notation style */
|
|
73
|
+
notation?: 'standard' | 'scientific' | 'engineering' | 'compact';
|
|
74
|
+
/** Enable grouping separators */
|
|
75
|
+
grouping?: boolean;
|
|
76
|
+
/** Size of digit groups */
|
|
77
|
+
groupSize?: number;
|
|
78
|
+
/** Decimal point character */
|
|
79
|
+
decimalSeparator?: string;
|
|
80
|
+
/** Grouping separator character */
|
|
81
|
+
groupSeparator?: string;
|
|
82
|
+
/** Convert to uppercase (for special formats) */
|
|
83
|
+
uppercase?: boolean;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Cache configuration
|
|
87
|
+
*/
|
|
88
|
+
interface CacheConfig {
|
|
89
|
+
/** Maximum number of entries */
|
|
90
|
+
maxSize: number;
|
|
91
|
+
/** Time-to-live in milliseconds */
|
|
92
|
+
ttl?: number;
|
|
93
|
+
/** Eviction policy */
|
|
94
|
+
evictionPolicy?: 'LRU' | 'LFU' | 'FIFO';
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Mathematical constants configuration
|
|
98
|
+
*/
|
|
99
|
+
interface MathConstantsConfig {
|
|
100
|
+
/** Precision for constant calculations */
|
|
101
|
+
precision: number;
|
|
102
|
+
/** Enable caching of computed values */
|
|
103
|
+
cache?: boolean;
|
|
104
|
+
/** Custom calculation algorithm */
|
|
105
|
+
algorithm?: 'series' | 'iteration' | 'approximation';
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Debug configuration
|
|
109
|
+
*/
|
|
110
|
+
interface DebugConfig {
|
|
111
|
+
/** Enable detailed logging */
|
|
112
|
+
verbose: boolean;
|
|
113
|
+
/** Track operation performance */
|
|
114
|
+
trackPerformance: boolean;
|
|
115
|
+
/** Log level */
|
|
116
|
+
logLevel: 'error' | 'warn' | 'info' | 'debug';
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Numeric range specification
|
|
120
|
+
*/
|
|
121
|
+
interface NumericRange {
|
|
122
|
+
/** Start of range (inclusive) */
|
|
123
|
+
start: bigint;
|
|
124
|
+
/** End of range (inclusive) */
|
|
125
|
+
end: bigint;
|
|
126
|
+
/** Step size for iteration */
|
|
127
|
+
step?: bigint;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Operation status monitoring
|
|
131
|
+
*/
|
|
132
|
+
interface OperationStatus {
|
|
133
|
+
/** Current phase of operation */
|
|
134
|
+
phase: string;
|
|
135
|
+
/** Percentage complete (0-100) */
|
|
136
|
+
progress: number;
|
|
137
|
+
/** Estimated time remaining (ms) */
|
|
138
|
+
estimatedTimeRemaining?: number;
|
|
139
|
+
/** Memory usage in bytes */
|
|
140
|
+
memoryUsage?: number;
|
|
141
|
+
/** Computation steps completed */
|
|
142
|
+
steps: number;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Performance metrics
|
|
146
|
+
*/
|
|
147
|
+
interface PerformanceMetrics {
|
|
148
|
+
/** Operation execution time (ms) */
|
|
149
|
+
executionTime: number;
|
|
150
|
+
/** Number of computation steps */
|
|
151
|
+
steps: number;
|
|
152
|
+
/** Peak memory usage (bytes) */
|
|
153
|
+
peakMemory: number;
|
|
154
|
+
/** Cache hit rate (0-1) */
|
|
155
|
+
cacheHitRate?: number;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Progress callback type
|
|
159
|
+
*/
|
|
160
|
+
type ProgressCallback = (status: OperationStatus) => void;
|
|
161
|
+
/**
|
|
162
|
+
* Error callback type
|
|
163
|
+
*/
|
|
164
|
+
type ErrorCallback = (error: Error, phase: string) => void;
|
|
165
|
+
/**
|
|
166
|
+
* Value validation function type
|
|
167
|
+
*/
|
|
168
|
+
type Validator<T> = (value: T) => boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Node statistics interface
|
|
171
|
+
*/
|
|
172
|
+
interface NodeStats$1 {
|
|
173
|
+
/** Node height in tree */
|
|
174
|
+
height: number;
|
|
175
|
+
/** Subtree size */
|
|
176
|
+
size: number;
|
|
177
|
+
/** Sum of subtree values */
|
|
178
|
+
sum: bigint;
|
|
179
|
+
/** Minimum value in subtree */
|
|
180
|
+
min: bigint;
|
|
181
|
+
/** Maximum value in subtree */
|
|
182
|
+
max: bigint;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Operation options interface
|
|
186
|
+
*/
|
|
187
|
+
interface OperationOptions extends BaseOptions {
|
|
188
|
+
/** Maximum computation steps */
|
|
189
|
+
maxSteps?: number;
|
|
190
|
+
/** Progress callback */
|
|
191
|
+
onProgress?: ProgressCallback;
|
|
192
|
+
/** Error callback */
|
|
193
|
+
onError?: ErrorCallback;
|
|
194
|
+
/** Value validator */
|
|
195
|
+
validator?: Validator<bigint>;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Configuration type definitions for Hypernum library
|
|
200
|
+
* Defines all configuration options and their default values
|
|
201
|
+
*/
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Basic configuration options for simple usage
|
|
205
|
+
*/
|
|
206
|
+
interface BasicConfig {
|
|
207
|
+
/** Decimal precision for operations */
|
|
208
|
+
precision?: number;
|
|
209
|
+
/** Rounding mode for decimal operations */
|
|
210
|
+
roundingMode?: RoundingMode;
|
|
211
|
+
/** Whether to check for overflow */
|
|
212
|
+
checkOverflow?: boolean;
|
|
213
|
+
/** Maximum allowed computation steps */
|
|
214
|
+
maxSteps?: number;
|
|
215
|
+
/** Enable debug mode */
|
|
216
|
+
debug?: boolean;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Configuration for arithmetic operations
|
|
220
|
+
*/
|
|
221
|
+
interface ArithmeticConfig {
|
|
222
|
+
/** Default precision for decimal operations */
|
|
223
|
+
defaultPrecision: number;
|
|
224
|
+
/** Default rounding mode */
|
|
225
|
+
defaultRoundingMode: RoundingMode;
|
|
226
|
+
/** Whether to check for overflow by default */
|
|
227
|
+
checkOverflow: boolean;
|
|
228
|
+
/** Maximum steps for iterative calculations */
|
|
229
|
+
maxComputationSteps: number;
|
|
230
|
+
/** Configure automatic precision adjustment */
|
|
231
|
+
autoPrecision: {
|
|
232
|
+
enabled: boolean;
|
|
233
|
+
maxPrecision: number;
|
|
234
|
+
minPrecision: number;
|
|
235
|
+
};
|
|
236
|
+
/** Constants calculation configuration */
|
|
237
|
+
constants: MathConstantsConfig;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Configuration for data structures
|
|
241
|
+
*/
|
|
242
|
+
interface DataStructuresConfig {
|
|
243
|
+
/** Array configuration */
|
|
244
|
+
array: {
|
|
245
|
+
initialCapacity: number;
|
|
246
|
+
growthFactor: number;
|
|
247
|
+
maxSize: number;
|
|
248
|
+
};
|
|
249
|
+
/** Tree configuration */
|
|
250
|
+
tree: {
|
|
251
|
+
maxDepth: number;
|
|
252
|
+
autoBalance: boolean;
|
|
253
|
+
nodeLimit: number;
|
|
254
|
+
};
|
|
255
|
+
/** Heap configuration */
|
|
256
|
+
heap: {
|
|
257
|
+
initialCapacity: number;
|
|
258
|
+
growthPolicy: 'double' | 'linear' | 'fibonacci';
|
|
259
|
+
validatePropertyOnOperation: boolean;
|
|
260
|
+
};
|
|
261
|
+
/** Cache configuration */
|
|
262
|
+
cache: CacheConfig & {
|
|
263
|
+
enabled: boolean;
|
|
264
|
+
persistToDisk: boolean;
|
|
265
|
+
compressionEnabled: boolean;
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Configuration for number formatting
|
|
270
|
+
*/
|
|
271
|
+
interface FormattingConfig extends FormatOptions$1 {
|
|
272
|
+
/** Scientific notation configuration */
|
|
273
|
+
scientific: {
|
|
274
|
+
/** Minimum exponent to trigger scientific notation */
|
|
275
|
+
minExponent: number;
|
|
276
|
+
/** Maximum significant digits */
|
|
277
|
+
maxSignificantDigits: number;
|
|
278
|
+
/** Exponent separator character */
|
|
279
|
+
exponentSeparator: string;
|
|
280
|
+
};
|
|
281
|
+
/** Engineering notation configuration */
|
|
282
|
+
engineering: {
|
|
283
|
+
/** Use SI prefixes */
|
|
284
|
+
useSIPrefixes: boolean;
|
|
285
|
+
/** Custom unit definitions */
|
|
286
|
+
customUnits?: Map<number, string>;
|
|
287
|
+
};
|
|
288
|
+
/** Localization settings */
|
|
289
|
+
localization: {
|
|
290
|
+
/** Locale identifier */
|
|
291
|
+
locale: string;
|
|
292
|
+
/** Custom number formatting */
|
|
293
|
+
numberFormat?: Intl.NumberFormatOptions;
|
|
294
|
+
/** Use locale-specific grouping */
|
|
295
|
+
useLocaleGrouping: boolean;
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Configuration for performance monitoring
|
|
300
|
+
*/
|
|
301
|
+
interface PerformanceConfig {
|
|
302
|
+
/** Enable performance tracking */
|
|
303
|
+
enableTracking: boolean;
|
|
304
|
+
/** Sampling rate for metrics (0-1) */
|
|
305
|
+
samplingRate: number;
|
|
306
|
+
/** Performance thresholds */
|
|
307
|
+
thresholds: {
|
|
308
|
+
/** Warning threshold in milliseconds */
|
|
309
|
+
warnThresholdMs: number;
|
|
310
|
+
/** Error threshold in milliseconds */
|
|
311
|
+
errorThresholdMs: number;
|
|
312
|
+
/** Maximum allowed memory usage in bytes */
|
|
313
|
+
maxMemoryBytes: number;
|
|
314
|
+
};
|
|
315
|
+
/** Metrics collection configuration */
|
|
316
|
+
metrics: {
|
|
317
|
+
/** Enable detailed operation timing */
|
|
318
|
+
timing: boolean;
|
|
319
|
+
/** Track memory usage */
|
|
320
|
+
memory: boolean;
|
|
321
|
+
/** Track cache performance */
|
|
322
|
+
cache: boolean;
|
|
323
|
+
/** Custom metrics to track */
|
|
324
|
+
custom?: Map<string, (operation: any) => number>;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Feature flags for optional functionality
|
|
329
|
+
*/
|
|
330
|
+
interface FeatureFlags {
|
|
331
|
+
/** Enable experimental features */
|
|
332
|
+
experimentalFeatures: boolean;
|
|
333
|
+
/** Use WebAssembly implementations when available */
|
|
334
|
+
useWasm: boolean;
|
|
335
|
+
/** Enable worker thread support */
|
|
336
|
+
workerThreads: boolean;
|
|
337
|
+
/** Enable SharedArrayBuffer support */
|
|
338
|
+
sharedArrayBuffer: boolean;
|
|
339
|
+
/** Enable BigInt64Array support */
|
|
340
|
+
bigIntTypedArrays: boolean;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Full configuration interface with all options
|
|
344
|
+
*/
|
|
345
|
+
interface FullConfig {
|
|
346
|
+
/** Arithmetic operation configuration */
|
|
347
|
+
arithmetic: ArithmeticConfig;
|
|
348
|
+
/** Data structure configuration */
|
|
349
|
+
dataStructures: DataStructuresConfig;
|
|
350
|
+
/** Formatting configuration */
|
|
351
|
+
formatting: FormattingConfig;
|
|
352
|
+
/** Performance configuration */
|
|
353
|
+
performance: PerformanceConfig;
|
|
354
|
+
/** Debug configuration */
|
|
355
|
+
debug: DebugConfig;
|
|
356
|
+
/** Feature flags */
|
|
357
|
+
features: FeatureFlags;
|
|
358
|
+
/** Custom configuration options */
|
|
359
|
+
custom?: Map<string, any>;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Converts FullConfig to BasicConfig if necessary
|
|
363
|
+
*/
|
|
364
|
+
declare function convertToBasicConfig(config: HypernumConfig$1): BasicConfig;
|
|
365
|
+
/**
|
|
366
|
+
* Combined configuration type that can be either basic or full
|
|
367
|
+
*/
|
|
368
|
+
type HypernumConfig$1 = BasicConfig | FullConfig;
|
|
369
|
+
/**
|
|
370
|
+
* Default configuration values for basic config
|
|
371
|
+
*/
|
|
372
|
+
declare const DEFAULT_BASIC_CONFIG: Required<BasicConfig>;
|
|
373
|
+
/**
|
|
374
|
+
* Full default configuration values
|
|
375
|
+
*/
|
|
376
|
+
declare const DEFAULT_FULL_CONFIG: FullConfig;
|
|
377
|
+
/**
|
|
378
|
+
* Type guard to check if config is a full configuration
|
|
379
|
+
*/
|
|
380
|
+
declare function isFullConfig(config: HypernumConfig$1): config is FullConfig;
|
|
381
|
+
/**
|
|
382
|
+
* Type guard to check if config is a basic configuration
|
|
383
|
+
*/
|
|
384
|
+
declare function isBasicConfig(config: HypernumConfig$1): config is BasicConfig;
|
|
385
|
+
/**
|
|
386
|
+
* Validates configuration values
|
|
387
|
+
*/
|
|
388
|
+
declare function validateConfig(config: HypernumConfig$1): void;
|
|
389
|
+
/**
|
|
390
|
+
* Merges configuration with appropriate defaults
|
|
391
|
+
*/
|
|
392
|
+
declare function mergeConfig(custom?: Partial<HypernumConfig$1>): HypernumConfig$1;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Custom error types for Hypernum library
|
|
396
|
+
* Provides specific error classes for different types of errors that can occur
|
|
397
|
+
* during mathematical operations and data structure manipulations
|
|
398
|
+
*/
|
|
399
|
+
/**
|
|
400
|
+
* Base error class for Hypernum library
|
|
401
|
+
* All other error classes inherit from this
|
|
402
|
+
*/
|
|
403
|
+
declare class HypernumError extends Error {
|
|
404
|
+
constructor(message: string);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Error for arithmetic underflow conditions
|
|
408
|
+
*/
|
|
409
|
+
declare class UnderflowError extends HypernumError {
|
|
410
|
+
constructor(message?: string);
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Error for division by zero
|
|
414
|
+
*/
|
|
415
|
+
declare class DivisionByZeroError extends HypernumError {
|
|
416
|
+
constructor(message?: string);
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Error for precision-related issues
|
|
420
|
+
*/
|
|
421
|
+
declare class PrecisionError extends HypernumError {
|
|
422
|
+
constructor(message?: string);
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Error for computation limits exceeded
|
|
426
|
+
*/
|
|
427
|
+
declare class ComputationLimitError extends HypernumError {
|
|
428
|
+
constructor(message?: string);
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Error for invalid operations on data structures
|
|
432
|
+
*/
|
|
433
|
+
declare class DataStructureError extends HypernumError {
|
|
434
|
+
constructor(message: string);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Error for heap property violations
|
|
438
|
+
*/
|
|
439
|
+
declare class HeapPropertyError extends DataStructureError {
|
|
440
|
+
constructor(message?: string);
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Error for tree-related issues
|
|
444
|
+
*/
|
|
445
|
+
declare class TreeError extends DataStructureError {
|
|
446
|
+
constructor(message?: string);
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Error for array index out of bounds
|
|
450
|
+
*/
|
|
451
|
+
declare class IndexError extends DataStructureError {
|
|
452
|
+
constructor(message?: string);
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Error for invalid number format or conversion
|
|
456
|
+
*/
|
|
457
|
+
declare class FormatError extends HypernumError {
|
|
458
|
+
constructor(message: string);
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Error for invalid Roman numeral operations
|
|
462
|
+
*/
|
|
463
|
+
declare class RomanNumeralError extends FormatError {
|
|
464
|
+
constructor(message?: string);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Core constants for Hypernum library
|
|
469
|
+
* Defines fundamental values and limits used across the library
|
|
470
|
+
*/
|
|
471
|
+
declare const MAX_SAFE_INTEGER: bigint;
|
|
472
|
+
declare const MIN_SAFE_INTEGER: bigint;
|
|
473
|
+
declare const MAX_PRECISION = 100;
|
|
474
|
+
declare const MAX_COMPUTATION_STEPS = 1000;
|
|
475
|
+
declare const MAX_BITS = 1024;
|
|
476
|
+
declare const ZERO: bigint;
|
|
477
|
+
declare const ONE: bigint;
|
|
478
|
+
declare const TWO: bigint;
|
|
479
|
+
declare const TEN: bigint;
|
|
480
|
+
declare const NEGATIVE_ONE: bigint;
|
|
481
|
+
declare const MAX_POWER_BASE: bigint;
|
|
482
|
+
declare const MAX_POWER_EXPONENT: bigint;
|
|
483
|
+
declare const MAX_TETRATION_HEIGHT: bigint;
|
|
484
|
+
declare const MAX_FACTORIAL_INPUT: bigint;
|
|
485
|
+
declare const DEFAULT_TREE_MAX_DEPTH = 1000;
|
|
486
|
+
declare const DEFAULT_HEAP_INITIAL_CAPACITY = 16;
|
|
487
|
+
declare const DEFAULT_ARRAY_GROWTH_FACTOR = 2;
|
|
488
|
+
declare const MIN_ARRAY_CAPACITY = 16;
|
|
489
|
+
declare const DEFAULT_DECIMAL_SEPARATOR = ".";
|
|
490
|
+
declare const DEFAULT_GROUP_SEPARATOR = ",";
|
|
491
|
+
declare const DEFAULT_GROUP_SIZE = 3;
|
|
492
|
+
declare const MAX_GROUP_SIZE = 10;
|
|
493
|
+
declare const MIN_ROMAN_VALUE = 1;
|
|
494
|
+
declare const MAX_ROMAN_VALUE = 3999;
|
|
495
|
+
declare const MAX_ACKERMANN_M = 4;
|
|
496
|
+
declare const MAX_ACKERMANN_N = 1000;
|
|
497
|
+
declare const DEFAULT_CACHE_SIZE = 1000;
|
|
498
|
+
declare const MAX_CACHE_SIZE = 10000;
|
|
499
|
+
declare const ERROR_MESSAGES: {
|
|
500
|
+
readonly OVERFLOW: "Operation would result in overflow";
|
|
501
|
+
readonly UNDERFLOW: "Operation would result in underflow";
|
|
502
|
+
readonly NEGATIVE_ROOT: "Cannot compute root of negative number";
|
|
503
|
+
readonly NEGATIVE_EXPONENT: "Negative exponents not supported for integers";
|
|
504
|
+
readonly DIVISION_BY_ZERO: "Division by zero";
|
|
505
|
+
readonly INVALID_PRECISION: "Precision must be non-negative and not exceed MAX_PRECISION";
|
|
506
|
+
readonly INVALID_BASE: "Base must be a positive integer";
|
|
507
|
+
readonly INVALID_ROMAN: "Invalid Roman numeral";
|
|
508
|
+
readonly COMPUTATION_LIMIT: "Computation exceeded maximum allowed steps";
|
|
509
|
+
readonly NEGATIVE_INDEX: "Array index cannot be negative";
|
|
510
|
+
readonly TREE_DEPTH_EXCEEDED: "Maximum tree depth exceeded";
|
|
511
|
+
readonly INVALID_HEAP_PROPERTY: "Heap property violation detected";
|
|
512
|
+
};
|
|
513
|
+
declare const FEATURES: {
|
|
514
|
+
readonly OVERFLOW_CHECKING: true;
|
|
515
|
+
readonly AUTOMATIC_PRECISION: true;
|
|
516
|
+
readonly MEMOIZATION: true;
|
|
517
|
+
readonly TREE_BALANCING: true;
|
|
518
|
+
readonly DEBUG_MODE: false;
|
|
519
|
+
};
|
|
520
|
+
declare const DEFAULT_OPTIONS: {
|
|
521
|
+
readonly precision: 0;
|
|
522
|
+
readonly roundingMode: "HALF_EVEN";
|
|
523
|
+
readonly checkOverflow: true;
|
|
524
|
+
readonly maxSteps: 1000;
|
|
525
|
+
readonly grouping: true;
|
|
526
|
+
readonly uppercase: false;
|
|
527
|
+
readonly cache: true;
|
|
528
|
+
};
|
|
529
|
+
declare const NUMBER_UNITS: readonly [{
|
|
530
|
+
readonly value: 1n;
|
|
531
|
+
readonly symbol: "";
|
|
532
|
+
}, {
|
|
533
|
+
readonly value: 1000n;
|
|
534
|
+
readonly symbol: "K";
|
|
535
|
+
}, {
|
|
536
|
+
readonly value: 1000000n;
|
|
537
|
+
readonly symbol: "M";
|
|
538
|
+
}, {
|
|
539
|
+
readonly value: 1000000000n;
|
|
540
|
+
readonly symbol: "B";
|
|
541
|
+
}, {
|
|
542
|
+
readonly value: 1000000000000n;
|
|
543
|
+
readonly symbol: "T";
|
|
544
|
+
}, {
|
|
545
|
+
readonly value: 1000000000000000n;
|
|
546
|
+
readonly symbol: "Q";
|
|
547
|
+
}];
|
|
548
|
+
declare const PERFORMANCE: {
|
|
549
|
+
readonly WARN_THRESHOLD_MS: 100;
|
|
550
|
+
readonly ERROR_THRESHOLD_MS: 1000;
|
|
551
|
+
readonly MAX_ARRAY_SIZE: 1000000;
|
|
552
|
+
readonly MAX_TREE_SIZE: 1000000;
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Interface representing an Ackermann node in the computation structure
|
|
557
|
+
*/
|
|
558
|
+
interface IAckermannNode {
|
|
559
|
+
m: number;
|
|
560
|
+
n: number;
|
|
561
|
+
value: bigint;
|
|
562
|
+
prevM?: IAckermannNode;
|
|
563
|
+
prevN?: IAckermannNode;
|
|
564
|
+
nextM?: IAckermannNode;
|
|
565
|
+
nextN?: IAckermannNode;
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Type for Ackermann computation path step
|
|
569
|
+
*/
|
|
570
|
+
type ComputationStep = {
|
|
571
|
+
m: number;
|
|
572
|
+
n: number;
|
|
573
|
+
value: bigint;
|
|
574
|
+
};
|
|
575
|
+
/**
|
|
576
|
+
* Type for growth rate analysis
|
|
577
|
+
*/
|
|
578
|
+
type GrowthAnalysis = {
|
|
579
|
+
value: bigint;
|
|
580
|
+
increase: bigint;
|
|
581
|
+
multiplier: bigint;
|
|
582
|
+
};
|
|
583
|
+
/**
|
|
584
|
+
* Class representing the Ackermann function computation structure
|
|
585
|
+
* Implements caching and relationship tracking between values
|
|
586
|
+
*/
|
|
587
|
+
declare class AckermannStructure {
|
|
588
|
+
private nodes;
|
|
589
|
+
private maxComputedM;
|
|
590
|
+
private maxComputedN;
|
|
591
|
+
private heap;
|
|
592
|
+
constructor();
|
|
593
|
+
/**
|
|
594
|
+
* Generates a unique key for node storage
|
|
595
|
+
*/
|
|
596
|
+
private static getNodeKey;
|
|
597
|
+
/**
|
|
598
|
+
* Computes the Ackermann function value
|
|
599
|
+
* Uses recursion with memoization
|
|
600
|
+
*/
|
|
601
|
+
private computeAckermann;
|
|
602
|
+
/**
|
|
603
|
+
* Adds a new node to the structure
|
|
604
|
+
*/
|
|
605
|
+
addNode(m: number, n: number): IAckermannNode;
|
|
606
|
+
/**
|
|
607
|
+
* Builds nodes for a range of m and n values
|
|
608
|
+
*/
|
|
609
|
+
buildRange(mRange: number, nRange: number): void;
|
|
610
|
+
/**
|
|
611
|
+
* Gets the computation path to reach A(m,n)
|
|
612
|
+
*/
|
|
613
|
+
getComputationPath(m: number, n: number): ComputationStep[];
|
|
614
|
+
/**
|
|
615
|
+
* Analyzes growth rate for a fixed m value
|
|
616
|
+
*/
|
|
617
|
+
analyzeGrowthRate(m: number): Map<number, GrowthAnalysis>;
|
|
618
|
+
/**
|
|
619
|
+
* Gets the largest computed value
|
|
620
|
+
*/
|
|
621
|
+
getLargestValue(): bigint;
|
|
622
|
+
/**
|
|
623
|
+
* Gets a specific Ackermann value if it exists
|
|
624
|
+
*/
|
|
625
|
+
getValue(m: number, n: number): bigint | undefined;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Represents the result of a comparison operation
|
|
630
|
+
* -1: first value is less than second value
|
|
631
|
+
* 0: values are equal
|
|
632
|
+
* 1: first value is greater than second value
|
|
633
|
+
*/
|
|
634
|
+
type ComparisonResult$1 = -1 | 0 | 1;
|
|
635
|
+
/**
|
|
636
|
+
* Generic comparator function type for heap elements
|
|
637
|
+
*/
|
|
638
|
+
type Comparator<T> = (a: T, b: T) => ComparisonResult$1;
|
|
639
|
+
/**
|
|
640
|
+
* Abstract base heap class implementing common heap operations
|
|
641
|
+
*/
|
|
642
|
+
declare abstract class Heap<T> {
|
|
643
|
+
protected heap: T[];
|
|
644
|
+
protected readonly compare: Comparator<T>;
|
|
645
|
+
constructor(comparator: Comparator<T>);
|
|
646
|
+
/**
|
|
647
|
+
* Gets the size of the heap
|
|
648
|
+
*/
|
|
649
|
+
size(): number;
|
|
650
|
+
/**
|
|
651
|
+
* Checks if the heap is empty
|
|
652
|
+
*/
|
|
653
|
+
isEmpty(): boolean;
|
|
654
|
+
/**
|
|
655
|
+
* Peeks at the root element without removing it
|
|
656
|
+
*/
|
|
657
|
+
peek(): T | undefined;
|
|
658
|
+
/**
|
|
659
|
+
* Inserts a new element into the heap
|
|
660
|
+
*/
|
|
661
|
+
push(value: T): void;
|
|
662
|
+
/**
|
|
663
|
+
* Removes and returns the root element
|
|
664
|
+
*/
|
|
665
|
+
pop(): T | undefined;
|
|
666
|
+
/**
|
|
667
|
+
* Removes all elements from the heap
|
|
668
|
+
*/
|
|
669
|
+
clear(): void;
|
|
670
|
+
/**
|
|
671
|
+
* Creates a heap from an array of elements
|
|
672
|
+
*/
|
|
673
|
+
static heapify<T extends {}>(array: T[], comparator: Comparator<T>): Heap<T>;
|
|
674
|
+
/**
|
|
675
|
+
* Gets the parent index of a node
|
|
676
|
+
*/
|
|
677
|
+
protected getParentIndex(index: number): number;
|
|
678
|
+
/**
|
|
679
|
+
* Gets the left child index of a node
|
|
680
|
+
*/
|
|
681
|
+
protected getLeftChildIndex(index: number): number;
|
|
682
|
+
/**
|
|
683
|
+
* Gets the right child index of a node
|
|
684
|
+
*/
|
|
685
|
+
protected getRightChildIndex(index: number): number;
|
|
686
|
+
/**
|
|
687
|
+
* Swaps two elements in the heap
|
|
688
|
+
*/
|
|
689
|
+
protected swap(i: number, j: number): void;
|
|
690
|
+
/**
|
|
691
|
+
* Moves an element up the heap until heap property is satisfied
|
|
692
|
+
*/
|
|
693
|
+
protected abstract siftUp(index: number): void;
|
|
694
|
+
/**
|
|
695
|
+
* Moves an element down the heap until heap property is satisfied
|
|
696
|
+
*/
|
|
697
|
+
protected abstract siftDown(index: number): void;
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* MinHeap implementation where the root is the smallest element
|
|
701
|
+
*/
|
|
702
|
+
declare class MinHeap<T> extends Heap<T> {
|
|
703
|
+
constructor(comparator: Comparator<T>);
|
|
704
|
+
protected siftUp(index: number): void;
|
|
705
|
+
protected siftDown(index: number): void;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* MaxHeap implementation where the root is the largest element
|
|
709
|
+
*/
|
|
710
|
+
declare class MaxHeap<T> extends Heap<T> {
|
|
711
|
+
constructor(comparator: Comparator<T>);
|
|
712
|
+
protected siftUp(index: number): void;
|
|
713
|
+
protected siftDown(index: number): void;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Type for BigArray operation result
|
|
718
|
+
*/
|
|
719
|
+
type OperationResult<T> = {
|
|
720
|
+
success: boolean;
|
|
721
|
+
value?: T;
|
|
722
|
+
error?: string;
|
|
723
|
+
};
|
|
724
|
+
/**
|
|
725
|
+
* Options for BigArray initialization
|
|
726
|
+
*/
|
|
727
|
+
interface BigArrayOptions<T> {
|
|
728
|
+
initialCapacity?: number;
|
|
729
|
+
growthFactor?: number;
|
|
730
|
+
comparator?: Comparator$1<T>;
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* A specialized array implementation for handling large numbers and providing
|
|
734
|
+
* efficient operations with segment tree support
|
|
735
|
+
*/
|
|
736
|
+
declare class BigArray<T> {
|
|
737
|
+
private data;
|
|
738
|
+
private segmentTree;
|
|
739
|
+
private readonly growthFactor;
|
|
740
|
+
private readonly comparator;
|
|
741
|
+
private size;
|
|
742
|
+
private capacity;
|
|
743
|
+
constructor(options?: BigArrayOptions<T>);
|
|
744
|
+
/**
|
|
745
|
+
* Gets the current size of the array
|
|
746
|
+
*/
|
|
747
|
+
getSize(): number;
|
|
748
|
+
/**
|
|
749
|
+
* Gets the current capacity of the array
|
|
750
|
+
*/
|
|
751
|
+
getCapacity(): number;
|
|
752
|
+
/**
|
|
753
|
+
* Resizes the internal array when needed
|
|
754
|
+
*/
|
|
755
|
+
private resize;
|
|
756
|
+
/**
|
|
757
|
+
* Appends an element to the end of the array
|
|
758
|
+
*/
|
|
759
|
+
push(value: T): OperationResult<number>;
|
|
760
|
+
/**
|
|
761
|
+
* Removes and returns the last element
|
|
762
|
+
*/
|
|
763
|
+
pop(): OperationResult<T>;
|
|
764
|
+
/**
|
|
765
|
+
* Gets element at specified index
|
|
766
|
+
*/
|
|
767
|
+
get(index: number): OperationResult<T>;
|
|
768
|
+
/**
|
|
769
|
+
* Sets element at specified index
|
|
770
|
+
*/
|
|
771
|
+
set(index: number, value: T): OperationResult<T>;
|
|
772
|
+
/**
|
|
773
|
+
* Rebuilds the segment tree after major changes
|
|
774
|
+
*/
|
|
775
|
+
private rebuildSegmentTree;
|
|
776
|
+
/**
|
|
777
|
+
* Builds a segment tree node recursively
|
|
778
|
+
*/
|
|
779
|
+
private buildSegmentTree;
|
|
780
|
+
/**
|
|
781
|
+
* Updates the segment tree after a value change
|
|
782
|
+
*/
|
|
783
|
+
private updateSegmentTree;
|
|
784
|
+
/**
|
|
785
|
+
* Queries the maximum value in a range
|
|
786
|
+
*/
|
|
787
|
+
queryRange(start: number, end: number): OperationResult<T>;
|
|
788
|
+
/**
|
|
789
|
+
* Recursively queries the segment tree
|
|
790
|
+
*/
|
|
791
|
+
private querySegmentTree;
|
|
792
|
+
/**
|
|
793
|
+
* Creates a heap from the current array
|
|
794
|
+
*/
|
|
795
|
+
toHeap(isMin?: boolean): MinHeap<T> | MaxHeap<T>;
|
|
796
|
+
/**
|
|
797
|
+
* Sorts the array in-place
|
|
798
|
+
*/
|
|
799
|
+
sort(ascending?: boolean): void;
|
|
800
|
+
/**
|
|
801
|
+
* Returns array as native array
|
|
802
|
+
*/
|
|
803
|
+
toArray(): T[];
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Interface for tree node statistics
|
|
808
|
+
*/
|
|
809
|
+
interface NodeStats {
|
|
810
|
+
height: number;
|
|
811
|
+
size: number;
|
|
812
|
+
sum: bigint;
|
|
813
|
+
min: bigint;
|
|
814
|
+
max: bigint;
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Interface for tree traversal configuration
|
|
818
|
+
*/
|
|
819
|
+
interface TraversalConfig {
|
|
820
|
+
includeStats?: boolean;
|
|
821
|
+
skipSubtrees?: boolean;
|
|
822
|
+
maxDepth?: number;
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Class representing a node in the number tree
|
|
826
|
+
*/
|
|
827
|
+
declare class NumberNode {
|
|
828
|
+
value: bigint;
|
|
829
|
+
left: NumberNode | null;
|
|
830
|
+
right: NumberNode | null;
|
|
831
|
+
parent: NumberNode | null;
|
|
832
|
+
height: number;
|
|
833
|
+
size: number;
|
|
834
|
+
sum: bigint;
|
|
835
|
+
constructor(value: bigint | string | number);
|
|
836
|
+
/**
|
|
837
|
+
* Updates node statistics based on children
|
|
838
|
+
*/
|
|
839
|
+
updateStats(): void;
|
|
840
|
+
/**
|
|
841
|
+
* Gets balance factor of the node
|
|
842
|
+
*/
|
|
843
|
+
getBalance(): number;
|
|
844
|
+
/**
|
|
845
|
+
* Gets complete statistics for the node and its subtree
|
|
846
|
+
*/
|
|
847
|
+
getStats(): NodeStats;
|
|
848
|
+
/**
|
|
849
|
+
* Finds minimum value node in the subtree
|
|
850
|
+
*/
|
|
851
|
+
findMin(): NumberNode;
|
|
852
|
+
/**
|
|
853
|
+
* Finds maximum value node in the subtree
|
|
854
|
+
*/
|
|
855
|
+
findMax(): NumberNode;
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* AVL Tree implementation specialized for handling large numbers
|
|
859
|
+
*/
|
|
860
|
+
declare class NumberTree {
|
|
861
|
+
private root;
|
|
862
|
+
private readonly comparator;
|
|
863
|
+
constructor(comparator?: Comparator$1<bigint>);
|
|
864
|
+
/**
|
|
865
|
+
* Gets the root node if it exists
|
|
866
|
+
*/
|
|
867
|
+
getRoot(): NumberNode | null;
|
|
868
|
+
/**
|
|
869
|
+
* Inserts a new value into the tree
|
|
870
|
+
*/
|
|
871
|
+
insert(value: bigint | string | number): NumberNode;
|
|
872
|
+
/**
|
|
873
|
+
* Recursively inserts a new node
|
|
874
|
+
*/
|
|
875
|
+
private insertNode;
|
|
876
|
+
/**
|
|
877
|
+
* Balances a node using AVL rotations
|
|
878
|
+
*/
|
|
879
|
+
private balance;
|
|
880
|
+
/**
|
|
881
|
+
* Performs left rotation
|
|
882
|
+
*/
|
|
883
|
+
private rotateLeft;
|
|
884
|
+
/**
|
|
885
|
+
* Performs right rotation
|
|
886
|
+
*/
|
|
887
|
+
private rotateRight;
|
|
888
|
+
/**
|
|
889
|
+
* Removes a value from the tree
|
|
890
|
+
*/
|
|
891
|
+
remove(value: bigint | string | number): boolean;
|
|
892
|
+
/**
|
|
893
|
+
* Recursively removes a node
|
|
894
|
+
*/
|
|
895
|
+
private removeNode;
|
|
896
|
+
/**
|
|
897
|
+
* Finds a node by value
|
|
898
|
+
*/
|
|
899
|
+
find(value: bigint | string | number): NumberNode | null;
|
|
900
|
+
/**
|
|
901
|
+
* Traverses the tree in specified order and returns values
|
|
902
|
+
*/
|
|
903
|
+
traverse(order?: 'inOrder' | 'preOrder' | 'postOrder', config?: TraversalConfig): bigint[];
|
|
904
|
+
/**
|
|
905
|
+
* Gets overall tree statistics
|
|
906
|
+
*/
|
|
907
|
+
getTreeStats(): NodeStats | null;
|
|
908
|
+
/**
|
|
909
|
+
* Gets the nth smallest value in the tree
|
|
910
|
+
*/
|
|
911
|
+
getNthValue(n: number): bigint | null;
|
|
912
|
+
/**
|
|
913
|
+
* Gets a range of values between start and end (inclusive)
|
|
914
|
+
*/
|
|
915
|
+
getRange(start: bigint | string | number, end: bigint | string | number): bigint[];
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* Interface for power tower computation options
|
|
920
|
+
*/
|
|
921
|
+
interface PowerTowerOptions {
|
|
922
|
+
maxHeight?: number;
|
|
923
|
+
maxValue?: bigint;
|
|
924
|
+
checkOverflow?: boolean;
|
|
925
|
+
precision?: number;
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Class representing a power tower (tetration) computation structure
|
|
929
|
+
* Handles expressions of the form: a↑↑b = a^(a^(a^...)) (b times)
|
|
930
|
+
*/
|
|
931
|
+
declare class PowerTower {
|
|
932
|
+
private readonly options;
|
|
933
|
+
private head;
|
|
934
|
+
private tail;
|
|
935
|
+
private size;
|
|
936
|
+
constructor(options?: PowerTowerOptions);
|
|
937
|
+
/**
|
|
938
|
+
* Creates a new power tower node
|
|
939
|
+
*/
|
|
940
|
+
private createNode;
|
|
941
|
+
/**
|
|
942
|
+
* Validates power tower height
|
|
943
|
+
*/
|
|
944
|
+
private validateHeight;
|
|
945
|
+
/**
|
|
946
|
+
* Validates value for computation
|
|
947
|
+
*/
|
|
948
|
+
private validateValue;
|
|
949
|
+
/**
|
|
950
|
+
* Computes power with overflow checking
|
|
951
|
+
*/
|
|
952
|
+
private computePower;
|
|
953
|
+
/**
|
|
954
|
+
* Builds a power tower of specified height with given base
|
|
955
|
+
*/
|
|
956
|
+
build(base: bigint | number | string, height: number): void;
|
|
957
|
+
/**
|
|
958
|
+
* Evaluates the power tower up to specified height
|
|
959
|
+
*/
|
|
960
|
+
evaluate(height?: number): bigint;
|
|
961
|
+
/**
|
|
962
|
+
* Gets the current height of the power tower
|
|
963
|
+
*/
|
|
964
|
+
getHeight(): number;
|
|
965
|
+
/**
|
|
966
|
+
* Checks if the tower can be evaluated to a given height
|
|
967
|
+
*/
|
|
968
|
+
isComputable(height?: number): boolean;
|
|
969
|
+
/**
|
|
970
|
+
* Gets the computation state at each level
|
|
971
|
+
*/
|
|
972
|
+
getState(): {
|
|
973
|
+
height: number;
|
|
974
|
+
value: bigint;
|
|
975
|
+
evaluated: boolean;
|
|
976
|
+
}[];
|
|
977
|
+
/**
|
|
978
|
+
* Clears the power tower
|
|
979
|
+
*/
|
|
980
|
+
clear(): void;
|
|
981
|
+
/**
|
|
982
|
+
* Gets the maximum computationally feasible height for a given base
|
|
983
|
+
*/
|
|
984
|
+
static getMaxFeasibleHeight(base: bigint | number | string): number;
|
|
985
|
+
/**
|
|
986
|
+
* Creates a string representation of the power tower
|
|
987
|
+
*/
|
|
988
|
+
toString(): string;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* Formatting utilities for Hypernum library
|
|
993
|
+
* Provides functions for formatting large numbers and converting between different representations
|
|
994
|
+
*/
|
|
995
|
+
interface FormatOptions {
|
|
996
|
+
notation?: 'standard' | 'scientific' | 'engineering' | 'compact';
|
|
997
|
+
precision?: number;
|
|
998
|
+
grouping?: boolean;
|
|
999
|
+
groupSize?: number;
|
|
1000
|
+
decimalSeparator?: string;
|
|
1001
|
+
groupSeparator?: string;
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Formats a BigInt value according to specified options
|
|
1005
|
+
*/
|
|
1006
|
+
declare const formatBigInt: (value: bigint, options?: FormatOptions) => string;
|
|
1007
|
+
/**
|
|
1008
|
+
* Parses a formatted string back to BigInt
|
|
1009
|
+
*/
|
|
1010
|
+
declare const parseBigIntString: (str: string, options?: FormatOptions) => bigint;
|
|
1011
|
+
/**
|
|
1012
|
+
* Normalizes a string representation for comparison
|
|
1013
|
+
*/
|
|
1014
|
+
declare const normalizeNumberString: (str: string) => string;
|
|
1015
|
+
|
|
1016
|
+
declare const toBigInt: (value: unknown) => bigint;
|
|
1017
|
+
declare const checkAdditionOverflow: (a: bigint, b: bigint) => void;
|
|
1018
|
+
declare const checkMultiplicationOverflow: (a: bigint, b: bigint) => void;
|
|
1019
|
+
declare const checkPowerOverflow: (base: bigint, exponent: bigint) => void;
|
|
1020
|
+
declare const validatePositive: (value: bigint) => void;
|
|
1021
|
+
declare const validateNonNegative: (value: bigint) => void;
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* Main Hypernum class that provides a high-level interface to all library functionality
|
|
1025
|
+
*/
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* Configuration options for Hypernum instance
|
|
1029
|
+
*/
|
|
1030
|
+
interface HypernumConfig {
|
|
1031
|
+
precision?: number;
|
|
1032
|
+
roundingMode?: RoundingMode;
|
|
1033
|
+
checkOverflow?: boolean;
|
|
1034
|
+
maxSteps?: number;
|
|
1035
|
+
debug?: boolean;
|
|
1036
|
+
}
|
|
1037
|
+
declare class Hypernum {
|
|
1038
|
+
private readonly config;
|
|
1039
|
+
private readonly structures;
|
|
1040
|
+
constructor(config?: HypernumConfig);
|
|
1041
|
+
add(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
1042
|
+
subtract(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
1043
|
+
multiply(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
1044
|
+
divide(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
1045
|
+
mod(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
1046
|
+
power(base: bigint | string | number, exponent: bigint | string | number): bigint;
|
|
1047
|
+
sqrt(value: bigint | string | number): bigint;
|
|
1048
|
+
nthRoot(value: bigint | string | number, n: bigint | string | number): bigint;
|
|
1049
|
+
and(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
1050
|
+
or(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
1051
|
+
xor(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
1052
|
+
not(value: bigint | string | number): bigint;
|
|
1053
|
+
/**
|
|
1054
|
+
* Calculates the greatest common divisor of two numbers
|
|
1055
|
+
*/
|
|
1056
|
+
gcd(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
1057
|
+
/**
|
|
1058
|
+
* Calculates the least common multiple of two numbers
|
|
1059
|
+
*/
|
|
1060
|
+
lcm(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
1061
|
+
createArray(id: string): BigArray<bigint>;
|
|
1062
|
+
getArray(id: string): BigArray<bigint>;
|
|
1063
|
+
createTree(id: string): NumberTree;
|
|
1064
|
+
getTree(id: string): NumberTree;
|
|
1065
|
+
createHeap(id: string, isMinHeap?: boolean): MinHeap$1<bigint> | MaxHeap$1<bigint>;
|
|
1066
|
+
getHeap(id: string): MinHeap$1<bigint> | MaxHeap$1<bigint>;
|
|
1067
|
+
createAckermannStructure(): AckermannStructure;
|
|
1068
|
+
format(value: bigint | string | number, options?: FormatOptions): string;
|
|
1069
|
+
validate(value: unknown): boolean;
|
|
1070
|
+
updateConfig(newConfig: Partial<HypernumConfig>): void;
|
|
1071
|
+
getConfig(): Readonly<Required<HypernumConfig>>;
|
|
1072
|
+
private compareValues;
|
|
1073
|
+
dispose(): void;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Arithmetic operations module for Hypernum library
|
|
1078
|
+
* Provides high-precision arithmetic operations with BigInt support
|
|
1079
|
+
*/
|
|
1080
|
+
|
|
1081
|
+
/**
|
|
1082
|
+
* Options for arithmetic operations
|
|
1083
|
+
*/
|
|
1084
|
+
interface ArithmeticOptions {
|
|
1085
|
+
precision?: number;
|
|
1086
|
+
roundingMode?: RoundingMode;
|
|
1087
|
+
checkOverflow?: boolean;
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Adds two numbers with optional precision and overflow checking
|
|
1091
|
+
*/
|
|
1092
|
+
declare function add(a: bigint | string | number, b: bigint | string | number, options?: ArithmeticOptions): bigint;
|
|
1093
|
+
/**
|
|
1094
|
+
* Subtracts two numbers with optional precision and overflow checking
|
|
1095
|
+
*/
|
|
1096
|
+
declare function subtract(a: bigint | string | number, b: bigint | string | number, options?: ArithmeticOptions): bigint;
|
|
1097
|
+
/**
|
|
1098
|
+
* Multiplies two numbers with optional precision and overflow checking
|
|
1099
|
+
*/
|
|
1100
|
+
declare function multiply(a: bigint | string | number, b: bigint | string | number, options?: ArithmeticOptions): bigint;
|
|
1101
|
+
/**
|
|
1102
|
+
* Divides two numbers with specified precision and rounding
|
|
1103
|
+
*/
|
|
1104
|
+
declare function divide(numerator: bigint | string | number, denominator: bigint | string | number, options?: ArithmeticOptions): bigint;
|
|
1105
|
+
/**
|
|
1106
|
+
* Calculates remainder with optional precision
|
|
1107
|
+
*/
|
|
1108
|
+
declare function remainder(a: bigint | string | number, b: bigint | string | number, options?: ArithmeticOptions): bigint;
|
|
1109
|
+
/**
|
|
1110
|
+
* Calculates the absolute value
|
|
1111
|
+
*/
|
|
1112
|
+
declare function abs(value: bigint | string | number): bigint;
|
|
1113
|
+
/**
|
|
1114
|
+
* Returns the sign of a number (-1, 0, or 1)
|
|
1115
|
+
*/
|
|
1116
|
+
declare function sign(value: bigint | string | number): bigint;
|
|
1117
|
+
/**
|
|
1118
|
+
* Calculates the greatest common divisor of two numbers
|
|
1119
|
+
*/
|
|
1120
|
+
declare function gcd(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
1121
|
+
/**
|
|
1122
|
+
* Calculates the least common multiple of two numbers
|
|
1123
|
+
*/
|
|
1124
|
+
declare function lcm(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
1125
|
+
|
|
1126
|
+
/**
|
|
1127
|
+
* Bitwise operations module for Hypernum library
|
|
1128
|
+
* Provides functions for bit-level manipulations of large numbers
|
|
1129
|
+
*/
|
|
1130
|
+
/**
|
|
1131
|
+
* Options for bitwise operations
|
|
1132
|
+
*/
|
|
1133
|
+
interface BitwiseOptions {
|
|
1134
|
+
/** Maximum bits to consider in operations */
|
|
1135
|
+
maxBits?: number;
|
|
1136
|
+
/** Whether to throw on overflow */
|
|
1137
|
+
strict?: boolean;
|
|
1138
|
+
}
|
|
1139
|
+
/**
|
|
1140
|
+
* Performs bitwise AND operation
|
|
1141
|
+
*/
|
|
1142
|
+
declare function and(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
1143
|
+
/**
|
|
1144
|
+
* Performs bitwise OR operation
|
|
1145
|
+
*/
|
|
1146
|
+
declare function or(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
1147
|
+
/**
|
|
1148
|
+
* Performs bitwise XOR operation
|
|
1149
|
+
*/
|
|
1150
|
+
declare function xor(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
1151
|
+
/**
|
|
1152
|
+
* Performs bitwise NOT operation
|
|
1153
|
+
*/
|
|
1154
|
+
declare function not(value: bigint | string | number): bigint;
|
|
1155
|
+
/**
|
|
1156
|
+
* Performs left shift operation
|
|
1157
|
+
*/
|
|
1158
|
+
declare function leftShift(value: bigint | string | number, shift: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
1159
|
+
/**
|
|
1160
|
+
* Performs right shift operation
|
|
1161
|
+
*/
|
|
1162
|
+
declare function rightShift(value: bigint | string | number, shift: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
1163
|
+
/**
|
|
1164
|
+
* Performs unsigned right shift operation
|
|
1165
|
+
* Note: BigInt doesn't have >>> operator, so we implement it manually
|
|
1166
|
+
*/
|
|
1167
|
+
declare function unsignedRightShift(value: bigint | string | number, shift: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
1168
|
+
/**
|
|
1169
|
+
* Rotates bits left by specified amount
|
|
1170
|
+
*/
|
|
1171
|
+
declare function rotateLeft(value: bigint | string | number, rotation: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
1172
|
+
/**
|
|
1173
|
+
* Rotates bits right by specified amount
|
|
1174
|
+
*/
|
|
1175
|
+
declare function rotateRight(value: bigint | string | number, rotation: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
1176
|
+
/**
|
|
1177
|
+
* Counts number of set bits (1s)
|
|
1178
|
+
*/
|
|
1179
|
+
declare function popCount(value: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
1180
|
+
/**
|
|
1181
|
+
* Returns number of trailing zero bits
|
|
1182
|
+
*/
|
|
1183
|
+
declare function trailingZeros(value: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
1184
|
+
/**
|
|
1185
|
+
* Returns number of leading zero bits
|
|
1186
|
+
*/
|
|
1187
|
+
declare function leadingZeros(value: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
1188
|
+
/**
|
|
1189
|
+
* Returns bit at specified position
|
|
1190
|
+
*/
|
|
1191
|
+
declare function getBit(value: bigint | string | number, position: bigint | string | number, options?: BitwiseOptions): boolean;
|
|
1192
|
+
/**
|
|
1193
|
+
* Sets bit at specified position
|
|
1194
|
+
*/
|
|
1195
|
+
declare function setBit(value: bigint | string | number, position: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
1196
|
+
/**
|
|
1197
|
+
* Clears bit at specified position
|
|
1198
|
+
*/
|
|
1199
|
+
declare function clearBit(value: bigint | string | number, position: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
1200
|
+
/**
|
|
1201
|
+
* Toggles bit at specified position
|
|
1202
|
+
*/
|
|
1203
|
+
declare function toggleBit(value: bigint | string | number, position: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* Comparison operations module for Hypernum library
|
|
1207
|
+
* Provides functions for comparing large numbers with precision support
|
|
1208
|
+
*/
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* Options for comparison operations
|
|
1212
|
+
*/
|
|
1213
|
+
interface ComparisonOptions {
|
|
1214
|
+
precision?: number;
|
|
1215
|
+
roundingMode?: RoundingMode;
|
|
1216
|
+
tolerance?: number;
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Result type for comparison operations
|
|
1220
|
+
* -1: first value is less than second value
|
|
1221
|
+
* 0: values are equal
|
|
1222
|
+
* 1: first value is greater than second value
|
|
1223
|
+
*/
|
|
1224
|
+
type ComparisonResult = -1 | 0 | 1;
|
|
1225
|
+
/**
|
|
1226
|
+
* Compares two numbers with optional precision
|
|
1227
|
+
*/
|
|
1228
|
+
declare function compare(a: bigint | string | number, b: bigint | string | number, options?: ComparisonOptions): ComparisonResult;
|
|
1229
|
+
/**
|
|
1230
|
+
* Checks if two numbers are equal
|
|
1231
|
+
*/
|
|
1232
|
+
declare function equals(a: bigint | string | number, b: bigint | string | number, options?: ComparisonOptions): boolean;
|
|
1233
|
+
/**
|
|
1234
|
+
* Checks if first number is less than second
|
|
1235
|
+
*/
|
|
1236
|
+
declare function lessThan(a: bigint | string | number, b: bigint | string | number, options?: ComparisonOptions): boolean;
|
|
1237
|
+
/**
|
|
1238
|
+
* Checks if first number is less than or equal to second
|
|
1239
|
+
*/
|
|
1240
|
+
declare function lessThanOrEqual(a: bigint | string | number, b: bigint | string | number, options?: ComparisonOptions): boolean;
|
|
1241
|
+
/**
|
|
1242
|
+
* Checks if first number is greater than second
|
|
1243
|
+
*/
|
|
1244
|
+
declare function greaterThan(a: bigint | string | number, b: bigint | string | number, options?: ComparisonOptions): boolean;
|
|
1245
|
+
/**
|
|
1246
|
+
* Checks if first number is greater than or equal to second
|
|
1247
|
+
*/
|
|
1248
|
+
declare function greaterThanOrEqual(a: bigint | string | number, b: bigint | string | number, options?: ComparisonOptions): boolean;
|
|
1249
|
+
/**
|
|
1250
|
+
* Checks if a number is between two others (inclusive)
|
|
1251
|
+
*/
|
|
1252
|
+
declare function between(value: bigint | string | number, min: bigint | string | number, max: bigint | string | number, options?: ComparisonOptions): boolean;
|
|
1253
|
+
/**
|
|
1254
|
+
* Finds the maximum value in an array of numbers
|
|
1255
|
+
*/
|
|
1256
|
+
declare function max(values: Array<bigint | string | number>, options?: ComparisonOptions): bigint;
|
|
1257
|
+
/**
|
|
1258
|
+
* Finds the minimum value in an array of numbers
|
|
1259
|
+
*/
|
|
1260
|
+
declare function min(values: Array<bigint | string | number>, options?: ComparisonOptions): bigint;
|
|
1261
|
+
/**
|
|
1262
|
+
* Clamps a value between minimum and maximum bounds
|
|
1263
|
+
*/
|
|
1264
|
+
declare function clamp(value: bigint | string | number, min: bigint | string | number, max: bigint | string | number, options?: ComparisonOptions): bigint;
|
|
1265
|
+
/**
|
|
1266
|
+
* Checks if all values in array are equal within tolerance
|
|
1267
|
+
*/
|
|
1268
|
+
declare function allEqual(values: Array<bigint | string | number>, options?: ComparisonOptions): boolean;
|
|
1269
|
+
/**
|
|
1270
|
+
* Checks if values are in ascending order
|
|
1271
|
+
*/
|
|
1272
|
+
declare function isAscending(values: Array<bigint | string | number>, options?: ComparisonOptions): boolean;
|
|
1273
|
+
/**
|
|
1274
|
+
* Checks if values are in descending order
|
|
1275
|
+
*/
|
|
1276
|
+
declare function isDescending(values: Array<bigint | string | number>, options?: ComparisonOptions): boolean;
|
|
1277
|
+
/**
|
|
1278
|
+
* Creates a comparator function for sorting
|
|
1279
|
+
*/
|
|
1280
|
+
declare function createComparator(options?: ComparisonOptions): (a: bigint | string | number, b: bigint | string | number) => number;
|
|
1281
|
+
|
|
1282
|
+
/**
|
|
1283
|
+
* Conversion operations module for Hypernum library
|
|
1284
|
+
* Provides functions for converting numbers between different formats and bases
|
|
1285
|
+
*/
|
|
1286
|
+
|
|
1287
|
+
/**
|
|
1288
|
+
* Options for conversion operations
|
|
1289
|
+
*/
|
|
1290
|
+
interface ConversionOptions {
|
|
1291
|
+
/** Precision for decimal operations */
|
|
1292
|
+
precision?: number;
|
|
1293
|
+
/** Rounding mode for decimal operations */
|
|
1294
|
+
roundingMode?: RoundingMode;
|
|
1295
|
+
/** Whether to use uppercase for hex/base-N output */
|
|
1296
|
+
uppercase?: boolean;
|
|
1297
|
+
/** Whether to add prefix for base-N output (0x, 0b, etc.) */
|
|
1298
|
+
prefix?: boolean;
|
|
1299
|
+
/** Minimum number of digits (pad with zeros) */
|
|
1300
|
+
minDigits?: number;
|
|
1301
|
+
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Converts number to binary string representation
|
|
1304
|
+
*/
|
|
1305
|
+
declare function toBinary(value: bigint | string | number, options?: ConversionOptions): string;
|
|
1306
|
+
/**
|
|
1307
|
+
* Converts number to octal string representation
|
|
1308
|
+
*/
|
|
1309
|
+
declare function toOctal(value: bigint | string | number, options?: ConversionOptions): string;
|
|
1310
|
+
/**
|
|
1311
|
+
* Converts number to hexadecimal string representation
|
|
1312
|
+
*/
|
|
1313
|
+
declare function toHexadecimal(value: bigint | string | number, options?: ConversionOptions): string;
|
|
1314
|
+
/**
|
|
1315
|
+
* Converts number to string in specified base
|
|
1316
|
+
*/
|
|
1317
|
+
declare function toBase(value: bigint | string | number, base: number, options?: ConversionOptions): string;
|
|
1318
|
+
/**
|
|
1319
|
+
* Converts string from specified base to bigint
|
|
1320
|
+
*/
|
|
1321
|
+
declare function fromBase(value: string, base: number): bigint;
|
|
1322
|
+
/**
|
|
1323
|
+
* Converts decimal string to fraction representation
|
|
1324
|
+
*/
|
|
1325
|
+
declare function toFraction(value: string): [bigint, bigint];
|
|
1326
|
+
/**
|
|
1327
|
+
* Converts fraction to decimal string with specified precision
|
|
1328
|
+
*/
|
|
1329
|
+
declare function fromFraction(numerator: bigint | string | number, denominator: bigint | string | number, options?: ConversionOptions): string;
|
|
1330
|
+
/**
|
|
1331
|
+
* Converts scientific notation to decimal string
|
|
1332
|
+
*/
|
|
1333
|
+
declare function fromScientific(value: string): string;
|
|
1334
|
+
/**
|
|
1335
|
+
* Converts decimal to scientific notation
|
|
1336
|
+
*/
|
|
1337
|
+
declare function toScientific(value: bigint | string | number, options?: ConversionOptions): string;
|
|
1338
|
+
/**
|
|
1339
|
+
* Converts Roman numeral to number
|
|
1340
|
+
*/
|
|
1341
|
+
declare function fromRoman(value: string): bigint;
|
|
1342
|
+
/**
|
|
1343
|
+
* Converts number to Roman numeral
|
|
1344
|
+
*/
|
|
1345
|
+
declare function toRoman(value: bigint | string | number, options?: ConversionOptions): string;
|
|
1346
|
+
|
|
1347
|
+
/**
|
|
1348
|
+
* Factorial operations module for Hypernum library
|
|
1349
|
+
* Provides efficient implementations for factorial and related computations
|
|
1350
|
+
*/
|
|
1351
|
+
/**
|
|
1352
|
+
* Options for factorial operations
|
|
1353
|
+
*/
|
|
1354
|
+
interface FactorialOptions {
|
|
1355
|
+
/** Maximum allowed computation value */
|
|
1356
|
+
maxValue?: number;
|
|
1357
|
+
/** Whether to check for overflow */
|
|
1358
|
+
checkOverflow?: boolean;
|
|
1359
|
+
/** Cache computed values */
|
|
1360
|
+
useCache?: boolean;
|
|
1361
|
+
}
|
|
1362
|
+
/**
|
|
1363
|
+
* Calculates factorial of a number (n!)
|
|
1364
|
+
*/
|
|
1365
|
+
declare function factorial(value: bigint | string | number, options?: FactorialOptions): bigint;
|
|
1366
|
+
/**
|
|
1367
|
+
* Calculates binomial coefficient (n choose k)
|
|
1368
|
+
*/
|
|
1369
|
+
declare function binomial(n: bigint | string | number, k: bigint | string | number, options?: FactorialOptions): bigint;
|
|
1370
|
+
/**
|
|
1371
|
+
* Calculates subfactorial (derangement number)
|
|
1372
|
+
* Number of permutations of n elements with no fixed points
|
|
1373
|
+
*/
|
|
1374
|
+
declare function subfactorial(value: bigint | string | number, options?: FactorialOptions): bigint;
|
|
1375
|
+
/**
|
|
1376
|
+
* Calculates rising factorial (Pochhammer symbol)
|
|
1377
|
+
* x^(n) = x(x+1)(x+2)...(x+n-1)
|
|
1378
|
+
*/
|
|
1379
|
+
declare function risingFactorial(x: bigint | string | number, n: bigint | string | number, options?: FactorialOptions): bigint;
|
|
1380
|
+
/**
|
|
1381
|
+
* Calculates falling factorial
|
|
1382
|
+
* x_(n) = x(x-1)(x-2)...(x-n+1)
|
|
1383
|
+
*/
|
|
1384
|
+
declare function fallingFactorial(x: bigint | string | number, n: bigint | string | number, options?: FactorialOptions): bigint;
|
|
1385
|
+
/**
|
|
1386
|
+
* Calculates multifactorial (n!!)
|
|
1387
|
+
* Product of numbers from 1 to n that leave the same remainder as n when divided by k
|
|
1388
|
+
*/
|
|
1389
|
+
declare function multiFactorial(value: bigint | string | number, k?: bigint | string | number, options?: FactorialOptions): bigint;
|
|
1390
|
+
/**
|
|
1391
|
+
* Calculates primorial (product of primes up to n)
|
|
1392
|
+
*/
|
|
1393
|
+
declare function primorial(value: bigint | string | number, options?: FactorialOptions): bigint;
|
|
1394
|
+
|
|
1395
|
+
/**
|
|
1396
|
+
* Power operations module for Hypernum library
|
|
1397
|
+
* Provides efficient implementations for exponentiation and related operations
|
|
1398
|
+
*/
|
|
1399
|
+
|
|
1400
|
+
/**
|
|
1401
|
+
* Options for power operations
|
|
1402
|
+
*/
|
|
1403
|
+
interface PowerOptions {
|
|
1404
|
+
/** Precision for decimal operations */
|
|
1405
|
+
precision?: number;
|
|
1406
|
+
/** Rounding mode for decimal operations */
|
|
1407
|
+
roundingMode?: RoundingMode;
|
|
1408
|
+
/** Whether to check for overflow */
|
|
1409
|
+
checkOverflow?: boolean;
|
|
1410
|
+
/** Maximum allowed computation steps */
|
|
1411
|
+
maxSteps?: number;
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* Raises a number to an integer power using binary exponentiation
|
|
1415
|
+
*/
|
|
1416
|
+
declare function power(baseValue: bigint | string | number, exponentValue: bigint | string | number, options?: PowerOptions): bigint;
|
|
1417
|
+
/**
|
|
1418
|
+
* Calculates square root using Newton's method
|
|
1419
|
+
*/
|
|
1420
|
+
declare function sqrt(value: bigint | string | number, options?: PowerOptions): bigint;
|
|
1421
|
+
/**
|
|
1422
|
+
* Calculates nth root using Newton's method
|
|
1423
|
+
*/
|
|
1424
|
+
declare function nthRoot(value: bigint | string | number, n: bigint | string | number, options?: PowerOptions): bigint;
|
|
1425
|
+
/**
|
|
1426
|
+
* Calculates tetration (repeated exponentiation)
|
|
1427
|
+
* a↑↑n = a^(a^(a^...)) (n times)
|
|
1428
|
+
*/
|
|
1429
|
+
declare function tetration(base: bigint | string | number, height: bigint | string | number, options?: PowerOptions): bigint;
|
|
1430
|
+
/**
|
|
1431
|
+
* Calculates super-root (inverse tetration)
|
|
1432
|
+
* Finds x where x↑↑n = value
|
|
1433
|
+
*/
|
|
1434
|
+
declare function superRoot(value: bigint | string | number, height: bigint | string | number, options?: PowerOptions): bigint;
|
|
1435
|
+
|
|
1436
|
+
/**
|
|
1437
|
+
* Hypernum - A TypeScript/JavaScript library for large number operations
|
|
1438
|
+
*/
|
|
1439
|
+
|
|
1440
|
+
declare const VERSION: any;
|
|
1441
|
+
|
|
1442
|
+
/**
|
|
1443
|
+
* Creates a new Hypernum instance with custom configuration
|
|
1444
|
+
*/
|
|
1445
|
+
declare function createHypernum(config?: Partial<HypernumConfig$1>): Hypernum;
|
|
1446
|
+
declare const defaultHypernum: Hypernum;
|
|
1447
|
+
|
|
1448
|
+
export { AckermannStructure, BigArray, ComputationLimitError, DEFAULT_ARRAY_GROWTH_FACTOR, DEFAULT_BASIC_CONFIG, DEFAULT_CACHE_SIZE, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_FULL_CONFIG, DEFAULT_GROUP_SEPARATOR, DEFAULT_GROUP_SIZE, DEFAULT_HEAP_INITIAL_CAPACITY, DEFAULT_OPTIONS, DEFAULT_TREE_MAX_DEPTH, DataStructureError, DivisionByZeroError, ERROR_MESSAGES, FEATURES, FormatError, HeapPropertyError, Hypernum, HypernumError, IndexError, MAX_ACKERMANN_M, MAX_ACKERMANN_N, MAX_BITS, MAX_CACHE_SIZE, MAX_COMPUTATION_STEPS, MAX_FACTORIAL_INPUT, MAX_GROUP_SIZE, MAX_POWER_BASE, MAX_POWER_EXPONENT, MAX_PRECISION, MAX_ROMAN_VALUE, MAX_SAFE_INTEGER, MAX_TETRATION_HEIGHT, MIN_ARRAY_CAPACITY, MIN_ROMAN_VALUE, MIN_SAFE_INTEGER, MaxHeap, MinHeap, NEGATIVE_ONE, NUMBER_UNITS, NumberTree, ONE, PERFORMANCE, PowerTower, PrecisionError, RomanNumeralError, RoundingMode, TEN, TWO, TreeError, UnderflowError, VERSION, ZERO, abs, add, allEqual, and, between, binomial, checkAdditionOverflow, checkMultiplicationOverflow, checkPowerOverflow, clamp, clearBit, compare, convertToBasicConfig, createComparator, createHypernum, Hypernum as default, defaultHypernum, divide, equals, factorial, fallingFactorial, formatBigInt, fromBase, fromFraction, fromRoman, fromScientific, gcd, getBit, greaterThan, greaterThanOrEqual, isAscending, isBasicConfig, isDescending, isFullConfig, lcm, leadingZeros, leftShift, lessThan, lessThanOrEqual, max, mergeConfig, min, multiFactorial, multiply, normalizeNumberString, normalizePrecision, not, nthRoot, or, parseBigIntString, popCount, power, primorial, remainder, rightShift, risingFactorial, rotateLeft, rotateRight, round, scaleByPowerOfTen, scaledDivision, setBit, sign, sqrt, subfactorial, subtract, superRoot, tetration, toBase, toBigInt, toBinary, toFraction, toHexadecimal, toOctal, toRoman, toScientific, toggleBit, trailingZeros, unsignedRightShift, validateConfig, validateNonNegative, validatePositive, xor };
|
|
1449
|
+
export type { ArithmeticConfig, BaseOptions, BasicConfig, BigArrayOptions, CacheConfig, Comparator, DataStructuresConfig, DebugConfig, ErrorCallback, FeatureFlags, FormatOptions$1 as FormatOptions, FormattingConfig, FullConfig, HypernumConfig$1 as HypernumConfig, MathConstantsConfig, NodeStats$1 as NodeStats, NumericInput, NumericRange, OperationOptions, OperationStatus, PerformanceConfig, PerformanceMetrics, ProgressCallback, Result, Validator };
|