@thi.ng/tensors 0.1.0 → 0.3.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 (126) hide show
  1. package/CHANGELOG.md +45 -1
  2. package/README.md +93 -34
  3. package/abs.d.ts +1 -29
  4. package/abs.js +2 -11
  5. package/add.d.ts +4 -35
  6. package/add.js +2 -11
  7. package/addn.d.ts +1 -33
  8. package/addn.js +2 -11
  9. package/api.d.ts +138 -15
  10. package/broadcast.d.ts +24 -0
  11. package/broadcast.js +54 -0
  12. package/clamp.d.ts +4 -38
  13. package/clamp.js +2 -11
  14. package/clampn.d.ts +1 -37
  15. package/clampn.js +2 -11
  16. package/cos.d.ts +1 -29
  17. package/cos.js +2 -11
  18. package/defopn.d.ts +4 -7
  19. package/defopn.js +17 -7
  20. package/defoprt.d.ts +5 -7
  21. package/defoprt.js +21 -11
  22. package/defoprtt.d.ts +7 -7
  23. package/defoprtt.js +30 -26
  24. package/defopt.d.ts +4 -7
  25. package/defopt.js +17 -20
  26. package/defoptn.d.ts +4 -7
  27. package/defoptn.js +17 -20
  28. package/defoptnn.d.ts +4 -7
  29. package/defoptnn.js +20 -16
  30. package/defoptt.d.ts +5 -6
  31. package/defoptt.js +36 -27
  32. package/defopttt.d.ts +5 -7
  33. package/defopttt.js +43 -37
  34. package/diagonal.d.ts +16 -0
  35. package/diagonal.js +18 -0
  36. package/div.d.ts +4 -35
  37. package/div.js +2 -11
  38. package/divn.d.ts +1 -33
  39. package/divn.js +2 -11
  40. package/dot.d.ts +4 -26
  41. package/dot.js +3 -12
  42. package/errors.d.ts +2 -0
  43. package/errors.js +3 -0
  44. package/exp.d.ts +1 -29
  45. package/exp.js +2 -11
  46. package/exp2.d.ts +1 -29
  47. package/exp2.js +2 -11
  48. package/filtered-indices.d.ts +34 -0
  49. package/filtered-indices.js +17 -0
  50. package/identity.d.ts +7 -0
  51. package/identity.js +3 -2
  52. package/index.d.ts +6 -0
  53. package/index.js +6 -0
  54. package/log.d.ts +1 -29
  55. package/log.js +2 -11
  56. package/log2.d.ts +1 -29
  57. package/log2.js +2 -11
  58. package/mag.d.ts +5 -0
  59. package/magsq.d.ts +1 -25
  60. package/magsq.js +3 -12
  61. package/max.d.ts +5 -30
  62. package/max.js +2 -11
  63. package/maxn.d.ts +1 -33
  64. package/maxn.js +2 -11
  65. package/min.d.ts +5 -30
  66. package/min.js +2 -11
  67. package/minn.d.ts +1 -33
  68. package/minn.js +2 -11
  69. package/mul.d.ts +4 -35
  70. package/mul.js +2 -11
  71. package/mulm.d.ts +1 -1
  72. package/mulm.js +21 -20
  73. package/muln.d.ts +1 -33
  74. package/muln.js +2 -11
  75. package/mulv.d.ts +1 -1
  76. package/mulv.js +16 -15
  77. package/normalize.d.ts +9 -1
  78. package/package.json +48 -4
  79. package/pow.d.ts +5 -30
  80. package/pow.js +2 -11
  81. package/pown.d.ts +1 -33
  82. package/pown.js +2 -11
  83. package/product.d.ts +1 -25
  84. package/product.js +5 -12
  85. package/rand-distrib.d.ts +13 -10
  86. package/rand-distrib.js +55 -23
  87. package/range.d.ts +20 -0
  88. package/range.js +28 -0
  89. package/relu.d.ts +1 -29
  90. package/relu.js +2 -11
  91. package/relun.d.ts +1 -33
  92. package/relun.js +2 -11
  93. package/select.d.ts +6 -6
  94. package/select.js +26 -23
  95. package/set.d.ts +1 -6
  96. package/set.js +3 -11
  97. package/setn.d.ts +1 -6
  98. package/setn.js +3 -11
  99. package/sigmoid.d.ts +1 -29
  100. package/sigmoid.js +2 -11
  101. package/sin.d.ts +1 -29
  102. package/sin.js +2 -11
  103. package/softmax.d.ts +1 -1
  104. package/softplus.d.ts +1 -33
  105. package/softplus.js +2 -11
  106. package/sqrt.d.ts +1 -29
  107. package/sqrt.js +2 -11
  108. package/step.d.ts +1 -33
  109. package/step.js +2 -11
  110. package/sub.d.ts +4 -35
  111. package/sub.js +2 -11
  112. package/subn.d.ts +1 -33
  113. package/subn.js +2 -11
  114. package/sum.d.ts +1 -25
  115. package/sum.js +5 -12
  116. package/svd.d.ts +33 -0
  117. package/svd.js +246 -0
  118. package/swap.d.ts +26 -0
  119. package/swap.js +15 -0
  120. package/tan.d.ts +1 -29
  121. package/tan.js +2 -11
  122. package/tanh.d.ts +1 -29
  123. package/tanh.js +2 -11
  124. package/tensor.d.ts +6 -1
  125. package/tensor.js +58 -21
  126. package/top.d.ts +2 -6
