Advertisement
MAT4m

Untitled

Jan 13th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1.  
  2. struct Complex {
  3. double R;
  4. double I;
  5. }
  6.  
  7. typedef struct Complex Complex;
  8.  
  9. Complex initComplex(double input_R, double input_I) {
  10. Complex result = { input_R, input_I };
  11. return result;
  12. }
  13.  
  14. {
  15. Complex result;
  16. result.R = input_R;
  17. result.I = input_I;
  18. return result;
  19. }
  20.  
  21. Complex addComplex(Complex a, Complex b) {
  22. Complex result;
  23. result.R = a.R + b.R;
  24. result.I = a.I + b.I;
  25. return result;
  26. }
  27.  
  28. Complex multiplicateComplex(Complex a, Complex b) {
  29. Complex result;
  30. result.R = a.R * b.R - a.I * b.I;
  31. result.I = a.R * b.I + b.R *a.I;
  32. return result;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement