by goatlover · 9y ago · 0 comments
class Complex {
double real;
double imaginary;
}
Or similar. Maybe template it so you can have a Complex<double> instead. It's still fundamentally a combination of existing types.That's very convenient when you want your complex numbers to work just like ints and floats.
Reducing things to just their primitives ignores how useful abstractions are for humans. Not everyone thinks it's a good use of their time to reinvent classes & objects or closures with structures and function pointers. Thus why those abstractions are part of so many programming languages (to answer the expressed bafflement one level above my initial reply).
Some C or assembly fans act like abstractions should end at that level, for some strange reason.
[1] Look for the instructions prefixed with FC = Floating-point Complex
https://developer.arm.com/docs/dui0801/latest/a64-simd-vecto...
There are lots of processors out there besides CPUs. You could even design a new processor or program an FPGA to do complex math. Fast Fourier transforms deal with imaginary math, for example. You can do those in a number of ways, including on a CPU or GPU, but it's not unheard of for companies to use either custom hardware or programmable hardware to meet performance needs.