-
Notifications
You must be signed in to change notification settings - Fork 36
Closed
Description
Example code provided by mir:
/+dub.sdl:
dependency "mir-algorithm" version=">=2.0.0"
+/
void main()
{
import mir.ndslice;
auto matrix = slice!double(3, 4);
matrix[] = 0;
matrix.diagonal[] = 1;
auto row = matrix[2];
row[3] = 6;
assert(matrix[2, 3] == 6); // D & C index order
import std.stdio;
matrix.writeln; // [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 6]]This code works fine for all numeric types except (u)byte and (u)short. I saw #100 and kind of understand why byte fails, but why does (u)short also fail? (Error: matrix[] is not an lvalue and cannot be modified) Presumably it is because the internal representation. Explicit short(<num>) works in this case just as with byte.
If this is a won't fix, I would politely request a note in the documentation that byte and short should in general not be used. This bit me tonight while working with 16-bit image data and I was storing as short ndslice.
Thanks again for this amazing library.
Metadata
Metadata
Assignees
Labels
No labels