I recently found out there is support for vector extensions
But I have found I don't really understand how to use it, not even mentioning the more complex stuff. I couldn't find any good examples either.
I'm trying to figure out how to implement the following opBinary using vector extensions.
alias MatType = typeof(this);
union{
T[rows*columns] vec;
T[rows][columns] mat;
}
MatType opBinary(string op, T)(const T right) const {
MatType result = this;
mixin("result.vec[] = this.vec[] " ~ op ~ " right;");
return result;
}
Or alternatively, as I'm not sure which is more efficient/faster:
MatType opBinary(string op, T)(const T right) const {
MatType result;
static foreach(i; 0..rows*columns)
mixin("result.vec[i] = this.vec[i] " ~ op ~ " right;");
return result;
}
But going off the documentation, I have no idea how to use vector extensions to achieve something like this.
As a small disclaimer; I don't know to what extent the compiler already automates these kind of operations, and mostly want to use this as a learning experience.
Kind regards, HN