3 ms·
Isn't that the default behaviour for most linear algebra systems? (e.g. MATLAB). Maybe I'm missing something but I don't really care about compile time checking
by sjtrny 11y ago
Isn't that the default behaviour for most linear algebra systems? (e.g. MATLAB). Maybe I'm missing something but I don't really care about compile time checking and it seems an impossible task anyway with variable/dynamic sized inputs.
- gugagore 11y agoYes, it is impossible for a compiler to know the size of a matrix whose size is determined at runtime. But a lot of times you do know the size of matrices and not only is it more type-safe to have the type of a matrix be parametrized by its size, it also allows for more efficient code generation. If you don't know the size of a matrix and vector, you necessarily need a loop. If you know your matrix is 3 by 2, you may just, at compile time, unroll the loop completely. I don't know which default behavior you mean.
- dllthomas 11y agoIt's impossible for a compiler to know the size of a matrix whose size is determined at runtime, but it's not impossible for a compiler to prove that whatever the size your logic is still correct (or at least doesn't break any of the invariants you've established). Depending on the nature of those invariants and the complexity of your logic, you may need dependent types.