4 ms·
Why would complex numbers in particular deserve to be a native type? What about quaternions, or vectors and matrices of sizes 2-4 at least? Is there any real
by geon 2y ago
Why would complex numbers in particular deserve to be a native type?
What about quaternions, or vectors and matrices of sizes 2-4 at least?
Is there any real advantage over just using a struct?
Would MultiArrayList help with performance for complex numbers and vectors?
- gliptic 2y agoZig doesn't (and never will) have operator overloading, so using any user-defined numeric types is awkward. It also already has vector types.
- the__alchemist 2y agoThis is IMO the canonical use case of operator overloads. Are you proposing adding complex numbers to the standard lib to circumvent that restriction, vice addressing it?
- Q6T46nT668w6i3m 2y agoI don’t think it’s more complicated than people want an abstraction for the complex number instructions you find on processors like the TMS320 series or Qualcomm Hexagon.
- deleted 2y ago[deleted]
- ilayn 2y agoWhy should complex numbers need justification to be native type? If you need to do serious computation, you need them. If you say Zig is not for number crunching which, say, Java explicitly decided then fine otherwise searching for a reason for complex number tells me that you don't do any numerical programming which is fine but asking for justification makes no sense. Why is any other thing in the language justified? float64 is just two float32. Why stop at float64 why not float128 float256?
- geon 2y agoWhat do you mean with ” float64 is just two float32.”?