That was my point.
[quote]Usually people define * and / between vectors and numbers, but not between vectors themselves, when operator overloading.
[/quote]
Hmm. Definitely useful, but trickier to do in a generalisable way.
[/quote]
Matrices get * defined, but oftentimes not /, because the operation of inverting a matrix can fail sometimes and it’s usually best not to hide that by making it look like regular old division.
[/quote]
Division can fail in a field, although floating point in Java hides it by using infinities and NaNs. If integer division can get away with throwing ArithmeticException I don’t see why overloaded division couldn’t throw a SingularMatrixException.
[quote]Personally, I’d love to see Java get some built in primitives (preferably stack-allocated and immutable) for vectors, matrices, and complex numbers, with these overloadings baked in; if that happened, I wouldn’t care about operator overloading one bit, though I’d also like the big/arb. precision number classes to get the same treatment. I can’t come up with many other compelling or common use cases for operator overloading that make sense, but those ones cause a lot of pain if you work in areas that require them…
[/quote]
I’m trying to think about how it could be done while still being and feeling like Java and with a bit more flexibility for people who want to play around with surreal numbers, octonions, or an arbitrary field. (I’m assuming that quaternions would be added to your list of basics).
