Sparse Ax = b with WebAssembly text format
A wasm module is defined with wat
Within the module, two components are defined:
- shared linear memory
- sparse_mul function
A, x, and b are stored in the linear memory.
A is sparse format: row, col, val, row, col, val, ...
x and b are dense format: x0,x1,x2,x3,x4, ...
sparse_mul inputs the offset address of A,x,b, and the number of entries in A.
it adds A*x to b (within the linear memory)
In Javascript, array views for A,x,and b are created from the linear memory's buffer.
So, we can set and get with javascript and compute with wasm.
test: matrix of ones multiplied by sparse identity matrix
x = [1,1,1].
A = [0,0,1, 1,1,0, 2,2,0]
A*x = ...