Source for file Complex.php
Documentation is available at Complex.php
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Jesus M. Castagnetto <jmcastagnetto@php.net> |
// +----------------------------------------------------------------------+
// $Id: Complex.php 304053 2010-10-05 00:43:46Z clockwerx $
* Package with classes to represent and manipulate complex number. Contain
* definitions for basic arithmetic functions, as well as trigonometric,
* inverse trigonometric, hyperbolic, inverse hyperbolic, exponential and
* logarithms of complex numbers.
* Math_Complex: class to represent an manipulate complex numbers (z = a + b*i)
* Originally this class was part of NumPHP (Numeric PHP package)
* @author Jesus M. Castagnetto <jmcastagnetto@php.net>
class Math_Complex {/*{{{*/
* The real part of the complex number
* The imaginary part of the complex number
* Constructor for Math_Complex
* @param float $real Real part of the number
* @param float $im Imaginary part of the number
* @return object Math_Complex
function Math_Complex ($real, $im)
* Simple string representation of the number
$str .= ($i < 0 ) ? ' - ' : ' + ';
* Returns the square of the magnitude of the number
return ($this->_real * $this->_real + $this->_im * $this->_im);
* Returns the magnitude (also referred as norm) of the number
return sqrt($this->abs2 ());
* Returns the norm of the number
* Alias of Math_Complex::abs()
* Returns the argument of the complex number
* @return float|PEAR_ErrorA floating point number on success, a PEAR_Error otherwise
$arg = atan2($this->_im,$this->_real);
if (M_PI < $arg || $arg < -1*M_PI ) {
return PEAR ::raiseError ('Argument has an impossible value');
* Returns the angle (argument) associated with the complex number
* Alias of Math_Complex::arg()
* @return mixed A float on success, a PEAR_Error otherwise
* Returns the real part of the complex number
* Returns the imaginary part of the complex number
} /* end of Math_Complex class *//*}}}*/
Documentation generated on Mon, 11 Mar 2019 15:39:23 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|