MCPcopy Create free account
hub / github.com/gpujs/gpu.js / testMatrix4

Function testMatrix4

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

Source from the content-addressed store, hash-verified

102});
103
104function testMatrix4(mode) {
105 const gpu = new GPU({ mode });
106 function getMatrix() {
107 const matrix = [
108 [1,2,3,4],
109 [5,6,7,8],
110 [9,10,11,12],
111 [13,14,15,16],
112 ];
113 return matrix;
114 }
115 gpu.addFunction(getMatrix);
116 const kernel = gpu.createKernel(function(y, x) {
117 return getMatrix()[y][x];
118 }, { output: [1] });
119
120 assert.equal(kernel(0, 0)[0], 1);
121 assert.equal(kernel(0, 1)[0], 2);
122 assert.equal(kernel(0, 2)[0], 3);
123 assert.equal(kernel(0, 3)[0], 4);
124 assert.equal(kernel(1, 0)[0], 5);
125 assert.equal(kernel(1, 1)[0], 6);
126 assert.equal(kernel(1, 2)[0], 7);
127 assert.equal(kernel(1, 3)[0], 8);
128 assert.equal(kernel(2, 0)[0], 9);
129 assert.equal(kernel(2, 1)[0], 10);
130 assert.equal(kernel(2, 2)[0], 11);
131 assert.equal(kernel(2, 3)[0], 12);
132 assert.equal(kernel(3, 0)[0], 13);
133 assert.equal(kernel(3, 1)[0], 14);
134 assert.equal(kernel(3, 2)[0], 15);
135 assert.equal(kernel(3, 3)[0], 16);
136
137 gpu.destroy();
138}
139
140test('matrix4 auto', () => {
141 testMatrix4();

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…