Overview

Namespaces

  • chippyash
    • Type
      • Exceptions
      • Interfaces
      • Number
        • Complex
        • Rational
      • String

Interfaces

  • ComplexTypeInterface
  • GMPInterface
  • NumericTypeInterface
  • RationalTypeInterface
  • TypeInterface
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Hard type support
  4:  * For when you absolutely want to know what you are getting
  5:  *
  6:  * @author Ashley Kitson <akitson@zf4.biz>
  7:  * @copyright Ashley Kitson, UK, 2014
  8:  * @licence GPL V3 or later : http://www.gnu.org/licenses/gpl.html
  9:  */
 10: namespace chippyash\Type\Interfaces;
 11: 
 12: use chippyash\Type\Number\Rational\RationalType;
 13: 
 14: /**
 15:  * Interface for chippyash\Type\Number\Complex\ComplexType types
 16:  * Makes it broadly compatible with other types
 17:  */
 18: interface ComplexTypeInterface extends TypeInterface
 19: {
 20:     /**
 21:      * Get the real part
 22:      * @return RationalType
 23:      */
 24:     public function r();
 25: 
 26:     /**
 27:      * Get the imaginary part
 28:      *
 29:      * @return RationalType
 30:      */
 31:     public function i();
 32:     
 33:     /**
 34:      * Is this number equal to zero?
 35:      * @return boolean
 36:      */
 37:     public function isZero();
 38: 
 39:     /**
 40:      * Is this number a real number?  i.e. is it in form n+0i
 41:      *
 42:      * @return boolean
 43:      */
 44:     public function isReal();
 45:     
 46:     /**
 47:      * Is this number Gaussian, i.e r & i are both equivelent to integers
 48:      *
 49:      * @return boolean
 50:      * @link http://en.wikipedia.org/wiki/Gaussian_integer
 51:      */
 52:     public function isGaussian();
 53:     
 54:     /**
 55:      * Return conjugate of this number
 56:      * @return \chippyash\Type\Number\Complex\ComplexType
 57:      */
 58:     public function conjugate();
 59:     
 60:     /**
 61:      * Return the modulus, also known as absolute value or magnitude of this number
 62:      * = sqrt(r^2 + i^2);
 63:      *
 64:      * @return \chippyash\Type\Number\Rational\RationalType
 65:      */
 66:     public function modulus();
 67:     
 68:     /**
 69:      * Return the angle (sometimes known as the argument) of the number
 70:      * when expressed in polar notation
 71:      * 
 72:      * The return value is a rational expressing theta as radians
 73:      * 
 74:      * @return \chippyash\Type\Number\Rational\RationalType
 75:      */
 76:     public function theta();
 77:     
 78:     /**
 79:      * Return the radius (sometimes known as Rho) of the number
 80:      * when expressed in polar notation
 81:      * 
 82:      * @return \chippyash\Type\Number\Rational\RationalType
 83:      */
 84:     public function radius();
 85:     
 86:     /**
 87:      * Returns complex number expressed in polar form
 88:      * 
 89:      * radius == this->modulus()
 90:      * theta is angle expressed in radians
 91:      * 
 92:      * @return array[radius => RationalType, theta => RationalType] 
 93:      */
 94:     public function asPolar();
 95:     
 96:     /**
 97:      * Returns the polar quadrant for the complex number
 98:      * Returns 1, 2, 3 or 4 dependent on the quadrant
 99:      * 
100:      * @return int
101:      */
102:     public function polarQuadrant();
103:     
104:     /**
105:      * Return complex number expressed as a string in polar form
106:      * i.e. r(cosθ + i⋅sinθ)
107:      *
108:      * @return string
109:      */
110:     public function polarString();
111: }
112: 
Chippyash Strong Types API documentation generated by ApiGen 2.8.0