Copyright | [2015..2020] The Accelerate Team |
---|---|
License | BSD3 |
Maintainer | Trevor L. McDonell <trevor.mcdonell@gmail.com> |
Stability | experimental |
Portability | non-portable (GHC extensions) |
Safe Haskell | None |
Language | Haskell2010 |
Complex numbers, stored in the usual C-style array-of-struct representation, for easy interoperability.
Synopsis
- data Complex a = !a :+ !a
- pattern (::+) :: Elt a => Exp a -> Exp a -> Exp (Complex a)
- real :: Elt a => Exp (Complex a) -> Exp a
- imag :: Elt a => Exp (Complex a) -> Exp a
- mkPolar :: forall a. Floating a => Exp a -> Exp a -> Exp (Complex a)
- cis :: forall a. Floating a => Exp a -> Exp (Complex a)
- polar :: RealFloat a => Exp (Complex a) -> Exp (a, a)
- magnitude :: RealFloat a => Exp (Complex a) -> Exp a
- magnitude' :: RealFloat a => Exp (Complex a) -> Exp a
- phase :: RealFloat a => Exp (Complex a) -> Exp a
- conjugate :: Num a => Exp (Complex a) -> Exp (Complex a)
Rectangular from
Complex numbers are an algebraic type.
For a complex number z
,
is a number with the magnitude of abs
zz
,
but oriented in the positive real direction, whereas
has the phase of signum
zz
, but unit magnitude.
The Foldable
and Traversable
instances traverse the real part first.
Note that Complex
's instances inherit the deficiencies from the type
parameter's. For example, Complex Float
's Ord
instance has similar
problems to Float
's.
!a :+ !a infix 6 | forms a complex number from its real and imaginary rectangular components. |
Instances
Polar form
mkPolar :: forall a. Floating a => Exp a -> Exp a -> Exp (Complex a) Source #
Form a complex number from polar components of magnitude and phase.
magnitude :: RealFloat a => Exp (Complex a) -> Exp a Source #
The non-negative magnitude of a complex number
magnitude' :: RealFloat a => Exp (Complex a) -> Exp a Source #
As magnitude
, but ignore floating point rounding and use the traditional
(simpler to evaluate) definition.
Since: 1.3.0.0
Conjugate
conjugate :: Num a => Exp (Complex a) -> Exp (Complex a) Source #
Return the complex conjugate of a complex number, defined as
conjugate(Z) = X - iY