gpu.js/examples/simple-typescript.ts
Robert Plummer 8bf362ad9a feat: No failing tests locally, only skipping and passing
Also:
feat: Typescript typings
feat: api cleanup and exports
feat: removal of building for node, only browser
2019-01-29 21:41:21 -05:00

19 lines
533 B
TypeScript

import {GPU} from "../src";
import {KernelFunction, IKernel} from "../index";
const gpu = new GPU({ mode: 'gpu' });
// Look ma! I can typescript on my GPU!
const kernelFunction: KernelFunction = function(anInt: number, anArray: number[], aNestedArray: number[][]) {
const x = .25 + anInt + anArray[this.thread.x] + aNestedArray[this.thread.x][this.thread.y];
return x;
};
const kernel: IKernel = gpu.createKernel(kernelFunction, {
output: [1]
});
const result = kernel(1.25, [.25], [[1.25]]);
console.log(result[0]); // 3