Closed PhilipWitte closed 12 years ago
I implemented it, but just for matrix inversion, since the determinant/magnitude/length can be 0, and as we all know dividing by 0 is not what we want. This optimization can be disabled with -version=NoReciprocalMul
, it is enabled by default.
You might think about using an assert and having a compiler variable instead of a compiler flag:
private auto invert(bool rmul = true)(ref Matrix mat) const {
static if (rmul && isFloatingPoint!mt) {
assert(det != 0);
mt d = 1 / det;
enum op = "*";
}
else {
mt d = det;
enum op = "/";
}
...
}
That way you can use both, and only use '/' when & where the program fails in debug.
[EDIT] I forget this method is private :-/ I see why you just went with the compiler flag.
This needs to be tested, but I believe it should work: