IMPRODUCT

Returns the product of two or more complex numbers in x + yi or x + yj text format.

Excel Function:
IMPRODUCT(complexNumber[,complexNumber[,...]])

@param	string		$complexNumber,...	Series of complex numbers to multiply
@return	string
170764
public static function IMPRODUCT() {
		// Return value
		$returnValue = self::_parseComplex('1');
		$activeSuffix = '';

		// Loop through the arguments
		$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
		foreach ($aArgs as $arg) {
			$parsedComplex = self::_parseComplex($arg);

			$workValue = $returnValue;
			if (($parsedComplex['suffix'] != '') && ($activeSuffix == '')) {
				$activeSuffix = $parsedComplex['suffix'];
			} elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) {
				return PHPExcel_Calculation_Functions::NaN();
			}
			$returnValue['real'] = ($workValue['real'] * $parsedComplex['real']) - ($workValue['imaginary'] * $parsedComplex['imaginary']);
			$returnValue['imaginary'] = ($workValue['real'] * $parsedComplex['imaginary']) + ($workValue['imaginary'] * $parsedComplex['real']);
		}

		if ($returnValue['imaginary'] == 0.0) { $activeSuffix = ''; }
		return self::COMPLEX($returnValue['real'],$returnValue['imaginary'],$activeSuffix);
	}
906485
public static function IMEXP($complexNumber)
    {
        $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);

        $parsedComplex = self::parseComplex($complexNumber);

        if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
            return '1';
        }

        $e = exp($parsedComplex['real']);
        $eX = $e * cos($parsedComplex['imaginary']);
        $eY = $e * sin($parsedComplex['imaginary']);

        if ($parsedComplex['suffix'] == '') {
            return self::COMPLEX($eX, $eY);
        } else {
            return self::COMPLEX($eX, $eY, $parsedComplex['suffix']);
        }
    }
632054
protected function arbitrate(NumericTypeInterface $a, NumericTypeInterface $b)
    {
        $pairing = $this->getTypePairing($a, $b);
        if ($pairing == 'complex:complex') {
            return 'complex';
        }
        if (strpos($pairing, 'complex') === 0) {
            return 'complex:numeric';
        }
        if (strpos($pairing, 'complex') !== false) {
            return 'numeric:complex';
        }
        if (strstr($pairing, 'rational') !== false) {
            return 'rational';
        }
        if (strstr($pairing, 'float') !== false) {
            return 'float';
        }
        if (strstr($pairing, 'wholeint') !== false) {
            return 'whole';
        }
        if (strstr($pairing, 'naturalint') !== false) {
            return 'natural';
        }
        if ($pairing == 'int:int') {
            return 'int';
        }
    }
692552
public function invertSignal() : RealNumber
    {
        if ($this->isZero() === true) {
            return new RealNumber(0);
        } elseif ($this->isPositive() === true) {
            return $this->toNegative();
        } else {
            return $this->toPositive();
        }
    }
687075
public static ComplexNumber Add(ComplexNumber z1, ComplexNumber z2) {
        return new ComplexNumber(z1.real + z2.real, z1.imaginary + z2.imaginary);
    }
688288
public function getFormula()
	{
		$expression	= "";
		for( $i = $this->getRank() - 1; $i >= 0; $i-- )
		{
			$a = $this->coefficients[$i];
			if( $a != 0 )
			{
				$sign = $this->getSign( $a );
				if( $i )
				{
					if( abs( $a ) == 1 )
					{
						if( $expression || $a == -1 )
							$expression	.= $sign;
					}
					else
						$expression	.= $expression ? $sign.abs( $a )."*" : $a."*";
					$expression	.= "pow(x,".$i.")";
				}
				else
					$expression	.= $expression ? $sign.abs( $a ) : $a;
			}
		}
		$formula	= new Alg_Math_Formula( $expression, "x" );
		return $formula;
	}
