private static function powi($z, $n) {
        if ($n < 0) return static::div(1,static::powi($z, -$n));

        if ($n == 0) return new Complex(1,0);

        $y = new Complex(1,0);
        while ($n > 1) {
            if ($n % 2 == 0) {
                $n = $n / 2;
            } else {
                $y = static::mul($z, $y);
                $n = ($n-1)/2;
            }
            $z = static::mul($z, $z);
        }

        return static::mul($z, $y);
    }
private static function powi($z, $n) {
        if ($n < 0) return static::div(1,static::powi($z, -$n));

        if ($n == 0) return new Complex(1,0);

        $y = new Complex(1,0);
        while ($n > 1) {
            if ($n % 2 == 0) {
                $n = $n / 2;
            } else {
                $y = static::mul($z, $y);
                $n = ($n-1)/2;
            }
            $z = static::mul($z, $z);
        }

        return static::mul($z, $y);
    }
private static function powi ( $ z , $ n ) { if ( $ n < 0 ) return static :: div ( 1 , static :: powi ( $ z , - $ n ) ) ; if ( $ n == 0 ) return new Complex ( 1 , 0 ) ; $ y = new Complex ( 1 , 0 ) ; while ( $ n > 1 ) { if ( $ n % 2 == 0 ) { $ n = $ n / 2 ; } else { $ y = static :: mul ( $ z , $ y ) ; $ n = ( $ n - 1 ) / 2 ; } $ z = static :: mul ( $ z , $ z ) ; } return static :: mul ( $ z , $ y ) ; }
integer power of a complex number

Complex::powi($z, $n) computes and returns $z^$n where $n is an integer


@param mixed $z (Complex, or parsable to Complex)
@param int $n
@retval Complex
integer power of a complex number