Re: Impose structure on array

2019-05-26 Thread 9il via Digitalmars-d-learn
On Monday, 20 May 2019 at 12:09:02 UTC, Alex wrote: given some array, is there some way to easily impose structure on that array at runtime? void* data; auto x = cast(byte[A,B,C])data; X is then an AxBxC matrix. I'm having to compute the index myself and it just seems unnecessary. A and B a

Re: Impose structure on array

2019-05-20 Thread Dennis via Digitalmars-d-learn
On Monday, 20 May 2019 at 12:09:02 UTC, Alex wrote: void* data; auto x = cast(byte[A,B,C])data; X is then an AxBxC matrix. It sounds like you're looking for ndslide from mir http://code.dlang.org/packages/mir-algorithm ``` ubyte data[]; auto x = x.sliced(A, B, C); ``` It should be pretty ef

Impose structure on array

2019-05-20 Thread Alex via Digitalmars-d-learn
given some array, is there some way to easily impose structure on that array at runtime? void* data; auto x = cast(byte[A,B,C])data; X is then an AxBxC matrix. I'm having to compute the index myself and it just seems unnecessary. A and B are not known at compile time though. Obviously it s