@thi.ng/tensors 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.
Files changed (124) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/LICENSE +201 -0
  3. package/README.md +307 -0
  4. package/abs.d.ts +37 -0
  5. package/abs.js +14 -0
  6. package/add.d.ts +42 -0
  7. package/add.js +15 -0
  8. package/addn.d.ts +42 -0
  9. package/addn.js +15 -0
  10. package/api.d.ts +137 -0
  11. package/api.js +0 -0
  12. package/clamp.d.ts +47 -0
  13. package/clamp.js +15 -0
  14. package/clampn.d.ts +47 -0
  15. package/clampn.js +15 -0
  16. package/cos.d.ts +37 -0
  17. package/cos.js +14 -0
  18. package/defopn.d.ts +13 -0
  19. package/defopn.js +65 -0
  20. package/defoprt.d.ts +14 -0
  21. package/defoprt.js +77 -0
  22. package/defoprtt.d.ts +14 -0
  23. package/defoprtt.js +113 -0
  24. package/defopt.d.ts +13 -0
  25. package/defopt.js +109 -0
  26. package/defoptn.d.ts +13 -0
  27. package/defoptn.js +109 -0
  28. package/defoptnn.d.ts +13 -0
  29. package/defoptnn.js +109 -0
  30. package/defoptt.d.ts +13 -0
  31. package/defoptt.js +144 -0
  32. package/defopttt.d.ts +13 -0
  33. package/defopttt.js +177 -0
  34. package/div.d.ts +42 -0
  35. package/div.js +15 -0
  36. package/divn.d.ts +42 -0
  37. package/divn.js +15 -0
  38. package/dot.d.ts +31 -0
  39. package/dot.js +17 -0
  40. package/errors.d.ts +15 -0
  41. package/errors.js +9 -0
  42. package/exp.d.ts +37 -0
  43. package/exp.js +14 -0
  44. package/exp2.d.ts +37 -0
  45. package/exp2.js +14 -0
  46. package/format.d.ts +14 -0
  47. package/format.js +37 -0
  48. package/identity.d.ts +4 -0
  49. package/identity.js +11 -0
  50. package/index.d.ts +60 -0
  51. package/index.js +59 -0
  52. package/log.d.ts +37 -0
  53. package/log.js +14 -0
  54. package/log2.d.ts +37 -0
  55. package/log2.js +14 -0
  56. package/mag.d.ts +3 -0
  57. package/mag.js +5 -0
  58. package/magsq.d.ts +31 -0
  59. package/magsq.js +17 -0
  60. package/max.d.ts +37 -0
  61. package/max.js +14 -0
  62. package/maxn.d.ts +42 -0
  63. package/maxn.js +14 -0
  64. package/min.d.ts +37 -0
  65. package/min.js +14 -0
  66. package/minn.d.ts +42 -0
  67. package/minn.js +14 -0
  68. package/mul.d.ts +42 -0
  69. package/mul.js +15 -0
  70. package/mulm.d.ts +12 -0
  71. package/mulm.js +49 -0
  72. package/muln.d.ts +42 -0
  73. package/muln.js +15 -0
  74. package/mulv.d.ts +11 -0
  75. package/mulv.js +39 -0
  76. package/normalize.d.ts +3 -0
  77. package/normalize.js +11 -0
  78. package/package.json +261 -0
  79. package/pow.d.ts +37 -0
  80. package/pow.js +14 -0
  81. package/pown.d.ts +42 -0
  82. package/pown.js +14 -0
  83. package/product.d.ts +31 -0
  84. package/product.js +15 -0
  85. package/rand-distrib.d.ts +49 -0
  86. package/rand-distrib.js +52 -0
  87. package/relu.d.ts +37 -0
  88. package/relu.js +14 -0
  89. package/relun.d.ts +43 -0
  90. package/relun.js +14 -0
  91. package/select.d.ts +91 -0
  92. package/select.js +111 -0
  93. package/set.d.ts +8 -0
  94. package/set.js +14 -0
  95. package/setn.d.ts +8 -0
  96. package/setn.js +14 -0
  97. package/sigmoid.d.ts +39 -0
  98. package/sigmoid.js +15 -0
  99. package/sin.d.ts +37 -0
  100. package/sin.js +14 -0
  101. package/softmax.d.ts +27 -0
  102. package/softmax.js +10 -0
  103. package/softplus.d.ts +48 -0
  104. package/softplus.js +15 -0
  105. package/sqrt.d.ts +37 -0
  106. package/sqrt.js +14 -0
  107. package/step.d.ts +48 -0
  108. package/step.js +14 -0
  109. package/storage.d.ts +3 -0
  110. package/storage.js +32 -0
  111. package/sub.d.ts +42 -0
  112. package/sub.js +15 -0
  113. package/subn.d.ts +42 -0
  114. package/subn.js +15 -0
  115. package/sum.d.ts +31 -0
  116. package/sum.js +15 -0
  117. package/tan.d.ts +37 -0
  118. package/tan.js +14 -0
  119. package/tanh.d.ts +37 -0
  120. package/tanh.js +14 -0
  121. package/tensor.d.ts +127 -0
  122. package/tensor.js +517 -0
  123. package/top.d.ts +16 -0
  124. package/top.js +15 -0
