On Thursday, 29 April 2021 at 15:56:48 UTC, jmh530 wrote:
On Thursday, 29 April 2021 at 15:26:15 UTC, Newbie wrote:
[snip]
Forgot to add the the first array was created using the
following code.
auto base = iota(2, 5, 3);
What you're basically asking for the first one is to convert
for row major to column major. There doesn't seem to be a
specific function for that, but you can piece it together. The
second one is just applying allReversed to the result of that.
So we have:
```d
/+dub.sdl:
dependency "mir-algorithm" version="~>3.10.25"
+/
import std.stdio: writeln;
import mir.ndslice.topology: iota, flattened, reshape,
universal;
import mir.ndslice.dynamic: transposed, allReversed;
void main() {
auto x = iota(2, 5, 3);
int err;
auto y = x.flattened.reshape([3, 5, 2], err).transposed!(1,
2);
auto z = y.allReversed;
writeln(x);
writeln(y);
writeln(z);
}
```
First of all thanks for your guidance and i modified your example
to get the results I was looking for.
auto y2 = base.flattened.reshape([3, 5, 2], err).transposed!(1,
2);
produced the following.
---------
|0 10 20|
|1 11 21|
---------
|2 12 22|
|3 13 23|
---------
|4 14 24|
|5 15 25|
---------
|6 16 26|
|7 17 27|
---------
|8 18 28|
|9 19 29|
---------
and auto y2 = base.flattened.reshape([3, 2, 5],
err).transposed!(1, 2);
gave me the result i was looking for.
---------
|0 10 20|
|1 11 21|
|2 12 22|
|3 13 23|
|4 14 24|
---------
|5 15 25|
|6 16 26|
|7 17 27|
|8 18 28|
|9 19 29|
---------
Thanks,
Newbie.