(mode)
| 4 | describe('features: internally defined matrices'); |
| 5 | |
| 6 | function 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 | |
| 28 | test('matrix2 auto', () => { |
| 29 | testMatrix2(); |
no test coverage detected
searching dependent graphs…