@danielsimonjr/mathts-tensor 0.2.2 → 0.2.3
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/dist/index.d.ts +9 -8
- package/dist/index.js +6 -10
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -78,14 +78,15 @@ declare function idx(dim: number, name?: string, opts?: Omit<IndexOpts, 'name'>)
|
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
80
|
* Tensor — rank-N, Float64Array-backed, row-major dense tensor. The
|
|
81
|
-
* compute primitive behind @danielsimonjr/mathts-tensor. Construction
|
|
82
|
-
* elementwise
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
81
|
+
* compute primitive behind @danielsimonjr/mathts-tensor. Construction,
|
|
82
|
+
* elementwise, einsum, matMul, transpose, reshape live here.
|
|
83
|
+
*
|
|
84
|
+
* Element-wise and data-movement ops are straightforward O(n) loops (a
|
|
85
|
+
* correctness baseline). Heavy ops delegate to the standard packages rather
|
|
86
|
+
* than reinventing them: `matMul` uses matrix's backend-selected multiply
|
|
87
|
+
* (SIMD-WASM for large inputs), and the decompositions (in `operations/`)
|
|
88
|
+
* route through matrix's `svd`/`eig`/`lu`/`qr`/`cholesky`. Storage mirrors
|
|
89
|
+
* DenseMatrix (Float64Array, row-major), generalised to arbitrary rank.
|
|
89
90
|
*/
|
|
90
91
|
|
|
91
92
|
type NestedArray = number | NestedArray[];
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/Tensor.ts
|
|
2
|
-
import { DenseMatrix } from "@danielsimonjr/mathts-matrix";
|
|
2
|
+
import { DenseMatrix, backendManager } from "@danielsimonjr/mathts-matrix";
|
|
3
3
|
var Tensor = class _Tensor {
|
|
4
4
|
shape;
|
|
5
5
|
data;
|
|
@@ -535,15 +535,11 @@ var Tensor = class _Tensor {
|
|
|
535
535
|
const [m, k] = this.shape;
|
|
536
536
|
const [k2, n] = other.shape;
|
|
537
537
|
if (k !== k2) throw new Error(`Tensor.matMul: inner dimension mismatch ${k} != ${k2}`);
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
out[i * n + j] = sum;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
return new _Tensor([m, n], out);
|
|
538
|
+
const c = backendManager.multiply(
|
|
539
|
+
new DenseMatrix(m, k, this.data),
|
|
540
|
+
new DenseMatrix(k, n, other.data)
|
|
541
|
+
);
|
|
542
|
+
return new _Tensor([m, n], c.toFloat64Array());
|
|
547
543
|
}
|
|
548
544
|
static einsum(spec, ...operands) {
|
|
549
545
|
const inStrides = operands.map((o) => _Tensor.rowMajorStrides(o.shape));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielsimonjr/mathts-tensor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Rank-N dense Tensor type for MathTS with Float64Array-backed storage",
|
|
5
5
|
"author": "Daniel Simon Jr.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@danielsimonjr/mathts-core": "^0.3.0",
|
|
35
|
-
"@danielsimonjr/mathts-matrix": "^0.1.
|
|
35
|
+
"@danielsimonjr/mathts-matrix": "^0.1.13"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^25.5.2",
|