4 ms·
Somewhat confusing to see a matrix represented as an array of arrays, it will never be fast.
by stabbles 2y ago
Somewhat confusing to see a matrix represented as an array of arrays, it will never be fast.
- tomsmeding 2y agoThis is in the surface language only: Futhark's arrays must be "rectangular" (if you have an array of arrays, the subarrays are mandated to be equally-sized; this is statically checked in most cases, and when it can't, it becomes a runtime check), and thus they are represented as a single, actual multi-dimensional array.
- adgjlsfhk1 2y agoimo that seems like some pretty weird semantics. how do you write an operation that needs to bundle together lists of different lengths?
- Athas 2y agoThe best answer is that you probably don't want to use Futhark for that - it's a specialised, rather restricted language. There are ways to encode irregular arrays, but it's not even remotely as ergonomic as in other languages (it can be plenty fast, however). For a particularly simple example, see https://futhark-lang.org/examples/triangular.html https://futhark-lang.org/examples/triangular.html In the future, or in a future similar language, one might well imagine an ability to "box" arrays, like in APL, which would allow true "arrays of arrays" with no restrictions on sizes.