numpy-ts 0.2.0 → 0.4.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,9 +1,9 @@
1
1
  /**
2
2
  * Broadcasting utilities for NumPy-compatible array operations
3
3
  *
4
- * Wraps @stdlib broadcasting functions with NumPy-compatible API
4
+ * Implements NumPy broadcasting rules without external dependencies
5
5
  */
6
- type StdlibNDArray = any;
6
+ import { ArrayStorage } from './storage';
7
7
  /**
8
8
  * Check if two or more shapes are broadcast-compatible
9
9
  * and compute the resulting output shape
@@ -35,21 +35,25 @@ export declare function computeBroadcastShape(shapes: readonly number[][]): numb
35
35
  */
36
36
  export declare function areBroadcastable(shape1: readonly number[], shape2: readonly number[]): boolean;
37
37
  /**
38
- * Broadcast multiple stdlib ndarrays to a common shape
38
+ * Broadcast an ArrayStorage to a target shape
39
+ * Returns a view with modified strides for broadcasting
39
40
  *
40
- * Returns read-only views of the input arrays broadcast to the same shape.
41
+ * @param storage - The storage to broadcast
42
+ * @param targetShape - The target shape to broadcast to
43
+ * @returns A new ArrayStorage view with broadcasting strides
44
+ */
45
+ export declare function broadcastTo(storage: ArrayStorage, targetShape: readonly number[]): ArrayStorage;
46
+ /**
47
+ * Broadcast multiple ArrayStorage objects to a common shape
48
+ *
49
+ * Returns views of the input arrays broadcast to the same shape.
41
50
  * Views share memory with the original arrays.
42
51
  *
43
- * @param arrays - Stdlib ndarrays to broadcast
44
- * @returns Array of broadcast stdlib ndarrays
52
+ * @param storages - ArrayStorage objects to broadcast
53
+ * @returns Array of broadcast ArrayStorage views
45
54
  * @throws Error if arrays have incompatible shapes
46
- *
47
- * @example
48
- * ```typescript
49
- * const [a, b] = broadcastStdlibArrays([arr1._data, arr2._data]);
50
- * ```
51
55
  */
52
- export declare function broadcastStdlibArrays(arrays: StdlibNDArray[]): StdlibNDArray[];
56
+ export declare function broadcastArrays(storages: ArrayStorage[]): ArrayStorage[];
53
57
  /**
54
58
  * Generate a descriptive error message for broadcasting failures
55
59
  *
@@ -58,5 +62,4 @@ export declare function broadcastStdlibArrays(arrays: StdlibNDArray[]): StdlibND
58
62
  * @returns Error message string
59
63
  */
60
64
  export declare function broadcastErrorMessage(shapes: readonly number[][], operation?: string): string;
61
- export {};
62
65
  //# sourceMappingURL=broadcasting.d.ts.map
@@ -1,21 +1,19 @@
1
1
  /**
2
2
  * NDArray - NumPy-compatible multidimensional array
3
3
  *
4
- * Thin wrapper around @stdlib/ndarray providing NumPy-like API
4
+ * Core array class providing NumPy-like API
5
5
  */
6
6
  import { type DType, type TypedArray } from './dtype';
7
7
  import { ArrayStorage } from './storage';
