c++ - Find exponent of a complex number -


i want find out exponent of complex number such as: 2+3i.

how can find value? know

e^(jt)=cos(t)+jsin(t) 

is there built in function in opencv? if yes, please explain me example.

what’s wrong cexp( ) function declared in complex.h? why want use opencv instead of standard library?

#include <complex.h> #include <stdio.h>  int main(int argc, char *argv[]) {     double complex z = 2 + 3*i;     double complex w = cexp(z);     printf("%f + %fi\n", creal(w), cimag(w));     return 0; } 

if you’re targeting platform doesn’t provide complex types or operations, can use following quick-and-dirty solution:

struct mycomplex { double real; double imag; }  struct mycomplex my_exp(struct mycomplex z) {     struct mycomplex w;     w.real = exp(z.real)*cos(z.imag);     w.imag = exp(z.real)*sin(z.imag);     return w; } 

and finally, since you’re using msvc, rudimentary c++ example:

#include <complex> #include <iostream>  int main(int argc, char *argv[]) {     auto z = std::complex<double>(2,3);     auto w = std::exp(z);     std::cout << w << std::endl;     return 0; } 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -