@thi.ng/tensors 0.5.0 → 0.6.1
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/CHANGELOG.md +9 -1
- package/README.md +2 -2
- package/defoprt.d.ts +5 -5
- package/defoprt.js +6 -5
- package/defoprtt.d.ts +7 -6
- package/defoprtt.js +6 -5
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/mean.d.ts +8 -0
- package/mean.js +5 -0
- package/package.json +14 -11
- package/swap.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2025-
|
|
3
|
+
- **Last updated**: 2025-06-09T17:24:08Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -11,6 +11,14 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
11
11
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
12
12
|
and/or version bumps of transitive dependencies.
|
|
13
13
|
|
|
14
|
+
## [0.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/tensors@0.6.0) (2025-06-05)
|
|
15
|
+
|
|
16
|
+
#### 🚀 Features
|
|
17
|
+
|
|
18
|
+
- update defOpRT()/defOpRTT() ([8099abc](https://github.com/thi-ng/umbrella/commit/8099abc))
|
|
19
|
+
- add optional `complete` fn to produce/transform final result (reducer like)
|
|
20
|
+
- add mean() tensor op ([2f15d21](https://github.com/thi-ng/umbrella/commit/2f15d21))
|
|
21
|
+
|
|
14
22
|
## [0.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/tensors@0.5.0) (2025-05-28)
|
|
15
23
|
|
|
16
24
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 209 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
|
@@ -218,7 +218,7 @@ For Node.js REPL:
|
|
|
218
218
|
const ten = await import("@thi.ng/tensors");
|
|
219
219
|
```
|
|
220
220
|
|
|
221
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 9.
|
|
221
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 9.48 KB
|
|
222
222
|
|
|
223
223
|
## Dependencies
|
|
224
224
|
|
package/defoprt.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { TensorData, TensorOpRT } from "./api.js";
|
|
1
|
+
import type { ITensor, TensorData, TensorOpRT } from "./api.js";
|
|
3
2
|
/**
|
|
4
3
|
* Higher order tensor reduction op factory. Takes given reduction `rfn` and
|
|
5
|
-
* `init` function to produce an initial result
|
|
6
|
-
* applying the given
|
|
4
|
+
* `init` function to produce an initial result and optional `complete` to
|
|
5
|
+
* produce the final result. Returns a {@link TensorOpRT} applying the given
|
|
6
|
+
* function component-wise.
|
|
7
7
|
*
|
|
8
8
|
* @param rfn
|
|
9
9
|
* @param init
|
|
10
10
|
*/
|
|
11
|
-
export declare const defOpRT: <A = number, B = A>(rfn: (acc: B, data: TensorData<A>, i: number) => B, init:
|
|
11
|
+
export declare const defOpRT: <A = number, B = A>(rfn: (acc: B, data: TensorData<A>, i: number) => B, init: () => B, complete?: (acc: B, a: ITensor<A>) => B) => import("./api.js").MultiTensorOpImpl<TensorOpRT<A, B>>;
|
|
12
12
|
//# sourceMappingURL=defoprt.d.ts.map
|
package/defoprt.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { identity } from "@thi.ng/api/fn";
|
|
1
2
|
import { top } from "./top.js";
|
|
2
|
-
const defOpRT = (rfn, init) => {
|
|
3
|
+
const defOpRT = (rfn, init, complete = identity) => {
|
|
3
4
|
const f1 = (a) => {
|
|
4
5
|
const {
|
|
5
6
|
data,
|
|
@@ -11,7 +12,7 @@ const defOpRT = (rfn, init) => {
|
|
|
11
12
|
for (let x = 0; x < sx; x++) {
|
|
12
13
|
res = rfn(res, data, offset + x * tx);
|
|
13
14
|
}
|
|
14
|
-
return res;
|
|
15
|
+
return complete(res, a);
|
|
15
16
|
};
|
|
16
17
|
const f2 = (a) => {
|
|
17
18
|
const {
|
|
@@ -28,7 +29,7 @@ const defOpRT = (rfn, init) => {
|
|
|
28
29
|
res = rfn(res, data, ox + y * ty);
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
return res;
|
|
32
|
+
return complete(res, a);
|
|
32
33
|
};
|
|
33
34
|
const f3 = (a) => {
|
|
34
35
|
const {
|
|
@@ -48,7 +49,7 @@ const defOpRT = (rfn, init) => {
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
|
-
return res;
|
|
52
|
+
return complete(res, a);
|
|
52
53
|
};
|
|
53
54
|
const f4 = (a) => {
|
|
54
55
|
const {
|
|
@@ -71,7 +72,7 @@ const defOpRT = (rfn, init) => {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
|
-
return res;
|
|
75
|
+
return complete(res, a);
|
|
75
76
|
};
|
|
76
77
|
return top(
|
|
77
78
|
0,
|
package/defoprtt.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { TensorData, TensorOpRTT } from "./api.js";
|
|
1
|
+
import type { ITensor, TensorData, TensorOpRTT } from "./api.js";
|
|
3
2
|
/**
|
|
4
3
|
* Higher order tensor reduction op factory. Takes given reduction `rfn` and
|
|
5
|
-
* `init` function to produce an initial result
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* `init` function to produce an initial result and optional `complete` to
|
|
5
|
+
* produce the final result. Returns a {@link TensorOpRTT} applying the given
|
|
6
|
+
* function componentwise, by default with broadcasting rules (see
|
|
7
|
+
* {@link broadcast} for details).
|
|
8
8
|
*
|
|
9
9
|
* @param rfn
|
|
10
10
|
* @param init
|
|
11
|
+
* @param complete
|
|
11
12
|
* @param useBroadcast
|
|
12
13
|
*/
|
|
13
|
-
export declare const defOpRTT: <A = number, B = A>(rfn: (acc: B, adata: TensorData<A>, bdata: TensorData<A>, ia: number, ib: number) => B, init:
|
|
14
|
+
export declare const defOpRTT: <A = number, B = A>(rfn: (acc: B, adata: TensorData<A>, bdata: TensorData<A>, ia: number, ib: number) => B, init: () => B, complete?: (acc: B, a: ITensor<A>, b: ITensor<A>) => B, useBroadcast?: boolean) => TensorOpRTT<A, B>;
|
|
14
15
|
//# sourceMappingURL=defoprtt.d.ts.map
|
package/defoprtt.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { identity } from "@thi.ng/api/fn";
|
|
1
2
|
import { broadcast } from "./broadcast.js";
|
|
2
|
-
const defOpRTT = (rfn, init, useBroadcast = true) => {
|
|
3
|
+
const defOpRTT = (rfn, init, complete = identity, useBroadcast = true) => {
|
|
3
4
|
const f1 = (a, b) => {
|
|
4
5
|
const {
|
|
5
6
|
data: adata,
|
|
@@ -16,7 +17,7 @@ const defOpRTT = (rfn, init, useBroadcast = true) => {
|
|
|
16
17
|
for (let x = 0; x < sx; x++) {
|
|
17
18
|
res = rfn(res, adata, bdata, oa + x * txa, ob + x * txb);
|
|
18
19
|
}
|
|
19
|
-
return res;
|
|
20
|
+
return complete(res, a, b);
|
|
20
21
|
};
|
|
21
22
|
const f2 = (a, b) => {
|
|
22
23
|
const {
|
|
@@ -39,7 +40,7 @@ const defOpRTT = (rfn, init, useBroadcast = true) => {
|
|
|
39
40
|
res = rfn(res, adata, bdata, oax + y * tya, obx + y * tyb);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
|
-
return res;
|
|
43
|
+
return complete(res, a, b);
|
|
43
44
|
};
|
|
44
45
|
const f3 = (a, b) => {
|
|
45
46
|
const {
|
|
@@ -66,7 +67,7 @@ const defOpRTT = (rfn, init, useBroadcast = true) => {
|
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
|
-
return res;
|
|
70
|
+
return complete(res, a, b);
|
|
70
71
|
};
|
|
71
72
|
const f4 = (a, b) => {
|
|
72
73
|
const {
|
|
@@ -103,7 +104,7 @@ const defOpRTT = (rfn, init, useBroadcast = true) => {
|
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
|
-
return res;
|
|
107
|
+
return complete(res, a, b);
|
|
107
108
|
};
|
|
108
109
|
const impls = [, f1, f2, f3, f4];
|
|
109
110
|
const wrapper = useBroadcast ? (a, b) => {
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/mean.d.ts
ADDED
package/mean.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/tensors",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "1D/2D/3D/4D tensors with extensible polymorphic operations and customizable storage",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -39,15 +39,15 @@
|
|
|
39
39
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@thi.ng/api": "^8.11.
|
|
43
|
-
"@thi.ng/arrays": "^2.11.
|
|
44
|
-
"@thi.ng/checks": "^3.7.
|
|
45
|
-
"@thi.ng/equiv": "^2.1.
|
|
46
|
-
"@thi.ng/errors": "^2.5.
|
|
47
|
-
"@thi.ng/math": "^5.11.
|
|
48
|
-
"@thi.ng/random": "^4.1.
|
|
49
|
-
"@thi.ng/strings": "^3.9.
|
|
50
|
-
"@thi.ng/vectors": "^8.
|
|
42
|
+
"@thi.ng/api": "^8.11.29",
|
|
43
|
+
"@thi.ng/arrays": "^2.11.2",
|
|
44
|
+
"@thi.ng/checks": "^3.7.9",
|
|
45
|
+
"@thi.ng/equiv": "^2.1.85",
|
|
46
|
+
"@thi.ng/errors": "^2.5.35",
|
|
47
|
+
"@thi.ng/math": "^5.11.29",
|
|
48
|
+
"@thi.ng/random": "^4.1.20",
|
|
49
|
+
"@thi.ng/strings": "^3.9.14",
|
|
50
|
+
"@thi.ng/vectors": "^8.3.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"esbuild": "^0.25.5",
|
|
@@ -218,6 +218,9 @@
|
|
|
218
218
|
"./maxn": {
|
|
219
219
|
"default": "./maxn.js"
|
|
220
220
|
},
|
|
221
|
+
"./mean": {
|
|
222
|
+
"default": "./mean.js"
|
|
223
|
+
},
|
|
221
224
|
"./min": {
|
|
222
225
|
"default": "./min.js"
|
|
223
226
|
},
|
|
@@ -322,5 +325,5 @@
|
|
|
322
325
|
"status": "alpha",
|
|
323
326
|
"year": 2018
|
|
324
327
|
},
|
|
325
|
-
"gitHead": "
|
|
328
|
+
"gitHead": "93cdcd8db4d4669561a7f0ebc47697bdbfd04214\n"
|
|
326
329
|
}
|