package/errors.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { NumericArray } from "@thi.ng/api";
2
+ import type { ITensor } from "./api.js";
2
3
  export declare const IllegalShapeError: {
3
4
  new (msg?: NumericArray | undefined): {
4
5
  origMessage: string;
@@ -12,4 +13,5 @@ export declare const IllegalShapeError: {
12
13
  stackTraceLimit: number;
13
14
  };
14
15
  export declare const illegalShape: (shape: NumericArray) => never;
16
+ export declare const ensureShape: (t: ITensor<any>, shape: number[]) => false;
15
17
  //# sourceMappingURL=errors.d.ts.map
package/errors.js CHANGED
@@ -1,9 +1,12 @@
1
1
  import { defError } from "@thi.ng/errors/deferror";
2
+ import { equals } from "@thi.ng/vectors/equals";
2
3
  const IllegalShapeError = defError(() => "illegal shape");
3
4
  const illegalShape = (shape) => {
4
5
  throw new IllegalShapeError(shape);
5
6
  };
7
+ const ensureShape = (t, shape) => !equals(t.shape, shape) && illegalShape(t.shape);
6
8
  export {
7
9
  IllegalShapeError,
10
+ ensureShape,
8
11
  illegalShape
9
12
  };
package/exp.d.ts CHANGED
@@ -5,33 +5,5 @@
5
5
  * @param out - output tensor
6
6
  * @param a - input tensor
7
7
  */
8
- export declare const exp: import("./api.js").MultiTensorOpT<number>;
9
- /**
10
- * Same as {@link exp} for 1D tensors.
11
- *
12
- * @param out - output tensor
13
- * @param a - input tensor
14
- */
15
- export declare const exp_1: import("./api.js").TensorOpT<number, number, import("./tensor.js").Tensor1<number>, import("./tensor.js").Tensor1<number>>;
16
- /**
17
- * Same as {@link exp} for 2D tensors.
18
- *
19
- * @param out - output tensor
20
- * @param a - input tensor
21
- */
22
- export declare const exp_2: import("./api.js").TensorOpT<number, number, import("./tensor.js").Tensor2<number>, import("./tensor.js").Tensor2<number>>;
23
- /**
24
- * Same as {@link exp} for 3D tensors.
25
- *
26
- * @param out - output tensor
27
- * @param a - input tensor
28
- */
29
- export declare const exp_3: import("./api.js").TensorOpT<number, number, import("./tensor.js").Tensor3<number>, import("./tensor.js").Tensor3<number>>;
30
- /**
31
- * Same as {@link exp} for 4D tensors.
32
- *
33
- * @param out - output tensor
34
- * @param a - input tensor
35
- */
36
- export declare const exp_4: import("./api.js").TensorOpT<number, number, import("./tensor.js").Tensor4<number>, import("./tensor.js").Tensor4<number>>;
8
+ export declare const exp: import("./api.js").MultiTensorOpImpl<import("./api.js").TensorOpT<number>>;
37
9
  //# sourceMappingURL=exp.d.ts.map
package/exp.js CHANGED
@@ -1,14 +1,5 @@
1
1
  import { defOpT } from "./defopt.js";
2
- const [a, b, c, d, e] = defOpT(Math.exp);
3
- const exp = a;
4
- const exp_1 = b;
5
- const exp_2 = c;
6
- const exp_3 = d;
7
- const exp_4 = e;
2
+ const exp = defOpT(Math.exp);
8
3
  export {
9
- exp,
10
- exp_1,
11
- exp_2,
12
- exp_3,
13
- exp_4
4
+ exp
14
5
  };
package/exp2.d.ts CHANGED
@@ -5,33 +5,5 @@
5
5
  * @param out - output tensor
6
6
  * @param a - input tensor
7
7
  */
8
- export declare const exp2: import("./api.js").MultiTensorOpT<number>;
9
- /**
10
- * Same as {@link exp2} for 1D tensors.
11
- *
12
- * @param out - output tensor
13
- * @param a - input tensor
14
- */
15
- export declare const exp2_1: import("./api.js").TensorOpT<number, number, import("./tensor.js").Tensor1<number>, import("./tensor.js").Tensor1<number>>;
16
- /**
17
- * Same as {@link exp2} for 2D tensors.
18
- *
19
- * @param out - output tensor
20
- * @param a - input tensor
21
- */
22
- export declare const exp2_2: import("./api.js").TensorOpT<number, number, import("./tensor.js").Tensor2<number>, import("./tensor.js").Tensor2<number>>;
23
- /**
24
- * Same as {@link exp2} for 3D tensors.
25
- *
26
- * @param out - output tensor
27
- * @param a - input tensor
28
- */
29
- export declare const exp2_3: import("./api.js").TensorOpT<number, number, import("./tensor.js").Tensor3<number>, import("./tensor.js").Tensor3<number>>;
30
- /**
31
- * Same as {@link exp2} for 4D tensors.
32
- *
33
- * @param out - output tensor
34
- * @param a - input tensor
35
- */
36
- export declare const exp2_4: import("./api.js").TensorOpT<number, number, import("./tensor.js").Tensor4<number>, import("./tensor.js").Tensor4<number>>;
8
+ export declare const exp2: import("./api.js").MultiTensorOpImpl<import("./api.js").TensorOpT<number>>;
37
9
  //# sourceMappingURL=exp2.d.ts.map
package/exp2.js CHANGED
@@ -1,14 +1,5 @@
1
1
  import { defOpT } from "./defopt.js";
2
- const [a, b, c, d, e] = defOpT((x) => 2 ** x);
3
- const exp2 = a;
4
- const exp2_1 = b;
5
- const exp2_2 = c;
6
- const exp2_3 = d;
7
- const exp2_4 = e;
2
+ const exp2 = defOpT((x) => 2 ** x);
8
3
  export {
9
- exp2,
10
- exp2_1,
11
- exp2_2,
12
- exp2_3,
13
- exp2_4
4
+ exp2
14
5
  };
@@ -0,0 +1,34 @@
1
+ import type { Predicate } from "@thi.ng/api";
2
+ /**
3
+ * Higher order function. Takes a predicate function and returns a new function
4
+ * which accepts a tensor and then returns an array of tensor component indices
5
+ * for which the predicate passed.
6
+ *
7
+ * @remarks
8
+ * Also see {@link nonZeroIndices}.
9
+ *
10
+ * @param pred
11
+ */
12
+ export declare const filteredIndices: <T = number>(pred: Predicate<T>) => import("./api.js").MultiTensorOpImpl<import("./api.js").TensorOpRT<T, number[]>>;
13
+ /**
14
+ * Returns an array of indices where the given tensor has non-zero component
15
+ * values.
16
+ *
17
+ * @param a
18
+ */
19
+ export declare const nonZeroIndices: import("./api.js").MultiTensorOpImpl<import("./api.js").TensorOpRT<number, number[]>>;
20
+ /**
21
+ * Returns an array of indices where the given tensor has negative component
22
+ * values.
23
+ *
24
+ * @param a
25
+ */
26
+ export declare const negativeIndices: import("./api.js").MultiTensorOpImpl<import("./api.js").TensorOpRT<number, number[]>>;
27
+ /**
28
+ * Returns an array of indices where the given tensor has positive component
29
+ * values.
30
+ *
31
+ * @param a
32
+ */
33
+ export declare const positiveIndices: import("./api.js").MultiTensorOpImpl<import("./api.js").TensorOpRT<number, number[]>>;
34
+ //# sourceMappingURL=filtered-indices.d.ts.map
@@ -0,0 +1,17 @@
1
+ import { defOpRT } from "./defoprt.js";
2
+ const filteredIndices = (pred) => defOpRT(
3
+ (acc, data, i) => {
4
+ if (pred(data[i])) acc.push(i);
5
+ return acc;
6
+ },
7
+ () => []
8
+ );
9
+ const nonZeroIndices = filteredIndices((x) => x !== 0);
10
+ const negativeIndices = filteredIndices((x) => x < 0);
11
+ const positiveIndices = filteredIndices((x) => x > 0);
12
+ export {
13
+ filteredIndices,
14
+ negativeIndices,
15
+ nonZeroIndices,
16
+ positiveIndices
17
+ };
package/identity.d.ts CHANGED
@@ -1,4 +1,11 @@
1
1
  import type { TensorOpts, Type } from "./api.js";
2
2
  import { Tensor2 } from "./tensor.js";
3
+ /**
4
+ * Creates a square identity matrix of given `size` and options.
5
+ *
6
+ * @param type
7
+ * @param size
8
+ * @param opts
9
+ */
3
10
  export declare const identity: <T extends Exclude<Type, "str">>(type: T, size: number, opts?: Pick<TensorOpts<any, any>, "storage">) => Tensor2<number>;
4
11
  //# sourceMappingURL=identity.d.ts.map
package/identity.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { STORAGE } from "./storage.js";
2
2
  import { Tensor2 } from "./tensor.js";
3
3
  const identity = (type, size, opts) => {
4
+ const n = size * size;
4
5
  const storage = opts?.storage || STORAGE[type];
5
- const data = storage.alloc(size * size);
6
- for (let i = 0; i < data.length; i += size + 1) data[i] = 1;
6
+ const data = storage.alloc(n);
7
+ for (let i = 0; i < n; i += size + 1) data[i] = 1;
7
8
  return new Tensor2(type, storage, data, [size, size], [size, 1]);
8
9
  };
9
10
  export {
package/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./abs.js";
2
2
  export * from "./add.js";
3
3
  export * from "./addn.js";
4
4
  export * from "./api.js";
5
+ export * from "./broadcast.js";
5
6
  export * from "./clamp.js";
6
7
  export * from "./clampn.js";
7
8
  export * from "./cos.js";
@@ -13,12 +14,14 @@ export * from "./defoptn.js";
13
14
  export * from "./defoptnn.js";
14
15
  export * from "./defoptt.js";
15
16
  export * from "./defopttt.js";
17
+ export * from "./diagonal.js";
16
18
  export * from "./div.js";
17
19
  export * from "./divn.js";
18
20
  export * from "./dot.js";
19
21
  export * from "./errors.js";
20
22
  export * from "./exp.js";
21
23
  export * from "./exp2.js";
24
+ export * from "./filtered-indices.js";
22
25
  export * from "./format.js";
23
26
  export * from "./identity.js";
24
27
  export * from "./log.js";
@@ -38,6 +41,7 @@ export * from "./pow.js";
38
41
  export * from "./pown.js";
39
42
  export * from "./product.js";
40
43
  export * from "./rand-distrib.js";
44
+ export * from "./range.js";
41
45
  export * from "./relu.js";
42
46
  export * from "./relun.js";
43
47
  export * from "./select.js";
@@ -53,6 +57,8 @@ export * from "./storage.js";
53
57
  export * from "./sub.js";
54
58
  export * from "./subn.js";
55
59
  export * from "./sum.js";
60
+ export * from "./svd.js";
61
+ export * from "./swap.js";
56
62
  export * from "./tan.js";
57
63
  export * from "./tanh.js";
58
64
  export * from "./tensor.js";
package/index.js CHANGED
@@ -2,6 +2,7 @@ export * from "./abs.js";
2
2
  export * from "./add.js";
3
3
  export * from "./addn.js";
4
4
  export * from "./api.js";
5
+ export * from "./broadcast.js";
5
6
  export * from "./clamp.js";
6
7
  export * from "./clampn.js";
7
8
  export * from "./cos.js";
@@ -13,12 +14,14 @@ export * from "./defoptn.js";
13
14
  export * from "./defoptnn.js";
14
15
  export * from "./defoptt.js";
15
16
  export * from "./defopttt.js";
17
+ export * from "./diagonal.js";
16
18
  export * from "./div.js";
17
19
  export * from "./divn.js";
18
20
  export * from "./dot.js";
19
21
  export * from "./errors.js";
20
22
  export * from "./exp.js";
21
23
  export * from "./exp2.js";
24
+ export * from "./filtered-indices.js";
22
25
  export * from "./format.js";
23
26
  export * from "./identity.js";
24
27
  export * from "./log.js";
@@ -38,6 +41,7 @@ export * from "./pow.js";
38
41
  export * from "./pown.js";
39
42
  export * from "./product.js";
40
43
  export * from "./rand-distrib.js";
44
+ export * from "./range.js";
41
45
  export * from "./relu.js";
42
46
  export * from "./relun.js";
43
47
  export * from "./select.js";
@@ -53,6 +57,8 @@ export * from "./storage.js";
53
57
  export * from "./sub.js";
54
58
  export * from "./subn.js";
55
59
  export * from "./sum.js";
60
+ export * from "./svd.js";
61
+ export * from "./swap.js";
56
62
  export * from "./tan.js";
57
63
  export * from "./tanh.js";
58
64
  export * from "./tensor.js";
package/log.d.ts CHANGED
@@ -5,33 +5,5 @@
5
5
  * @param out - output tensor
6
6
  * @param a - input tensor
7
7
  */
8
- export declare const log: import("./api.js").MultiTensorOpT<number>;
9
- /**
10
- * Same as {@link log} for 1D tensors.
11
- *
12
- * @param out - output tensor
13
- * @param a - input tensor
14
- */
15
- export declare const log_1: import("./api.js").TensorOpT<number, number, import("./tensor.js").Tensor1<number>, import("./tensor.js").Tensor1<number>>;
16
- /**
17
- * Same as {@link log} for 2D tensors.
18
- *
19
- * @param out - output tensor
20
- * @param a - input tensor
21
- */
22
- export declare const log_2: import("./api.js").TensorOpT<number, number, import("./tensor.js").Tensor2<number>, import("./tensor.js").Tensor2<number>>;
23
- /**
24
- * Same as {@link log} for 3D tensors.
25
- *
26
- * @param out - output tensor
27
- * @param a - input tensor
28
- */
29
- export declare const log_3: import("./api.js").TensorOpT<number, number, import("./tensor.js").Tensor3<number>, import("./tensor.js").Tensor3<number>>;
30
- /**
31
- * Same as {@link log} for 4D tensors.
32
- *
33
- * @param out - output tensor
34
- * @param a - input tensor
35
- */
36
- export declare const log_4: import("./api.js").TensorOpT<number, number, import("./tensor.js").Tensor4<number>, import("./tensor.js").Tensor4<number>>;
8
+ export declare const log: import("./api.js").MultiTensorOpImpl<import("./api.js").TensorOpT<number>>;
37
9
  //# sourceMappingURL=log.d.ts.map
package/log.js CHANGED
@@ -1,14 +1,5 @@
1
1
  import { defOpT } from "./defopt.js";
2
- const [a, b, c, d, e] = defOpT(Math.log);
3
- const log = a;
4
- const log_1 = b;
5
- const log_2 = c;
6
- const log_3 = d;
7
- const log_4 = e;
2
+ const log = defOpT(Math.log);
8
3
  export {
9
- log,
10
- log_1,
11
- log_2,
12
- log_3,
13
- log_4
4
+ log
14
5
  };
package/log2.d.ts CHANGED
@@ -5,33 +5,5 @@
5
5
  * @param out - output tensor
6
6
  * @param a - input tensor
7
7
  */
8
- export declare const log2: import("./api.js").MultiTensorOpT<number>;
9
- /**
10
- * Same as {@link log2} for 1D tensors.
11
- *
12
- * @param out - output tensor
13
- * @param a - input tensor
14
- */
15
- export declare const log2_1: import("./api.js").TensorOpT<number, number, import("./tensor.js").Tensor1<number>, import("./tensor.js").Tensor1<number>>;
16
- /**
17
- * Same as {@link log2} for 2D tensors.
18
- *
19
- * @param out - output tensor
20
- * @param a - input tensor
21
- */
22
- export declare const log2_2: import("./api.js").TensorOpT<number, number, import("./tensor.js").Tensor2<number>, import("./tensor.js").Tensor2<number>>;
23
- /**
24
- * Same as {@link log2} for 3D tensors.
25
- *
26
- * @param out - output tensor
27
- * @param a - input tensor
28
- */
29
- export declare const log2_3: import("./api.js").TensorOpT<number, number, import("./tensor.js").Tensor3<number>, import("./tensor.js").Tensor3<number>>;
30
- /**
31
- * Same as {@link log2} for 4D tensors.
32
- *
33
- * @param out - output tensor
34
- * @param a - input tensor
35
- */
36
- export declare const log2_4: import("./api.js").TensorOpT<number, number, import("./tensor.js").Tensor4<number>, import("./tensor.js").Tensor4<number>>;
8
+ export declare const log2: import("./api.js").MultiTensorOpImpl<import("./api.js").TensorOpT<number>>;
37
9
  //# sourceMappingURL=log2.d.ts.map
package/log2.js CHANGED
@@ -1,14 +1,5 @@
1
1
  import { defOpT } from "./defopt.js";
2
- const [a, b, c, d, e] = defOpT(Math.log2);
3
- const log2 = a;
4
- const log2_1 = b;
5
- const log2_2 = c;
6
- const log2_3 = d;
7
- const log2_4 = e;
2
+ const log2 = defOpT(Math.log2);
8
3
  export {
9
- log2,
10
- log2_1,
11
- log2_2,
12
- log2_3,
13
- log2_4
4
+ log2
14
5
  };
package/mag.d.ts CHANGED
@@ -1,3 +1,8 @@
1
1
  import type { ITensor } from "./api.js";
2
+ /**
3
+ * Computes magnitude of given tensor. Also see {@link magSq}.
4
+ *
5
+ * @param a
6
+ */
2
7
  export declare const mag: (a: ITensor) => number;
3
8
  //# sourceMappingURL=mag.d.ts.map
package/magsq.d.ts CHANGED
@@ -3,29 +3,5 @@
3
3
  *
4
4
  * @param a - input tensor
5
5
  */
6
- export declare const magSq: import("./api.js").MultiTensorOpRT<number, number>;
7
- /**
8
- * Squared magnitude of given 1D tensor.
9
- *
10
- * @param a - input tensor
11
- */
12
- export declare const magSq1: import("./api.js").TensorOpRT<number, number, import("./tensor.js").Tensor1<number>>;
13
- /**
14
- * Squared magnitude of given 2D tensor.
15
- *
16
- * @param a - input tensor
17
- */
18
- export declare const magSq2: import("./api.js").TensorOpRT<number, number, import("./tensor.js").Tensor2<number>>;
19
- /**
20
- * Squared magnitude of given 3D tensor.
21
- *
22
- * @param a - input tensor
23
- */
24
- export declare const magSq3: import("./api.js").TensorOpRT<number, number, import("./tensor.js").Tensor3<number>>;
25
- /**
26
- * Squared magnitude of given 4D tensor.
27
- *
28
- * @param a - input tensor
29
- */
30
- export declare const magSq4: import("./api.js").TensorOpRT<number, number, import("./tensor.js").Tensor4<number>>;
6
+ export declare const magSq: import("./api.js").MultiTensorOpImpl<import("./api.js").TensorOpRT<number, number>>;
31
7
  //# sourceMappingURL=magsq.d.ts.map
package/magsq.js CHANGED
@@ -1,17 +1,8 @@
1
1
  import { defOpRT } from "./defoprt.js";
2
- const [a, b, c, d, e] = defOpRT(
3
- (acc, x) => acc + x * x,
2
+ const magSq = defOpRT(
3
+ (acc, data, i) => acc + data[i] ** 2,
4
4
  () => 0
5
5
  );
6
- const magSq = a;
7
- const magSq1 = b;
8
- const magSq2 = c;
9
- const magSq3 = d;
10
- const magSq4 = e;
11
6
  export {
12
- magSq,
13
- magSq1,
14
- magSq2,
15
- magSq3,
16
- magSq4
7
+ magSq
17
8
  };
package/max.d.ts CHANGED
@@ -1,37 +1,12 @@
1
1
  /**
2
2
  * Componentwise computes `Math.max` of given nD tensors and writes result to
3
- * `out`. If `out` is null, mutates original. Multi-method.
3
+ * `out`. If `out` is null, creates a new tensor using `a`'s type and storage
4
+ * provider and shape as determined by broadcasting rules (see {@link broadcast}
5
+ * for details).
4
6
  *
5
7
  * @param out - output tensor
6
8
  * @param a - input tensor
9
+ * @param b - input tensor
7
10
  */
8
- export declare const max: import("./api.js").MultiTensorOpTT<number>;
9
- /**
10
- * Same as {@link max} for 1D tensors.
11
- *
12
- * @param out - output tensor
13
- * @param a - input tensor
14
- */
15
- export declare const max1: import("./api.js").TensorOpTT<number, number, import("./tensor.js").Tensor1<number>, import("./tensor.js").Tensor1<number>>;
16
- /**
17
- * Same as {@link max} for 2D tensors.
18
- *
19
- * @param out - output tensor
20
- * @param a - input tensor
21
- */
22
- export declare const max2: import("./api.js").TensorOpTT<number, number, import("./tensor.js").Tensor2<number>, import("./tensor.js").Tensor2<number>>;
23
- /**
24
- * Same as {@link max} for 3D tensors.
25
- *
26
- * @param out - output tensor
27
- * @param a - input tensor
28
- */
29
- export declare const max3: import("./api.js").TensorOpTT<number, number, import("./tensor.js").Tensor3<number>, import("./tensor.js").Tensor3<number>>;
30
- /**
31
- * Same as {@link max} for 4D tensors.
32
- *
33
- * @param out - output tensor
34
- * @param a - input tensor
35
- */
36
- export declare const max4: import("./api.js").TensorOpTT<number, number, import("./tensor.js").Tensor4<number>, import("./tensor.js").Tensor4<number>>;
11
+ export declare const max: import("./api.js").TensorOpTT<number>;
37
12
  //# sourceMappingURL=max.d.ts.map
package/max.js CHANGED
@@ -1,14 +1,5 @@
1
1
  import { defOpTT } from "./defoptt.js";
2
- const [a, b, c, d, e] = defOpTT(Math.max);
3
- const max = a;
4
- const max1 = b;
5
- const max2 = c;
6
- const max3 = d;
7
- const max4 = e;
2
+ const max = defOpTT(Math.max);
8
3
  export {
9
- max,
10
- max1,
11
- max2,
12
- max3,
13
- max4
4
+ max
14
5
  };
package/maxn.d.ts CHANGED
@@ -6,37 +6,5 @@
6
6
  * @param a - input tensor
7
7
  * @param n - scalar
8
8
  */
9
- export declare const maxN: import("./api.js").MultiTensorOpTN<number>;
10
- /**
11
- * Same as {@link maxN} for 1D tensors.
12
- *
13
- * @param out - output tensor
14
- * @param a - input tensor
15
- * @param n - scalar
16
- */
17
- export declare const maxN1: import("./api.js").TensorOpTN<number, number, import("./tensor.js").Tensor1<number>, import("./tensor.js").Tensor1<number>>;
18
- /**
19
- * Same as {@link maxN} for 2D tensors.
20
- *
21
- * @param out - output tensor
22
- * @param a - input tensor
23
- * @param n - scalar
24
- */
25
- export declare const maxN2: import("./api.js").TensorOpTN<number, number, import("./tensor.js").Tensor2<number>, import("./tensor.js").Tensor2<number>>;
26
- /**
27
- * Same as {@link maxN} for 3D tensors.
28
- *
29
- * @param out - output tensor
30
- * @param a - input tensor
31
- * @param n - scalar
32
- */
33
- export declare const maxN3: import("./api.js").TensorOpTN<number, number, import("./tensor.js").Tensor3<number>, import("./tensor.js").Tensor3<number>>;
34
- /**
35
- * Same as {@link maxN} for 4D tensors.
36
- *
37
- * @param out - output tensor
38
- * @param a - input tensor
39
- * @param n - scalar
40
- */
41
- export declare const maxN4: import("./api.js").TensorOpTN<number, number, import("./tensor.js").Tensor4<number>, import("./tensor.js").Tensor4<number>>;
9
+ export declare const maxN: import("./api.js").MultiTensorOpImpl<import("./api.js").TensorOpTN<number>>;
42
10
  //# sourceMappingURL=maxn.d.ts.map
package/maxn.js CHANGED
@@ -1,14 +1,5 @@
1
1
  import { defOpTN } from "./defoptn.js";
2
- const [a, b, c, d, e] = defOpTN(Math.max);
3
- const maxN = a;
4
- const maxN1 = b;
5
- const maxN2 = c;
6
- const maxN3 = d;
7
- const maxN4 = e;
2
+ const maxN = defOpTN(Math.max);
8
3
  export {
9
- maxN,
10
- maxN1,
11
- maxN2,
12
- maxN3,
13
- maxN4
4
+ maxN
14
5
  };
package/min.d.ts CHANGED
@@ -1,37 +1,12 @@
1
1
  /**
2
2
  * Componentwise computes `Math.min` of given nD tensors and writes result to
3
- * `out`. If `out` is null, mutates original. Multi-method.
3
+ * `out`. If `out` is null, creates a new tensor using `a`'s type and storage
4
+ * provider and shape as determined by broadcasting rules (see {@link broadcast}
5
+ * for details).
4
6
  *
5
7
  * @param out - output tensor
6
8
  * @param a - input tensor
9
+ * @param b - input tensor
7
10
  */
8
- export declare const min: import("./api.js").MultiTensorOpTT<number>;
9
- /**
10
- * Same as {@link min} for 1D tensors.
11
- *
12
- * @param out - output tensor
13
- * @param a - input tensor
14
- */
15
- export declare const min1: import("./api.js").TensorOpTT<number, number, import("./tensor.js").Tensor1<number>, import("./tensor.js").Tensor1<number>>;
16
- /**
17
- * Same as {@link min} for 2D tensors.
18
- *
19
- * @param out - output tensor
20
- * @param a - input tensor
21
- */
22
- export declare const min2: import("./api.js").TensorOpTT<number, number, import("./tensor.js").Tensor2<number>, import("./tensor.js").Tensor2<number>>;
23
- /**
24
- * Same as {@link min} for 3D tensors.
25
- *
26
- * @param out - output tensor
27
- * @param a - input tensor
28
- */
29
- export declare const min3: import("./api.js").TensorOpTT<number, number, import("./tensor.js").Tensor3<number>, import("./tensor.js").Tensor3<number>>;
30
- /**
31
- * Same as {@link min} for 4D tensors.
32
- *
33
- * @param out - output tensor
34
- * @param a - input tensor
35
- */
36
- export declare const min4: import("./api.js").TensorOpTT<number, number, import("./tensor.js").Tensor4<number>, import("./tensor.js").Tensor4<number>>;
11
+ export declare const min: import("./api.js").TensorOpTT<number>;
37
12
  //# sourceMappingURL=min.d.ts.map
package/min.js CHANGED
@@ -1,14 +1,5 @@
1
1
  import { defOpTT } from "./defoptt.js";
2
- const [a, b, c, d, e] = defOpTT(Math.min);
3
- const min = a;
4
- const min1 = b;
5
- const min2 = c;
6
- const min3 = d;
7
- const min4 = e;
2
+ const min = defOpTT(Math.min);
8
3
  export {
9
- min,
10
- min1,
11
- min2,
12
- min3,
13
- min4
4
+ min
14
5
  };