Copyright | (c) The University of Glasgow 2001 |
---|---|
License | BSD-style (see the file libraries/base/LICENSE) |
Maintainer | libraries@haskell.org |
Stability | provisional |
Portability | portable |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Complex numbers.
Synopsis
- data Complex a = !a :+ !a
- realPart :: Complex a -> a
- imagPart :: Complex a -> a
- mkPolar :: Floating a => a -> a -> Complex a
- cis :: Floating a => a -> Complex a
- polar :: RealFloat a => Complex a -> (a, a)
- magnitude :: RealFloat a => Complex a -> a
- phase :: RealFloat a => Complex a -> a
- conjugate :: Num a => Complex a -> Complex a
Rectangular form
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
Monad Complex # | Since: base-4.9.0.0 |
Functor Complex # | Since: base-4.9.0.0 |
Applicative Complex # | Since: base-4.9.0.0 |
Foldable Complex # | Since: base-4.9.0.0 |
Defined in Data.Complex fold :: Monoid m => Complex m -> m # foldMap :: Monoid m => (a -> m) -> Complex a -> m # foldr :: (a -> b -> b) -> b -> Complex a -> b # foldr' :: (a -> b -> b) -> b -> Complex a -> b # foldl :: (b -> a -> b) -> b -> Complex a -> b # foldl' :: (b -> a -> b) -> b -> Complex a -> b # foldr1 :: (a -> a -> a) -> Complex a -> a # foldl1 :: (a -> a -> a) -> Complex a -> a # elem :: Eq a => a -> Complex a -> Bool # maximum :: Ord a => Complex a -> a # minimum :: Ord a => Complex a -> a # | |
Traversable Complex # | Since: base-4.9.0.0 |
Eq a => Eq (Complex a) # | Since: base-2.1 |
RealFloat a => Floating (Complex a) # | Since: base-2.1 |
Defined in Data.Complex exp :: Complex a -> Complex a # log :: Complex a -> Complex a # sqrt :: Complex a -> Complex a # (**) :: Complex a -> Complex a -> Complex a # logBase :: Complex a -> Complex a -> Complex a # sin :: Complex a -> Complex a # cos :: Complex a -> Complex a # tan :: Complex a -> Complex a # asin :: Complex a -> Complex a # acos :: Complex a -> Complex a # atan :: Complex a -> Complex a # sinh :: Complex a -> Complex a # cosh :: Complex a -> Complex a # tanh :: Complex a -> Complex a # asinh :: Complex a -> Complex a # acosh :: Complex a -> Complex a # atanh :: Complex a -> Complex a # log1p :: Complex a -> Complex a # expm1 :: Complex a -> Complex a # | |
RealFloat a => Fractional (Complex a) # | Since: base-2.1 |
Data a => Data (Complex a) # | Since: base-2.1 |
Defined in Data.Complex gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Complex a -> c (Complex a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Complex a) # toConstr :: Complex a -> Constr # dataTypeOf :: Complex a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Complex a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Complex a)) # gmapT :: (forall b. Data b => b -> b) -> Complex a -> Complex a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Complex a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Complex a -> r # gmapQ :: (forall d. Data d => d -> u) -> Complex a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Complex a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Complex a -> m (Complex a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Complex a -> m (Complex a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Complex a -> m (Complex a) # | |
RealFloat a => Num (Complex a) # | Since: base-2.1 |
Read a => Read (Complex a) # | Since: base-2.1 |
Show a => Show (Complex a) # | Since: base-2.1 |
Generic (Complex a) # | |
Storable a => Storable (Complex a) # | Since: base-4.8.0.0 |
Defined in Data.Complex | |
Generic1 Complex # | |
type Rep (Complex a) # | Since: base-4.9.0.0 |
Defined in Data.Complex type Rep (Complex a) = D1 (MetaData "Complex" "Data.Complex" "base" False) (C1 (MetaCons ":+" (InfixI NotAssociative 6) False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 a))) | |
type Rep1 Complex # | Since: base-4.9.0.0 |
Defined in Data.Complex type Rep1 Complex = D1 (MetaData "Complex" "Data.Complex" "base" False) (C1 (MetaCons ":+" (InfixI NotAssociative 6) False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) Par1 :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) Par1)) |
Polar form
mkPolar :: Floating a => a -> a -> Complex a #
Form a complex number from polar components of magnitude and phase.