operator * method

Complex operator *(
  1. Complex b
)

Multiply two complex number

Examples

var c1 = Complex(real: 2, imaginary: 5);
var c2 = Complex(real: 4, imaginary: -3);

print(c1 * c2);

/*output:
Complex(real: 13.0, imaginary: 14.0)
*/

Implementation

Complex operator *(Complex b) {
  return Complex(
      real: real * b.real - imaginary * b.imaginary,
      imaginary: real * b.imaginary + imaginary * b.real);
}