Академический Документы
Профессиональный Документы
Культура Документы
How can I work with complex numbers in C? I see there is a complex.h header file, but it doesn't
give me much information about how to use it. How to access real and imaginary parts in an
efficient way? Are there native functions to get module and phase?
int main() {
return 0;
}
With:
creal(z1): get the real part (for float crealf(z1), for long double creall(z1))
cimag(z1): get the imaginary part (for float cimagf(z1), for long double cimagl(z1))
Another important point to remember when working with complex numbers is that functions like
cos(), exp() and sqrt() must be replaced with their complex forms, e.g. ccos(), cexp(), csqrt().