8
- type StdlibNDArray = any;
9
8
  export declare class NDArray {
10
- private _data;
11
- private _dtype?;
9
+ private _storage;
12
10
  private _base?;
13
- constructor(stdlibArray: StdlibNDArray, dtype?: DType, base?: NDArray);
11
+ constructor(storage: ArrayStorage, base?: NDArray);
14
12
  /**
15
13
  * Get internal storage (for ops modules)
16
14
  * @internal
17
15
  */
18
- get _storage(): ArrayStorage;
16
+ get storage(): ArrayStorage;
19
17
  /**
20
18
  * Create NDArray from storage (for ops modules)
21
19
  * @internal
@@ -45,41 +43,16 @@ export declare class NDArray {
45
43
  * Get a single element from the array
46
44
  * @param indices - Array of indices, one per dimension (e.g., [0, 1] for 2D array)
47
45
  * @returns The element value (BigInt for int64/uint64, number otherwise)
48
- *
49
- * @example
50
- * ```typescript
51
- * const arr = array([[1, 2], [3, 4]]);
52
- * arr.get([0, 1]); // Returns 2
53
- * arr.get([-1, -1]); // Returns 4 (negative indexing supported)
54
- * ```
55
46
  */
56
47
  get(indices: number[]): number | bigint;
57
48
  /**
58
49
  * Set a single element in the array
59
50
  * @param indices - Array of indices, one per dimension (e.g., [0, 1] for 2D array)
60
51
  * @param value - Value to set (will be converted to array's dtype)
61
- *
62
- * @example
63
- * ```typescript
64
- * const arr = zeros([2, 3]);
65
- * arr.set([0, 1], 42); // Set element at position [0, 1] to 42
66
- * arr.set([-1, -1], 99); // Set last element to 99 (negative indexing supported)
67
- * ```
68
52
  */
69
53
  set(indices: number[], value: number | bigint): void;
70
54
  /**
71
55
  * Return a deep copy of the array
72
- * Creates a new array with copied data (not a view)
73
- *
74
- * @returns Deep copy of the array
75
- *
76
- * @example
77
- * ```typescript
78
- * const arr = array([[1, 2], [3, 4]]);
79
- * const copied = arr.copy();
80
- * copied.set([0, 0], 99); // Doesn't affect original
81
- * console.log(arr.get([0, 0])); // Still 1
82
- * ```
83
56
  */
84
57
  copy(): NDArray;
85
58
  /**
@@ -90,16 +63,50 @@ export declare class NDArray {
90
63
  */
91
64
  astype(dtype: DType, copy?: boolean): NDArray;
92
65
  /**
93
- * Helper method for element-wise operations with broadcasting
94
- * @private
66
+ * Element-wise addition
67
+ * @param other - Array or scalar to add
68
+ * @returns Result of addition with broadcasting
95
69
  */
96
70
  add(other: NDArray | number): NDArray;
71
+ /**
72
+ * Element-wise subtraction
73
+ * @param other - Array or scalar to subtract
74
+ * @returns Result of subtraction with broadcasting
75
+ */
97
76
  subtract(other: NDArray | number): NDArray;
77
+ /**
78
+ * Element-wise multiplication
79
+ * @param other - Array or scalar to multiply
80
+ * @returns Result of multiplication with broadcasting
81
+ */
98
82
  multiply(other: NDArray | number): NDArray;
83
+ /**
84
+ * Element-wise division
85
+ * @param other - Array or scalar to divide by
86
+ * @returns Result of division with broadcasting
87
+ */
99
88
  divide(other: NDArray | number): NDArray;
89
+ /**
90
+ * Element-wise modulo operation
91
+ * @param other - Array or scalar divisor
92
+ * @returns Remainder after division
93
+ */
100
94
  mod(other: NDArray | number): NDArray;
95
+ /**
96
+ * Element-wise floor division
97
+ * @param other - Array or scalar to divide by
98
+ * @returns Floor of the quotient
99
+ */
101
100
  floor_divide(other: NDArray | number): NDArray;
101
+ /**
102
+ * Numerical positive (element-wise +x)
103
+ * @returns Copy of the array
104
+ */
102
105
  positive(): NDArray;
106
+ /**
107
+ * Element-wise reciprocal (1/x)
108
+ * @returns New array with reciprocals
109
+ */
103
110
  reciprocal(): NDArray;
104
111
  /**
105
112
  * Square root of each element
@@ -173,15 +180,15 @@ export declare class NDArray {
173
180
  * @returns Boolean array (represented as uint8: 1=true, 0=false)
174
181
  */
175
182
  isclose(other: NDArray | number, rtol?: number, atol?: number): NDArray;
176
- allclose(other: NDArray | number, rtol?: number, atol?: number): boolean;
177
183
  /**
178
- * Helper method for isclose operation with broadcasting
179
- * @private
180
- */
181
- /**
182
- * Helper method for comparison operations with broadcasting
183
- * @private
184
+ * Element-wise comparison with tolerance
185
+ * Returns True where |a - b| <= (atol + rtol * |b|)
186
+ * @param other - Value or array to compare with
187
+ * @param rtol - Relative tolerance (default: 1e-5)
188
+ * @param atol - Absolute tolerance (default: 1e-8)
189
+ * @returns Boolean array (represented as uint8: 1=true, 0=false)
184
190
  */
191
+ allclose(other: NDArray | number, rtol?: number, atol?: number): boolean;
185
192
  /**
186
193
  * Sum array elements over a given axis
187
194
  * @param axis - Axis along which to sum. If undefined, sum all elements
@@ -296,20 +303,47 @@ export declare class NDArray {
296
303
  * @returns Array with additional dimension (always a view)
297
304
  */
298
305
  expand_dims(axis: number): NDArray;
306
+ /**
307
+ * Matrix multiplication
308
+ * @param other - Array to multiply with
309
+ * @returns Result of matrix multiplication
310
+ */
299
311
  matmul(other: NDArray): NDArray;
312
+ /**
313
+ * Dot product (matching NumPy behavior)
314
+ * @param other - Array to dot with
315
+ * @returns Result of dot product (scalar or array depending on dimensions)
316
+ */
317
+ dot(other: NDArray): NDArray | number | bigint;
318
+ /**
319
+ * Sum of diagonal elements (trace)
320
+ * @returns Sum of diagonal elements
321
+ */
322
+ trace(): number | bigint;
323
+ /**
324
+ * Inner product (contracts over last axes of both arrays)
325
+ * @param other - Array to compute inner product with
326
+ * @returns Inner product result
327
+ */
328
+ inner(other: NDArray): NDArray | number | bigint;
329
+ /**
330
+ * Outer product (flattens inputs then computes a[i]*b[j])
331
+ * @param other - Array to compute outer product with
332
+ * @returns 2D outer product matrix
333
+ */
334
+ outer(other: NDArray): NDArray;
335
+ /**
336
+ * Tensor dot product along specified axes
337
+ * @param other - Array to contract with
338
+ * @param axes - Axes to contract (integer or [a_axes, b_axes])
339
+ * @returns Tensor dot product result
340
+ */
341
+ tensordot(other: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint;
300
342
  /**
301
343
  * Slice the array using NumPy-style string syntax
302
344
  *
303
345
  * @param sliceStrs - Slice specifications, one per dimension
304
346
  * @returns Sliced view of the array
305
- *
306
- * @example
307
- * ```typescript
308
- * const arr = array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
309
- * const row = arr.slice('0', ':'); // First row: [1, 2, 3]
310
- * const col = arr.slice(':', '1'); // Second column: [2, 5, 8]
311
- * const sub = arr.slice('0:2', '1:3'); // Top-right 2x2: [[2, 3], [5, 6]]
312
- * ```
313
347
  */
314
348
  slice(...sliceStrs: string[]): NDArray;
315
349
  /**
@@ -338,87 +372,271 @@ export declare class NDArray {
338
372
  * @returns Columns as array
339
373
  */
340
374
  cols(start: number, stop: number): NDArray;
375
+ /**
376
+ * String representation of the array
377
+ * @returns String describing the array shape and dtype
378
+ */
341
379
  toString(): string;
380
+ /**
381
+ * Convert to nested JavaScript array
382
+ * @returns Nested JavaScript array representation
383
+ */
342
384
  toArray(): any;
343
385
  }
344
386
  /**
345
387
  * Create array of zeros
388
+ * @param shape - Shape of the array
389
+ * @param dtype - Data type (default: float64)
390
+ * @returns Array filled with zeros
346
391
  */
347
392
  export declare function zeros(shape: number[], dtype?: DType): NDArray;
348
393
  /**
349
394
  * Create array of ones
395
+ * @param shape - Shape of the array
396
+ * @param dtype - Data type (default: float64)
397
+ * @returns Array filled with ones
350
398
  */
351
399
  export declare function ones(shape: number[], dtype?: DType): NDArray;
400
+ /**
401
+ * Create array from nested JavaScript arrays
402
+ * @param data - Nested arrays or existing NDArray
403
+ * @param dtype - Data type (optional, will be inferred if not provided)
404
+ * @returns New NDArray
405
+ */
352
406
  export declare function array(data: any, dtype?: DType): NDArray;
353
407
  /**
354
408
  * Create array with evenly spaced values within a given interval
355
- * Similar to Python's range() but returns floats
409
+ * Similar to Python's range() but returns array
410
+ * @param start - Start value (or stop if only one argument)
411
+ * @param stop - Stop value (exclusive)
412
+ * @param step - Step between values (default: 1)
413
+ * @param dtype - Data type (default: float64)
414
+ * @returns Array of evenly spaced values
356
415
  */
357
416
  export declare function arange(start: number, stop?: number, step?: number, dtype?: DType): NDArray;
358
417
  /**
359
418
  * Create array with evenly spaced values over a specified interval
419
+ * @param start - Starting value
420
+ * @param stop - Ending value (inclusive)
421
+ * @param num - Number of samples (default: 50)
422
+ * @param dtype - Data type (default: float64)
423
+ * @returns Array of evenly spaced values
360
424
  */
361
425
  export declare function linspace(start: number, stop: number, num?: number, dtype?: DType): NDArray;
362
426
  /**
363
427
  * Create array with logarithmically spaced values
364
428
  * Returns num samples, equally spaced on a log scale from base^start to base^stop
429
+ * @param start - base^start is the starting value
430
+ * @param stop - base^stop is the ending value
431
+ * @param num - Number of samples (default: 50)
432
+ * @param base - Base of the log space (default: 10.0)
433
+ * @param dtype - Data type (default: float64)
434
+ * @returns Array of logarithmically spaced values
365
435
  */
366
436
  export declare function logspace(start: number, stop: number, num?: number, base?: number, dtype?: DType): NDArray;
367
437
  /**
368
438
  * Create array with geometrically spaced values
369
439
  * Returns num samples, equally spaced on a log scale (geometric progression)
440
+ * @param start - Starting value
441
+ * @param stop - Ending value
442
+ * @param num - Number of samples (default: 50)
443
+ * @param dtype - Data type (default: float64)
444
+ * @returns Array of geometrically spaced values
370
445
  */
371
446
  export declare function geomspace(start: number, stop: number, num?: number, dtype?: DType): NDArray;
372
447
  /**
373
448
  * Create identity matrix
449
+ * @param n - Number of rows
450
+ * @param m - Number of columns (default: n)
451
+ * @param k - Index of diagonal (0 for main diagonal, positive for upper, negative for lower)
452
+ * @param dtype - Data type (default: float64)
453
+ * @returns Identity matrix
374
454
  */
375
455
  export declare function eye(n: number, m?: number, k?: number, dtype?: DType): NDArray;
376
456
  /**
377
457
  * Create an uninitialized array
378
- * Note: Unlike NumPy, TypedArrays are zero-initialized by default in JavaScript
458
+ * Note: TypedArrays are zero-initialized by default in JavaScript
459
+ * @param shape - Shape of the array
460
+ * @param dtype - Data type (default: float64)
461
+ * @returns Uninitialized array
379
462
  */
380
463
  export declare function empty(shape: number[], dtype?: DType): NDArray;
381
464
  /**
382
465
  * Create array filled with a constant value
466
+ * @param shape - Shape of the array
467
+ * @param fill_value - Value to fill the array with
468
+ * @param dtype - Data type (optional, inferred from fill_value if not provided)
469
+ * @returns Array filled with the constant value
383
470
  */
384
471
  export declare function full(shape: number[], fill_value: number | bigint | boolean, dtype?: DType): NDArray;
385
472
  /**
386
473
  * Create a square identity matrix
474
+ * @param n - Size of the square matrix
475
+ * @param dtype - Data type (default: float64)
476
+ * @returns n×n identity matrix
387
477
  */
388
478
  export declare function identity(n: number, dtype?: DType): NDArray;
389
479
  /**
390
480
  * Convert input to an ndarray
391
- * If input is already an NDArray, optionally convert dtype
481
+ * @param a - Input data (array-like or NDArray)
482
+ * @param dtype - Data type (optional)
483
+ * @returns NDArray representation of the input
392
484
  */
393
485
  export declare function asarray(a: NDArray | any, dtype?: DType): NDArray;
394
486
  /**
395
487
  * Create a deep copy of an array
488
+ * @param a - Array to copy
489
+ * @returns Deep copy of the array
396
490
  */
397
491
  export declare function copy(a: NDArray): NDArray;
398
492
  /**
399
493
  * Create array of zeros with the same shape as another array
494
+ * @param a - Array to match shape from
495
+ * @param dtype - Data type (optional, uses a's dtype if not provided)
496
+ * @returns Array of zeros
400
497
  */
401
498
  export declare function zeros_like(a: NDArray, dtype?: DType): NDArray;
402
499
  /**
403
500
  * Create array of ones with the same shape as another array
501
+ * @param a - Array to match shape from
502
+ * @param dtype - Data type (optional, uses a's dtype if not provided)
503
+ * @returns Array of ones
404
504
  */
405
505
  export declare function ones_like(a: NDArray, dtype?: DType): NDArray;
406
506
  /**
407
507
  * Create uninitialized array with the same shape as another array
508
+ * @param a - Array to match shape from
509
+ * @param dtype - Data type (optional, uses a's dtype if not provided)
510
+ * @returns Uninitialized array
408
511
  */
409
512
  export declare function empty_like(a: NDArray, dtype?: DType): NDArray;
410
513
  /**
411
514
  * Create array filled with a constant value, same shape as another array
515
+ * @param a - Array to match shape from
516
+ * @param fill_value - Value to fill with
517
+ * @param dtype - Data type (optional, uses a's dtype if not provided)
518
+ * @returns Filled array
412
519
  */
413
520
  export declare function full_like(a: NDArray, fill_value: number | bigint | boolean, dtype?: DType): NDArray;
521
+ /**
522
+ * Element-wise square root
523
+ * @param x - Input array
524
+ * @returns Array of square roots
525
+ */
414
526
  export declare function sqrt(x: NDArray): NDArray;
527
+ /**
528
+ * Element-wise power
529
+ * @param x - Base array
530
+ * @param exponent - Exponent (array or scalar)
531
+ * @returns Array of x raised to exponent
532
+ */
415
533
  export declare function power(x: NDArray, exponent: NDArray | number): NDArray;
534
+ /**
535
+ * Element-wise absolute value
536
+ * @param x - Input array
537
+ * @returns Array of absolute values
538
+ */
416
539
  export declare function absolute(x: NDArray): NDArray;
540
+ /**
541
+ * Element-wise negation
542
+ * @param x - Input array
543
+ * @returns Array of negated values
544
+ */
417
545
  export declare function negative(x: NDArray): NDArray;
546
+ /**
547
+ * Element-wise sign (-1, 0, or 1)
548
+ * @param x - Input array
549
+ * @returns Array of signs
550
+ */
418
551
  export declare function sign(x: NDArray): NDArray;
552
+ /**
553
+ * Element-wise modulo
554
+ * @param x - Dividend array
555
+ * @param divisor - Divisor (array or scalar)
556
+ * @returns Remainder after division
557
+ */
419
558
  export declare function mod(x: NDArray, divisor: NDArray | number): NDArray;
559
+ /**
560
+ * Element-wise floor division
561
+ * @param x - Dividend array
562
+ * @param divisor - Divisor (array or scalar)
563
+ * @returns Floor of the quotient
564
+ */
420
565
  export declare function floor_divide(x: NDArray, divisor: NDArray | number): NDArray;
566
+ /**
567
+ * Element-wise positive (unary +)
568
+ * @param x - Input array
569
+ * @returns Copy of the array
570
+ */
421
571
  export declare function positive(x: NDArray): NDArray;
572
+ /**
573
+ * Element-wise reciprocal (1/x)
574
+ * @param x - Input array
575
+ * @returns Array of reciprocals
576
+ */
422
577
  export declare function reciprocal(x: NDArray): NDArray;
423
- export {};
578
+ /**
579
+ * Dot product of two arrays
580
+ *
581
+ * Fully NumPy-compatible. Behavior depends on input dimensions:
582
+ * - 0D · 0D: Multiply scalars → scalar
583
+ * - 0D · ND or ND · 0D: Element-wise multiply → ND
584
+ * - 1D · 1D: Inner product → scalar
585
+ * - 2D · 2D: Matrix multiplication → 2D
586
+ * - 2D · 1D: Matrix-vector product → 1D
587
+ * - 1D · 2D: Vector-matrix product → 1D
588
+ * - ND · 1D (N>2): Sum over last axis → (N-1)D
589
+ * - 1D · ND (N>2): Sum over first axis → (N-1)D
590
+ * - ND · MD (N,M≥2): Tensor contraction → (N+M-2)D
591
+ *
592
+ * @param a - First array
593
+ * @param b - Second array
594
+ * @returns Result of dot product
595
+ */
596
+ export declare function dot(a: NDArray, b: NDArray): NDArray | number | bigint;
597
+ /**
598
+ * Sum of diagonal elements
599
+ *
600
+ * @param a - Input 2D array
601
+ * @returns Sum of diagonal elements
602
+ */
603
+ export declare function trace(a: NDArray): number | bigint;
604
+ /**
605
+ * Permute array dimensions
606
+ *
607
+ * @param a - Input array
608
+ * @param axes - Optional permutation of axes (defaults to reverse order)
609
+ * @returns Transposed view
610
+ */
611
+ export declare function transpose(a: NDArray, axes?: number[]): NDArray;
612
+ /**
613
+ * Inner product of two arrays
614
+ *
615
+ * Contracts over last axes of both arrays.
616
+ * Result shape: (*a.shape[:-1], *b.shape[:-1])
617
+ *
618
+ * @param a - First array
619
+ * @param b - Second array
620
+ * @returns Inner product result
621
+ */
622
+ export declare function inner(a: NDArray, b: NDArray): NDArray | number | bigint;
623
+ /**
624
+ * Outer product of two arrays
625
+ *
626
+ * Flattens inputs then computes result[i,j] = a[i] * b[j]
627
+ *
628
+ * @param a - First array
629
+ * @param b - Second array
630
+ * @returns 2D outer product matrix
631
+ */
632
+ export declare function outer(a: NDArray, b: NDArray): NDArray;
633
+ /**
634
+ * Tensor dot product along specified axes
635
+ *
636
+ * @param a - First array
637
+ * @param b - Second array
638
+ * @param axes - Axes to contract (integer or [a_axes, b_axes])
639
+ * @returns Tensor dot product
640
+ */
641
+ export declare function tensordot(a: NDArray, b: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint;
424
642
  //# sourceMappingURL=ndarray.d.ts.map
@@ -1,21 +1,22 @@
1
1
  /**
2
2
  * ArrayStorage - Internal storage abstraction
3
3
  *
4
- * Wraps @stdlib/ndarray to provide a clean internal interface
5
- * while keeping stdlib as an implementation detail.
4
+ * Stores array data directly using TypedArrays without external dependencies.
6
5
  *
7
6
  * @internal - This is not part of the public API
8
7
  */
9
- import type { ndarray as StdlibNDArray } from '@stdlib/types/ndarray';
10
8
  import { type DType, type TypedArray } from './dtype';
11
9
  /**
12
10
  * Internal storage for NDArray data
13
11
  * Manages the underlying TypedArray and metadata
14
12
  */
15
13
  export declare class ArrayStorage {
16
- private _stdlib;
14
+ private _data;
15
+ private _shape;
16
+ private _strides;
17
+ private _offset;
17
18
  private _dtype;
18
- constructor(stdlibArray: StdlibNDArray, dt?: DType);
19
+ constructor(data: TypedArray, shape: readonly number[], strides: readonly number[], offset: number, dtype: DType);
19
20
  /**
20
21
  * Shape of the array
21
22
  */
@@ -41,10 +42,9 @@ export declare class ArrayStorage {
41
42
  */
42
43
  get strides(): readonly number[];
43
44
  /**
44
- * Direct access to stdlib ndarray (for internal use)
45
- * @internal
45
+ * Offset into the data buffer
46
46
  */
47
- get stdlib(): StdlibNDArray;
47
+ get offset(): number;
48
48
  /**
49
49
  * Check if array is C-contiguous (row-major, no gaps)
50
50
  */
@@ -54,17 +54,29 @@ export declare class ArrayStorage {
54
54
  */
55
55
  get isFContiguous(): boolean;
56
56
  /**
57
- * Create a deep copy of this storage
57
+ * Get element at linear index (respects strides and offset)
58
58
  */
59
- copy(): ArrayStorage;
59
+ iget(linearIndex: number): number | bigint;
60
+ /**
61
+ * Set element at linear index (respects strides and offset)
62
+ */
63
+ iset(linearIndex: number, value: number | bigint): void;
64
+ /**
65
+ * Get element at multi-index position
66
+ */
67
+ get(...indices: number[]): number | bigint;
68
+ /**
69
+ * Set element at multi-index position
70
+ */
71
+ set(indices: number[], value: number | bigint): void;
60
72
  /**
61
- * Create storage from stdlib ndarray
73
+ * Create a deep copy of this storage
62
74
  */
63
- static fromStdlib(stdlibArray: StdlibNDArray, dtype?: DType): ArrayStorage;
75
+ copy(): ArrayStorage;
64
76
  /**
65
77
  * Create storage from TypedArray data
66
78
  */
67
- static fromData(data: TypedArray, shape: number[], dtype: DType): ArrayStorage;
79
+ static fromData(data: TypedArray, shape: number[], dtype: DType, strides?: number[], offset?: number): ArrayStorage;
68
80
  /**
69
81
  * Create storage with zeros
70
82
  */
@@ -73,11 +85,6 @@ export declare class ArrayStorage {
73
85
  * Create storage with ones
74
86
  */
75
87
  static ones(shape: number[], dtype?: DType): ArrayStorage;
76
- /**
77
- * Compute strides for row-major (C-order) layout
78
- * @private
79
- */
80
- private _computeStrides;
81
88
  /**
82
89
  * Compute strides for row-major (C-order) layout
83
90
  * @private
@@ -3,6 +3,6 @@
3
3
  *
4
4
  * @module numpy-ts
5
5
  */
6
- export { NDArray, zeros, ones, array, arange, linspace, logspace, geomspace, eye, empty, full, identity, asarray, copy, zeros_like, ones_like, empty_like, full_like, sqrt, power, absolute, negative, sign, mod, floor_divide, positive, reciprocal, } from './core/ndarray';
6
+ export { NDArray, zeros, ones, array, arange, linspace, logspace, geomspace, eye, empty, full, identity, asarray, copy, zeros_like, ones_like, empty_like, full_like, sqrt, power, absolute, negative, sign, mod, floor_divide, positive, reciprocal, dot, trace, transpose, inner, outer, tensordot, } from './core/ndarray';
7
7
  export declare const __version__: string;
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -7,9 +7,18 @@
7
7
  * @internal
8
8
  */
9
9
  import { ArrayStorage } from '../core/storage';
10
+ /**
11
+ * Compute the broadcast shape of two arrays
12
+ * Returns the shape that results from broadcasting a and b together
13
+ * Throws if shapes are not compatible for broadcasting
14
+ */
15
+ export declare function broadcastShapes(shapeA: readonly number[], shapeB: readonly number[]): number[];
10
16
  /**
11
17
  * Perform element-wise operation with broadcasting
12
18
  *
19
+ * NOTE: This is the slow path for broadcasting/non-contiguous arrays.
20
+ * Fast paths for contiguous arrays are implemented directly in ops/arithmetic.ts
21
+ *
13
22
  * @param a - First array storage
14
23
  * @param b - Second array storage
15
24
  * @param op - Operation to perform (a, b) => result