-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Row/column major ordering #21
Comments
See also #9 |
Hmm I like your idea of overloading It should basically work similar to opIndex then ;-)
|
Yes, first we need a good DIP for opCall to be like opIndex. See http://wiki.dlang.org/DIPs
Behavior with |
I guess one could use
What would you suggest |
Anyway
s().writeln; // [[0, 1], [2, 3]] instead of [[0, 2], [1, 3]]
s(1).writeln; // [0, 2] instead of [[0,2]] |
You could also overload with tuples and replace the s = iota(9).sliced(3, 3);
// 0 1 2
// 3 4 5
// 6 7 8
// 0 3 6
// 1 4 7
// 2 5 8
s(tuple(1,2), tuple(1, 2)); // [[4,7], [5,8]]
s( tuple(1,-1), tuple(1, -1)); // same Oh sry - made the brackets for For
|
|
and if i think about it one couldn't do stuff like |
duplicate of #10 |
See also: https://en.wikipedia.org/wiki/Row-major_order
It is sometimes useful to apply an operation in "Fortran mode"
(=column-major, everted)
Have a look at this example from NumPy:
You can think of this as "look at the array in column mode" -
apply the operation and "write in back in column mode".
So in Python one can actually "simulate" it with the following
If one tries the example with ndslice we get
which makes a bit of sense, because
everted
just reverts the order of iteration.It is possible to do the same as above correctly with
byElement
andarray
.However it feels wrong to have to copy the array.
The text was updated successfully, but these errors were encountered: