Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Dimensionality is easy, its the lengths of these dimensions that are hard. E.g. you can multiply n by k, k by m matrices to get an n by m matrix, but anything else is a type error. In Bling, I had Matrix<LN,LK> * Matrix<LK,LM> => Matrix<LN,LM>, where LN,LK,LM are type parameters up to around 10 (L0, L1, ..., L10, enough to do 3D graphics, mostly, but wouldn't work for HPC where lengths are much longer and diverse).

Looking at the linked page, extent isn't a part of a matrix's type signature, so it would be checked dynamically, correct?



> you can multiply n by k, k by m matrices to get an n by m matrix, but anything else is a type error.

This is exactly how Repa works, it uses a Peano encoding of the extent of dimensions to make invalid array operations inexpressible.


Ok. This isn't obvious at all by looking at the documentation, also since extent doesn't seem to appear in the type signature of a matrix instance.


[deleted]


Ah, this is exactly the approach I took in C# (though with a small range of branded types to stand in for numbers). Thanks for clearing this up!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: