MCPcopy Index your code
hub / github.com/gpujs/gpu.js / testMatrix2

Function testMatrix2

test/features/internally-defined-matrices.js:6–26  ·  view source on GitHub ↗
(mode)

Source from the content-addressed store, hash-verified

4describe('features: internally defined matrices');
5
6function testMatrix2(mode) {
7 const gpu = new GPU({ mode });
8 function getMatrix() {
9 const matrix = [
10 [1,2],
11 [3,4]
12 ];
13 return matrix;
14 }
15 gpu.addFunction(getMatrix);
16 const kernel = gpu.createKernel(function(y, x) {
17 return getMatrix()[y][x];
18 }, { output: [1] });
19
20 assert.equal(kernel(0, 0)[0], 1);
21 assert.equal(kernel(0, 1)[0], 2);
22 assert.equal(kernel(1, 0)[0], 3);
23 assert.equal(kernel(1, 1)[0], 4);
24
25 gpu.destroy();
26}
27
28test('matrix2 auto', () => {
29 testMatrix2();

Callers 1

Calls 5

addFunctionMethod · 0.95
createKernelMethod · 0.95
destroyMethod · 0.95
getMatrixFunction · 0.85
kernelFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…