package/defopt.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import type { Fn } from "@thi.ng/api";
2
+ import type { MultiTensorOpT, TensorOpT } from "./api.js";
3
+ import type { Tensor1, Tensor2, Tensor3, Tensor4 } from "./tensor.js";
4
+ /**
5
+ * Higher order tensor op factory. Takes given `fn` and returns a 4-tuple of
6
+ * {@link TensorOpT}s applying the given function component-wise. The result
7
+ * tuple uses this order: `[polymorphic, 1d, 2d, 3d, 4d]`.
8
+ *
9
+ * @param fn
10
+ * @param dispatch
11
+ */
12
+ export declare const defOpT: <T = number>(fn: Fn<T, T>, dispatch?: number) => [MultiTensorOpT<T>, TensorOpT<T, T, Tensor1<T>, Tensor1<T>>, TensorOpT<T, T, Tensor2<T>, Tensor2<T>>, TensorOpT<T, T, Tensor3<T>, Tensor3<T>>, TensorOpT<T, T, Tensor4<T>, Tensor4<T>>];
13
+ //# sourceMappingURL=defopt.d.ts.map
package/defopt.js ADDED
@@ -0,0 +1,109 @@
1
+ import { top } from "./top.js";
2
+ const defOpT = (fn, dispatch = 1) => {
3
+ const f1 = (out, a) => {
4
+ !out && (out = a);
5
+ const {
6
+ data: odata,
7
+ offset: oo,
8
+ stride: [txo]
9
+ } = out;
10
+ const {
11
+ data: adata,
12
+ offset: oa,
13
+ shape: [sx],
14
+ stride: [txa]
15
+ } = a;
16
+ for (let x = 0; x < sx; x++) {
17
+ odata[oo + x * txo] = fn(adata[oa + x * txa]);
18
+ }
19
+ return out;
20
+ };
21
+ const f2 = (out, a) => {
22
+ !out && (out = a);
23
+ const {
24
+ data: odata,
25
+ offset: oo,
26
+ stride: [txo, tyo]
27
+ } = out;
28
+ const {
29
+ data: adata,
30
+ offset: oa,
31
+ shape: [sx, sy],
32
+ stride: [txa, tya]
33
+ } = a;
34
+ for (let x = 0; x < sx; x++) {
35
+ const oox = oo + x * txo;
36
+ const oax = oa + x * txa;
37
+ for (let y = 0; y < sy; y++) {
38
+ odata[oox + y * tyo] = fn(adata[oax + y * tya]);
39
+ }
40
+ }
41
+ return out;
42
+ };
43
+ const f3 = (out, a) => {
44
+ !out && (out = a);
45
+ const {
46
+ data: odata,
47
+ offset: oo,
48
+ stride: [txo, tyo, tzo]
49
+ } = out;
50
+ const {
51
+ data: adata,
52
+ offset: oa,
53
+ shape: [sx, sy, sz],
54
+ stride: [txa, tya, tza]
55
+ } = a;
56
+ for (let x = 0; x < sx; x++) {
57
+ const oox = oo + x * txo;
58
+ const oax = oa + x * txa;
59
+ for (let y = 0; y < sy; y++) {
60
+ const ooy = oox + y * tyo;
61
+ const oay = oax + y * tya;
62
+ for (let z = 0; z < sz; z++) {
63
+ odata[ooy + z * tzo] = fn(adata[oay + z * tza]);
64
+ }
65
+ }
66
+ }
67
+ return out;
68
+ };
69
+ const f4 = (out, a) => {
70
+ !out && (out = a);
71
+ const {
72
+ data: odata,
73
+ offset: oo,
74
+ stride: [txo, tyo, tzo, two]
75
+ } = out;
76
+ const {
77
+ data: adata,
78
+ offset: oa,
79
+ shape: [sx, sy, sz, sw],
80
+ stride: [txa, tya, tza, twa]
81
+ } = a;
82
+ for (let x = 0; x < sx; x++) {
83
+ const oox = oo + x * txo;
84
+ const oax = oa + x * txa;
85
+ for (let y = 0; y < sy; y++) {
86
+ const ooy = oox + y * tyo;
87
+ const oay = oax + y * tya;
88
+ for (let z = 0; z < sz; z++) {
89
+ const ooz = ooy + z * tzo;
90
+ const oaz = oay + z * tza;
91
+ for (let w = 0; w < sw; w++) {
92
+ odata[ooz + w * two] = fn(adata[oaz + w * twa]);
93
+ }
94
+ }
95
+ }
96
+ }
97
+ return out;
98
+ };
99
+ return [
100
+ top(dispatch, void 0, f1, f2, f3, f4),
101
+ f1,
102
+ f2,
103
+ f3,
104
+ f4
105
+ ];
106
+ };
107
+ export {
108
+ defOpT
109
+ };
package/defoptn.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import type { FnU2 } from "@thi.ng/api";
2
+ import type { MultiTensorOpTN, TensorOpTN } from "./api.js";
3
+ import type { Tensor1, Tensor2, Tensor3, Tensor4 } from "./tensor.js";
4
+ /**
5
+ * Higher order tensor op factory. Takes given `fn` and returns a 4-tuple of
6
+ * {@link TensorOpTN}s applying the given function component-wise. The result
7
+ * tuple uses this order: `[polymorphic, 1d, 2d, 3d, 4d]`.
8
+ *
9
+ * @param fn
10
+ * @param dispatch
11
+ */
12
+ export declare const defOpTN: <T = number>(fn: FnU2<T>, dispatch?: number) => [MultiTensorOpTN<T>, TensorOpTN<T, T, Tensor1<T>, Tensor1<T>>, TensorOpTN<T, T, Tensor2<T>, Tensor2<T>>, TensorOpTN<T, T, Tensor3<T>, Tensor3<T>>, TensorOpTN<T, T, Tensor4<T>, Tensor4<T>>];
13
+ //# sourceMappingURL=defoptn.d.ts.map
package/defoptn.js ADDED
@@ -0,0 +1,109 @@
1
+ import { top } from "./top.js";
2
+ const defOpTN = (fn, dispatch = 1) => {
3
+ const f1 = (out, a, n) => {
4
+ !out && (out = a);
5
+ const {
6
+ data: odata,
7
+ offset: oo,
8
+ stride: [txo]
9
+ } = out;
10
+ const {
11
+ data: adata,
12
+ offset: oa,
13
+ shape: [sx],
14
+ stride: [txa]
15
+ } = a;
16
+ for (let x = 0; x < sx; x++) {
17
+ odata[oo + x * txo] = fn(adata[oa + x * txa], n);
18
+ }
19
+ return out;
20
+ };
21
+ const f2 = (out, a, n) => {
22
+ !out && (out = a);
23
+ const {
24
+ data: odata,
25
+ offset: oo,
26
+ stride: [txo, tyo]
27
+ } = out;
28
+ const {
29
+ data: adata,
30
+ offset: oa,
31
+ shape: [sx, sy],
32
+ stride: [txa, tya]
33
+ } = a;
34
+ for (let x = 0; x < sx; x++) {
35
+ const oox = oo + x * txo;
36
+ const oax = oa + x * txa;
37
+ for (let y = 0; y < sy; y++) {
38
+ odata[oox + y * tyo] = fn(adata[oax + y * tya], n);
39
+ }
40
+ }
41
+ return out;
42
+ };
43
+ const f3 = (out, a, n) => {
44
+ !out && (out = a);
45
+ const {
46
+ data: odata,
47
+ offset: oo,
48
+ stride: [txo, tyo, tzo]
49
+ } = out;
50
+ const {
51
+ data: adata,
52
+ offset: oa,
53
+ shape: [sx, sy, sz],
54
+ stride: [txa, tya, tza]
55
+ } = a;
56
+ for (let x = 0; x < sx; x++) {
57
+ const oox = oo + x * txo;
58
+ const oax = oa + x * txa;
59
+ for (let y = 0; y < sy; y++) {
60
+ const ooy = oox + y * tyo;
61
+ const oay = oax + y * tya;
62
+ for (let z = 0; z < sz; z++) {
63
+ odata[ooy + z * tzo] = fn(adata[oay + z * tza], n);
64
+ }
65
+ }
66
+ }
67
+ return out;
68
+ };
69
+ const f4 = (out, a, n) => {
70
+ !out && (out = a);
71
+ const {
72
+ data: odata,
73
+ offset: oo,
74
+ stride: [txo, tyo, tzo, two]
75
+ } = out;
76
+ const {
77
+ data: adata,
78
+ offset: oa,
79
+ shape: [sx, sy, sz, sw],
80
+ stride: [txa, tya, tza, twa]
81
+ } = a;
82
+ for (let x = 0; x < sx; x++) {
83
+ const oox = oo + x * txo;
84
+ const oax = oa + x * txa;
85
+ for (let y = 0; y < sy; y++) {
86
+ const ooy = oox + y * tyo;
87
+ const oay = oax + y * tya;
88
+ for (let z = 0; z < sz; z++) {
89
+ const ooz = ooy + z * tzo;
90
+ const oaz = oay + z * tza;
91
+ for (let w = 0; w < sw; w++) {
92
+ odata[ooz + w * two] = fn(adata[oaz + w * twa], n);
93
+ }
94
+ }
95
+ }
96
+ }
97
+ return out;
98
+ };
99
+ return [
100
+ top(dispatch, void 0, f1, f2, f3, f4),
101
+ f1,
102
+ f2,
103
+ f3,
104
+ f4
105
+ ];
106
+ };
107
+ export {
108
+ defOpTN
109
+ };
package/defoptnn.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import type { FnU3 } from "@thi.ng/api";
2
+ import type { MultiTensorOpTNN, TensorOpTNN } from "./api.js";
3
+ import type { Tensor1, Tensor2, Tensor3, Tensor4 } from "./tensor.js";
4
+ /**
5
+ * Higher order tensor op factory. Takes given `fn` and returns a 4-tuple of
6
+ * {@link TensorOpTNN}s applying the given function component-wise. The result
7
+ * tuple uses this order: `[polymorphic, 1d, 2d, 3d, 4d]`.
8
+ *
9
+ * @param fn
10
+ * @param dispatch
11
+ */
12
+ export declare const defOpTNN: <T = number>(fn: FnU3<T>, dispatch?: number) => [MultiTensorOpTNN<T>, TensorOpTNN<T, T, Tensor1<T>, Tensor1<T>>, TensorOpTNN<T, T, Tensor2<T>, Tensor2<T>>, TensorOpTNN<T, T, Tensor3<T>, Tensor3<T>>, TensorOpTNN<T, T, Tensor4<T>, Tensor4<T>>];
13
+ //# sourceMappingURL=defoptnn.d.ts.map
package/defoptnn.js ADDED
@@ -0,0 +1,109 @@
1
+ import { top } from "./top.js";
2
+ const defOpTNN = (fn, dispatch = 1) => {
3
+ const f1 = (out, a, n, m) => {
4
+ !out && (out = a);
5
+ const {
6
+ data: odata,
7
+ offset: oo,
8
+ stride: [txo]
9
+ } = out;
10
+ const {
11
+ data: adata,
12
+ offset: oa,
13
+ shape: [sx],
14
+ stride: [txa]
15
+ } = a;
16
+ for (let x = 0; x < sx; x++) {
17
+ odata[oo + x * txo] = fn(adata[oa + x * txa], n, m);
18
+ }
19
+ return out;
20
+ };
21
+ const f2 = (out, a, n, m) => {
22
+ !out && (out = a);
23
+ const {
24
+ data: odata,
25
+ offset: oo,
26
+ stride: [txo, tyo]
27
+ } = out;
28
+ const {
29
+ data: adata,
30
+ offset: oa,
31
+ shape: [sx, sy],
32
+ stride: [txa, tya]
33
+ } = a;
34
+ for (let x = 0; x < sx; x++) {
35
+ const oox = oo + x * txo;
36
+ const oax = oa + x * txa;
37
+ for (let y = 0; y < sy; y++) {
38
+ odata[oox + y * tyo] = fn(adata[oax + y * tya], n, m);
39
+ }
40
+ }
41
+ return out;
42
+ };
43
+ const f3 = (out, a, n, m) => {
44
+ !out && (out = a);
45
+ const {
46
+ data: odata,
47
+ offset: oo,
48
+ stride: [txo, tyo, tzo]
49
+ } = out;
50
+ const {
51
+ data: adata,
52
+ offset: oa,
53
+ shape: [sx, sy, sz],
54
+ stride: [txa, tya, tza]
55
+ } = a;
56
+ for (let x = 0; x < sx; x++) {
57
+ const oox = oo + x * txo;
58
+ const oax = oa + x * txa;
59
+ for (let y = 0; y < sy; y++) {
60
+ const ooy = oox + y * tyo;
61
+ const oay = oax + y * tya;
62
+ for (let z = 0; z < sz; z++) {
63
+ odata[ooy + z * tzo] = fn(adata[oay + z * tza], n, m);
64
+ }
65
+ }
66
+ }
67
+ return out;
68
+ };
69
+ const f4 = (out, a, n, m) => {
70
+ !out && (out = a);
71
+ const {
72
+ data: odata,
73
+ offset: oo,
74
+ stride: [txo, tyo, tzo, two]
75
+ } = out;
76
+ const {
77
+ data: adata,
78
+ offset: oa,
79
+ shape: [sx, sy, sz, sw],
80
+ stride: [txa, tya, tza, twa]
81
+ } = a;
82
+ for (let x = 0; x < sx; x++) {
83
+ const oox = oo + x * txo;
84
+ const oax = oa + x * txa;
85
+ for (let y = 0; y < sy; y++) {
86
+ const ooy = oox + y * tyo;
87
+ const oay = oax + y * tya;
88
+ for (let z = 0; z < sz; z++) {
89
+ const ooz = ooy + z * tzo;
90
+ const oaz = oay + z * tza;
91
+ for (let w = 0; w < sw; w++) {
92
+ odata[ooz + w * two] = fn(adata[oaz + w * twa], n, m);
93
+ }
94
+ }
95
+ }
96
+ }
97
+ return out;
98
+ };
99
+ return [
100
+ top(dispatch, void 0, f1, f2, f3, f4),
101
+ f1,
102
+ f2,
103
+ f3,
104
+ f4
105
+ ];
106
+ };
107
+ export {
108
+ defOpTNN
109
+ };
package/defoptt.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import type { FnU2 } from "@thi.ng/api";
2
+ import type { MultiTensorOpTT, TensorOpTT } from "./api.js";
3
+ import type { Tensor1, Tensor2, Tensor3, Tensor4 } from "./tensor.js";
4
+ /**
5
+ * Higher order tensor op factory. Takes given `fn` and returns a 4-tuple of
6
+ * {@link TensorOpTT}s applying the given function component-wise. The result
7
+ * tuple uses this order: `[polymorphic, 1d, 2d, 3d, 4d]`.
8
+ *
9
+ * @param fn
10
+ * @param dispatch
11
+ */
12
+ export declare const defOpTT: <T = number>(fn: FnU2<T>, dispatch?: number) => [MultiTensorOpTT<T>, TensorOpTT<T, T, Tensor1<T>, Tensor1<T>>, TensorOpTT<T, T, Tensor2<T>, Tensor2<T>>, TensorOpTT<T, T, Tensor3<T>, Tensor3<T>>, TensorOpTT<T, T, Tensor4<T>, Tensor4<T>>];
13
+ //# sourceMappingURL=defoptt.d.ts.map
package/defoptt.js ADDED
@@ -0,0 +1,144 @@
1
+ import { top } from "./top.js";
2
+ const defOpTT = (fn, dispatch = 1) => {
3
+ const f1 = (out, a, b) => {
4
+ !out && (out = a);
5
+ const {
6
+ data: odata,
7
+ offset: oo,
8
+ stride: [txo]
9
+ } = out;
10
+ const {
11
+ data: adata,
12
+ offset: oa,
13
+ shape: [sx],
14
+ stride: [txa]
15
+ } = a;
16
+ const {
17
+ data: bdata,
18
+ offset: ob,
19
+ stride: [txb]
20
+ } = b;
21
+ for (let x = 0; x < sx; x++) {
22
+ odata[oo + x * txo] = fn(adata[oa + x * txa], bdata[ob + x * txb]);
23
+ }
24
+ return out;
25
+ };
26
+ const f2 = (out, a, b) => {
27
+ !out && (out = a);
28
+ const {
29
+ data: odata,
30
+ offset: oo,
31
+ stride: [txo, tyo]
32
+ } = out;
33
+ const {
34
+ data: adata,
35
+ offset: oa,
36
+ shape: [sx, sy],
37
+ stride: [txa, tya]
38
+ } = a;
39
+ const {
40
+ data: bdata,
41
+ offset: ob,
42
+ stride: [txb, tyb]
43
+ } = b;
44
+ for (let x = 0; x < sx; x++) {
45
+ const oox = oo + x * txo;
46
+ const oax = oa + x * txa;
47
+ const obx = ob + x * txb;
48
+ for (let y = 0; y < sy; y++) {
49
+ odata[oox + y * tyo] = fn(
50
+ adata[oax + y * tya],
51
+ bdata[obx + y * tyb]
52
+ );
53
+ }
54
+ }
55
+ return out;
56
+ };
57
+ const f3 = (out, a, b) => {
58
+ !out && (out = a);
59
+ const {
60
+ data: odata,
61
+ offset: oo,
62
+ stride: [txo, tyo, tzo]
63
+ } = out;
64
+ const {
65
+ data: adata,
66
+ offset: oa,
67
+ shape: [sx, sy, sz],
68
+ stride: [txa, tya, tza]
69
+ } = a;
70
+ const {
71
+ data: bdata,
72
+ offset: ob,
73
+ stride: [txb, tyb, tzb]
74
+ } = b;
75
+ for (let x = 0; x < sx; x++) {
76
+ const oox = oo + x * txo;
77
+ const oax = oa + x * txa;
78
+ const obx = ob + x * txb;
79
+ for (let y = 0; y < sy; y++) {
80
+ const ooy = oox + y * tyo;
81
+ const oay = oax + y * tya;
82
+ const oby = obx + y * tyb;
83
+ for (let z = 0; z < sz; z++) {
84
+ odata[ooy + z * tzo] = fn(
85
+ adata[oay + z * tza],
86
+ bdata[oby + z * tzb]
87
+ );
88
+ }
89
+ }
90
+ }
91
+ return out;
92
+ };
93
+ const f4 = (out, a, b) => {
94
+ !out && (out = a);
95
+ const {
96
+ data: odata,
97
+ offset: oo,
98
+ stride: [txo, tyo, tzo, two]
99
+ } = out;
100
+ const {
101
+ data: adata,
102
+ offset: oa,
103
+ shape: [sx, sy, sz, sw],
104
+ stride: [txa, tya, tza, twa]
105
+ } = a;
106
+ const {
107
+ data: bdata,
108
+ offset: ob,
109
+ stride: [txb, tyb, tzb, twb]
110
+ } = b;
111
+ for (let x = 0; x < sx; x++) {
112
+ const oox = oo + x * txo;
113
+ const oax = oa + x * txa;
114
+ const obx = ob + x * txb;
115
+ for (let y = 0; y < sy; y++) {
116
+ const ooy = oox + y * tyo;
117
+ const oay = oax + y * tya;
118
+ const oby = obx + y * tyb;
119
+ for (let z = 0; z < sz; z++) {
120
+ const ooz = ooy + z * tzo;
121
+ const oaz = oay + z * tza;
122
+ const obz = oby + z * tzb;
123
+ for (let w = 0; w < sw; w++) {
124
+ odata[ooz + w * two] = fn(
125
+ adata[oaz + w * twa],
126
+ bdata[obz + w * twb]
127
+ );
128
+ }
129
+ }
130
+ }
131
+ }
132
+ return out;
133
+ };
134
+ return [
135
+ top(dispatch, void 0, f1, f2, f3, f4),
136
+ f1,
137
+ f2,
138
+ f3,
139
+ f4
140
+ ];
141
+ };
142
+ export {
143
+ defOpTT
144
+ };
package/defopttt.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import type { FnU3 } from "@thi.ng/api";
2
+ import type { MultiTensorOpTTT, TensorOpTTT } from "./api.js";
3
+ import type { Tensor1, Tensor2, Tensor3, Tensor4 } from "./tensor.js";
4
+ /**
5
+ * Higher order tensor op factory. Takes given `fn` and returns a 4-tuple of
6
+ * {@link TensorOpTTT}s applying the given function component-wise. The result
7
+ * tuple uses this order: `[polymorphic, 1d, 2d, 3d, 4d]`.
8
+ *
9
+ * @param fn
10
+ * @param dispatch
11
+ */
12
+ export declare const defOpTTT: <T = number>(fn: FnU3<T>, dispatch?: number) => [MultiTensorOpTTT<T>, TensorOpTTT<T, T, Tensor1<T>, Tensor1<T>>, TensorOpTTT<T, T, Tensor2<T>, Tensor2<T>>, TensorOpTTT<T, T, Tensor3<T>, Tensor3<T>>, TensorOpTTT<T, T, Tensor4<T>, Tensor4<T>>];
13
+ //# sourceMappingURL=defopttt.d.ts.map