@thi.ng/tensors
Version:
0D/1D/2D/3D/4D tensors with extensible polymorphic operations and customizable storage
34 lines • 1.1 kB
TypeScript
import type { Fn } from "@thi.ng/api";
import type { ITensor } from "./api.js";
import { Tensor1 } from "./tensor.js";
/**
* Integrates given tensor along innermost dimension and writes result to 1D
* tensor `out` (or creates new one).
*
* @remarks
* The output tensor shape must match the innermost shape of the input: e.g. if
* input shape is `[2,3,4]`, then the output tensor must have a shape of `[4]`.
*
* @example
* ```ts tangle:../export/integrate.ts
* import { integrate, print, product, sum, tensor } from "@thi.ng/tensors";
*
* const input = tensor([[1, 2], [10, 20], [100, 200]]);
*
* // integrate using `sum()` (also default)
* // i.e. [1 + 10 + 100, 2 + 20 + 200]
* print(integrate(null, input, sum));
* // 111.0000 222.0000
*
* // integrate using `product()`
* // i.e. [1 * 10 * 100, 2 * 20 * 200]
* print(integrate(null, input, product));
* // 1000.0000 8000.0000
* ```
*
* @param out
* @param a
* @param fn
*/
export declare const integrate: (out: Tensor1 | null, a: ITensor, fn?: Fn<ITensor, number>) => Tensor1;
//# sourceMappingURL=integrate.d.ts.map