1303478
public static ComplexNumber Divide(ComplexNumber z1, double scalar) {
        return new ComplexNumber(z1.real / scalar, z1.imaginary / scalar);
    }
391806
public Complex exp() {
        return new Complex(Math.exp(re) * Math.cos(im), Math.exp(re) * Math.sin(im));
    }
305924
private static Number sum_impl_(Number x, Number y) {
        if (x instanceof Double || y instanceof Double)
            return Double.valueOf(x.doubleValue() + y.doubleValue());
        else
            return Long.valueOf(x.longValue() + y.longValue());
    }
233733
public static ComplexNumber Log(ComplexNumber z1) {
        ComplexNumber result = new ComplexNumber();

        if ((z1.real > 0.0) && (z1.imaginary == 0.0)) {
            result.real = Math.log(z1.real);
            result.imaginary = 0.0;
        } else if (z1.real == 0.0) {
            if (z1.imaginary > 0.0) {
                result.real = Math.log(z1.imaginary);
                result.imaginary = Math.PI / 2.0;
            } else {
                result.real = Math.log(-(z1.imaginary));
                result.imaginary = -Math.PI / 2.0;
            }
        } else {
            result.real = Math.log(z1.getMagnitude());
            result.imaginary = Math.atan2(z1.imaginary, z1.real);
        }

        return result;
    }
306965
private static Number impl_(Number x, Number y) {
        return (x.doubleValue() > y.doubleValue() ? y : x);
    }
34586
public function reverse()
    {
        return new Complex(
            $this->imaginaryPart,
            $this->realPart,
            ($this->realPart == 0.0) ? null : $this->suffix
        );
    }
1061059
def mk_complex_format_func(fmt):
	
	fmt = fmt + u"+i" + fmt
	def complex_format_func(z):
		return fmt % (z.real, z.imag)
	return complex_format_func
1198789
function() {

      var a = this['re'];
      var b = this['im'];
      var r = this['abs']();

      var re, im;

      if (a >= 0) {

        if (b === 0) {
          return new Complex(Math.sqrt(a), 0);
        }

        re = 0.5 * Math.sqrt(2.0 * (r + a));
      } else {
        re = Math.abs(b) / Math.sqrt(2 * (r - a));
      }

      if (a <= 0) {
        im = 0.5 * Math.sqrt(2.0 * (r - a));
      } else {
        im = Math.abs(b) / Math.sqrt(2 * (r + a));
      }

      return new Complex(re, b < 0 ? -im : im);
    }
1217758
public ComplexDouble addi(double a, ComplexDouble result) {
    if (this == result) {
      r += a;
    } else {
      result.r = r + a;
      result.i = i;
    }
    return result;
  }
847088
public function complexDiv(ComplexType $a, ComplexType $b)
    {
        if ($b->isZero()) {
            throw new \BadMethodCallException('Cannot divide complex number by zero complex number');
        }
        //div = br^2 + bi^2
        $div = $this->rationalAdd(
            $this->rationalMul($b->r(), $b->r()),
            $this->rationalMul($b->i(), $b->i())
        );
        //r = ((ar * br) + (ai * bi))/div
        $r = $this->rationalDiv(
            $this->rationalAdd(
                $this->rationalMul($a->r(), $b->r()),
                $this->rationalMul($a->i(), $b->i())
            ),
            $div
        );
        //i = ((ai * br) - (ar * bi)) / div
        $i = $this->rationalDiv(
            $this->rationalSub(
                $this->rationalMul($a->i(), $b->r()),
                $this->rationalMul($a->r(), $b->i())
            ),
            $div
        );

        return ComplexTypeFactory::create($r, $i);
    }
499593
public function getSimilarProducts()
    {
        if ($this->_oSimilarProducts === null) {
            $this->_oSimilarProducts = false;
            if ($oProduct = $this->getProduct()) {
                $this->_oSimilarProducts = $oProduct->getSimilarProducts();
            }
        }

        return $this->_oSimilarProducts;
    }