←back to thread

132 points zfnmxt | 1 comments | | HN request time: 0.205s | source
Show context
stabbles ◴[] No.40714856[source]
Somewhat confusing to see a matrix represented as an array of arrays, it will never be fast.
replies(1): >>40714907 #
tomsmeding ◴[] No.40714907[source]
This 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.
replies(1): >>40716597 #
adgjlsfhk1 ◴[] No.40716597[source]
imo that seems like some pretty weird semantics. how do you write an operation that needs to bundle together lists of different lengths?
replies(1): >>40717028 #
1. Athas ◴[] No.40717028[source]
The 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

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.