pow method

Complex pow(
  1. num k
)

Implementation

Complex pow(num k) {
  if (k is int) {
    return List.filled(k, this).reduce((a, b) => a * b);
  } else if (k is double) {
    var angle = this.angle();
    var mag = norm();

    var newAngle = angle * k;
    var newMag = math.pow(mag, k);

    return Complex.exp(angle: newAngle, r: newMag.toDouble());
  } else {
    throw 'Unhandled power operation for type ${k.runtimeType}';
  }
}