numpy-ts 0.1.0 → 0.2.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/README.md +36 -39
- package/dist/numpy-ts.browser.js +2 -2
- package/dist/numpy-ts.esm.js +2 -2
- package/dist/numpy-ts.node.cjs +2 -2
- package/dist/types/core/ndarray.d.ts +40 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internal/compute.d.ts +9 -0
- package/dist/types/ops/arithmetic.d.ts +59 -0
- package/dist/types/ops/exponential.d.ts +28 -0
- package/package.json +1 -3
|
@@ -97,6 +97,37 @@ export declare class NDArray {
|
|
|
97
97
|
subtract(other: NDArray | number): NDArray;
|
|
98
98
|
multiply(other: NDArray | number): NDArray;
|
|
99
99
|
divide(other: NDArray | number): NDArray;
|
|
100
|
+
mod(other: NDArray | number): NDArray;
|
|
101
|
+
floor_divide(other: NDArray | number): NDArray;
|
|
102
|
+
positive(): NDArray;
|
|
103
|
+
reciprocal(): NDArray;
|
|
104
|
+
/**
|
|
105
|
+
* Square root of each element
|
|
106
|
+
* Promotes integer types to float64
|
|
107
|
+
* @returns New array with square roots
|
|
108
|
+
*/
|
|
109
|
+
sqrt(): NDArray;
|
|
110
|
+
/**
|
|
111
|
+
* Raise elements to power
|
|
112
|
+
* @param exponent - Power to raise to (array or scalar)
|
|
113
|
+
* @returns New array with powered values
|
|
114
|
+
*/
|
|
115
|
+
power(exponent: NDArray | number): NDArray;
|
|
116
|
+
/**
|
|
117
|
+
* Absolute value of each element
|
|
118
|
+
* @returns New array with absolute values
|
|
119
|
+
*/
|
|
120
|
+
absolute(): NDArray;
|
|
121
|
+
/**
|
|
122
|
+
* Numerical negative (element-wise negation)
|
|
123
|
+
* @returns New array with negated values
|
|
124
|
+
*/
|
|
125
|
+
negative(): NDArray;
|
|
126
|
+
/**
|
|
127
|
+
* Sign of each element (-1, 0, or 1)
|
|
128
|
+
* @returns New array with signs
|
|
129
|
+
*/
|
|
130
|
+
sign(): NDArray;
|
|
100
131
|
/**
|
|
101
132
|
* Element-wise greater than comparison
|
|
102
133
|
* @param other - Value or array to compare with
|
|
@@ -318,9 +349,6 @@ export declare function zeros(shape: number[], dtype?: DType): NDArray;
|
|
|
318
349
|
* Create array of ones
|
|
319
350
|
*/
|
|
320
351
|
export declare function ones(shape: number[], dtype?: DType): NDArray;
|
|
321
|
-
/**
|
|
322
|
-
* Create array from nested JavaScript arrays
|
|
323
|
-
*/
|
|
324
352
|
export declare function array(data: any, dtype?: DType): NDArray;
|
|
325
353
|
/**
|
|
326
354
|
* Create array with evenly spaced values within a given interval
|
|
@@ -383,5 +411,14 @@ export declare function empty_like(a: NDArray, dtype?: DType): NDArray;
|
|
|
383
411
|
* Create array filled with a constant value, same shape as another array
|
|
384
412
|
*/
|
|
385
413
|
export declare function full_like(a: NDArray, fill_value: number | bigint | boolean, dtype?: DType): NDArray;
|
|
414
|
+
export declare function sqrt(x: NDArray): NDArray;
|
|
415
|
+
export declare function power(x: NDArray, exponent: NDArray | number): NDArray;
|
|
416
|
+
export declare function absolute(x: NDArray): NDArray;
|
|
417
|
+
export declare function negative(x: NDArray): NDArray;
|
|
418
|
+
export declare function sign(x: NDArray): NDArray;
|
|
419
|
+
export declare function mod(x: NDArray, divisor: NDArray | number): NDArray;
|
|
420
|
+
export declare function floor_divide(x: NDArray, divisor: NDArray | number): NDArray;
|
|
421
|
+
export declare function positive(x: NDArray): NDArray;
|
|
422
|
+
export declare function reciprocal(x: NDArray): NDArray;
|
|
386
423
|
export {};
|
|
387
424
|
//# sourceMappingURL=ndarray.d.ts.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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, } 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, } from './core/ndarray';
|
|
7
7
|
export declare const __version__: string;
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -22,4 +22,13 @@ export declare function elementwiseBinaryOp(a: ArrayStorage, b: ArrayStorage, op
|
|
|
22
22
|
* Returns boolean array (dtype: 'bool', stored as Uint8Array)
|
|
23
23
|
*/
|
|
24
24
|
export declare function elementwiseComparisonOp(a: ArrayStorage, b: ArrayStorage, op: (a: number, b: number) => boolean): ArrayStorage;
|
|
25
|
+
/**
|
|
26
|
+
* Perform element-wise unary operation
|
|
27
|
+
*
|
|
28
|
+
* @param a - Input array storage
|
|
29
|
+
* @param op - Operation to perform (x) => result
|
|
30
|
+
* @param preserveDtype - If true, preserve input dtype; if false, promote to float64 (default: true)
|
|
31
|
+
* @returns Result storage
|
|
32
|
+
*/
|
|
33
|
+
export declare function elementwiseUnaryOp(a: ArrayStorage, op: (x: number) => number, preserveDtype?: boolean): ArrayStorage;
|
|
25
34
|
//# sourceMappingURL=compute.d.ts.map
|
|
@@ -46,4 +46,63 @@ export declare function multiply(a: ArrayStorage, b: ArrayStorage | number): Arr
|
|
|
46
46
|
* @returns Result storage with promoted float dtype
|
|
47
47
|
*/
|
|
48
48
|
export declare function divide(a: ArrayStorage, b: ArrayStorage | number): ArrayStorage;
|
|
49
|
+
/**
|
|
50
|
+
* Absolute value of each element
|
|
51
|
+
* Preserves dtype
|
|
52
|
+
*
|
|
53
|
+
* @param a - Input array storage
|
|
54
|
+
* @returns Result storage with absolute values
|
|
55
|
+
*/
|
|
56
|
+
export declare function absolute(a: ArrayStorage): ArrayStorage;
|
|
57
|
+
/**
|
|
58
|
+
* Numerical negative (element-wise negation)
|
|
59
|
+
* Preserves dtype
|
|
60
|
+
*
|
|
61
|
+
* @param a - Input array storage
|
|
62
|
+
* @returns Result storage with negated values
|
|
63
|
+
*/
|
|
64
|
+
export declare function negative(a: ArrayStorage): ArrayStorage;
|
|
65
|
+
/**
|
|
66
|
+
* Sign of each element (-1, 0, or 1)
|
|
67
|
+
* Preserves dtype
|
|
68
|
+
*
|
|
69
|
+
* @param a - Input array storage
|
|
70
|
+
* @returns Result storage with signs
|
|
71
|
+
*/
|
|
72
|
+
export declare function sign(a: ArrayStorage): ArrayStorage;
|
|
73
|
+
/**
|
|
74
|
+
* Modulo operation (remainder after division)
|
|
75
|
+
* NumPy behavior: Uses floor modulo (sign follows divisor), not JavaScript's truncate modulo
|
|
76
|
+
* Preserves dtype for integer types
|
|
77
|
+
*
|
|
78
|
+
* @param a - Dividend array storage
|
|
79
|
+
* @param b - Divisor (array storage or scalar)
|
|
80
|
+
* @returns Result storage with modulo values
|
|
81
|
+
*/
|
|
82
|
+
export declare function mod(a: ArrayStorage, b: ArrayStorage | number): ArrayStorage;
|
|
83
|
+
/**
|
|
84
|
+
* Floor division (division with result rounded down)
|
|
85
|
+
* NumPy behavior: Preserves integer types
|
|
86
|
+
*
|
|
87
|
+
* @param a - Dividend array storage
|
|
88
|
+
* @param b - Divisor (array storage or scalar)
|
|
89
|
+
* @returns Result storage with floor division values
|
|
90
|
+
*/
|
|
91
|
+
export declare function floorDivide(a: ArrayStorage, b: ArrayStorage | number): ArrayStorage;
|
|
92
|
+
/**
|
|
93
|
+
* Unary positive (returns a copy of the array)
|
|
94
|
+
* Preserves dtype
|
|
95
|
+
*
|
|
96
|
+
* @param a - Input array storage
|
|
97
|
+
* @returns Result storage (copy of input)
|
|
98
|
+
*/
|
|
99
|
+
export declare function positive(a: ArrayStorage): ArrayStorage;
|
|
100
|
+
/**
|
|
101
|
+
* Reciprocal (1/x) of each element
|
|
102
|
+
* NumPy behavior: Always promotes to float64 for integer types
|
|
103
|
+
*
|
|
104
|
+
* @param a - Input array storage
|
|
105
|
+
* @returns Result storage with reciprocal values
|
|
106
|
+
*/
|
|
107
|
+
export declare function reciprocal(a: ArrayStorage): ArrayStorage;
|
|
49
108
|
//# sourceMappingURL=arithmetic.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exponential, logarithmic, and power operations
|
|
3
|
+
*
|
|
4
|
+
* Pure functions for element-wise exponential operations:
|
|
5
|
+
* exp, log, sqrt, power, etc.
|
|
6
|
+
*
|
|
7
|
+
* These functions are used by NDArray methods but are separated
|
|
8
|
+
* to keep the codebase modular and testable.
|
|
9
|
+
*/
|
|
10
|
+
import { ArrayStorage } from '../core/storage';
|
|
11
|
+
/**
|
|
12
|
+
* Square root of each element
|
|
13
|
+
* NumPy behavior: Always promotes to float64 for integer types
|
|
14
|
+
*
|
|
15
|
+
* @param a - Input array storage
|
|
16
|
+
* @returns Result storage with sqrt applied
|
|
17
|
+
*/
|
|
18
|
+
export declare function sqrt(a: ArrayStorage): ArrayStorage;
|
|
19
|
+
/**
|
|
20
|
+
* Raise elements to power
|
|
21
|
+
* NumPy behavior: Promotes to float64 for integer types with non-integer exponents
|
|
22
|
+
*
|
|
23
|
+
* @param a - Base array storage
|
|
24
|
+
* @param b - Exponent (array storage or scalar)
|
|
25
|
+
* @returns Result storage with power applied
|
|
26
|
+
*/
|
|
27
|
+
export declare function power(a: ArrayStorage, b: ArrayStorage | number): ArrayStorage;
|
|
28
|
+
//# sourceMappingURL=exponential.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "numpy-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Complete NumPy implementation for TypeScript and JavaScript (under construction)",
|
|
5
5
|
"main": "dist/numpy-ts.node.cjs",
|
|
6
6
|
"browser": "dist/numpy-ts.browser.js",
|
|
@@ -54,8 +54,6 @@
|
|
|
54
54
|
"bench:build": "esbuild benchmarks/src/index.ts --bundle --platform=node --format=cjs --outfile=benchmarks/dist/bench.cjs",
|
|
55
55
|
"bench": "npm run bench:build && node benchmarks/dist/bench.cjs",
|
|
56
56
|
"bench:quick": "npm run bench:build && node benchmarks/dist/bench.cjs --quick",
|
|
57
|
-
"bench:standard": "npm run bench:build && node benchmarks/dist/bench.cjs --standard",
|
|
58
|
-
"bench:full": "npm run bench:build && node benchmarks/dist/bench.cjs --full",
|
|
59
57
|
"bench:category": "npm run bench:build && node benchmarks/dist/bench.cjs --category",
|
|
60
58
|
"bench:view": "open benchmarks/results/plots/latest.html || xdg-open benchmarks/results/plots/latest.html"
|
|
61
59
|
},
|