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

Function testMatrix3

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

Source from the content-addressed store, hash-verified

50});
51
52function testMatrix3(mode) {
53 const gpu = new GPU({ mode });
54 function getMatrix() {
55 const matrix = [
56 [1,2,3],
57 [4,5,6],
58 [7,8,9],
59 ];
60 return matrix;
61 }
62 gpu.addFunction(getMatrix);
63 const kernel = gpu.createKernel(function(y, x) {
64 return getMatrix()[y][x];
65 }, { output: [1] });
66
67 assert.equal(kernel(0, 0)[0], 1);
68 assert.equal(kernel(0, 1)[0], 2);
69 assert.equal(kernel(0, 2)[0], 3);
70 assert.equal(kernel(1, 0)[0], 4);
71 assert.equal(kernel(1, 1)[0], 5);
72 assert.equal(kernel(1, 2)[0], 6);
73 assert.equal(kernel(2, 0)[0], 7);
74 assert.equal(kernel(2, 1)[0], 8);
75 assert.equal(kernel(2, 2)[0], 9);
76
77 gpu.destroy();
78}
79
80test('matrix3 auto', () => {
81 testMatrix3();

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…