| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
NumHask.Data.Complex
Description
Complex numbers.
Synopsis
- newtype Complex a = Complex {
- complexPair :: (a, a)
- (+:) :: a -> a -> Complex a
- realPart :: Complex a -> a
- imagPart :: Complex a -> a
- normSquared :: Distributive a => Complex a -> a
Documentation
The underlying representation is a newtype-wrapped tuple, compared with the base datatype. This was chosen to facilitate the use of DerivingVia.
Constructors
| Complex | |
Fields
| |
Instances
| Functor Complex Source # | |||||||||
| Eq a => Eq (Complex a) Source # | |||||||||
| Data a => Data (Complex a) Source # | |||||||||
Defined in NumHask.Data.Complex Methods 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 :: forall r r'. (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) # | |||||||||
| Generic (Complex a) Source # | |||||||||
Defined in NumHask.Data.Complex Associated Types
| |||||||||
| Read a => Read (Complex a) Source # | |||||||||
| Show a => Show (Complex a) Source # | |||||||||
| Additive a => Additive (Complex a) Source # | |||||||||
| Subtractive a => Subtractive (Complex a) Source # | |||||||||
| (TrigField a, ExpField a) => ExpField (Complex a) Source # | |||||||||
| (Subtractive a, QuotientField a) => QuotientField (Complex a) Source # | A complex field quotients and recombines component-wise.
Can't use DerivingVia due to extra Whole constraints. | ||||||||
Defined in NumHask.Data.Complex Associated Types
| |||||||||
| JoinSemiLattice a => JoinSemiLattice (Complex a) Source # | |||||||||
| LowerBounded a => LowerBounded (Complex a) Source # | |||||||||
Defined in NumHask.Data.Complex | |||||||||
| MeetSemiLattice a => MeetSemiLattice (Complex a) Source # | |||||||||
| UpperBounded a => UpperBounded (Complex a) Source # | |||||||||
Defined in NumHask.Data.Complex | |||||||||
| (ExpField a, Eq a) => Basis (Complex a) Source # | |||||||||
Defined in NumHask.Data.Complex Associated Types
| |||||||||
| TrigField a => Direction (Complex a) Source # | |||||||||
| Epsilon a => Epsilon (Complex a) Source # | |||||||||
Defined in NumHask.Data.Complex | |||||||||
| (Subtractive a, Divisive a) => Divisive (Complex a) Source # | |||||||||
| (Subtractive a, Multiplicative a) => Multiplicative (Complex a) Source # | |||||||||
| (Distributive a, Subtractive a) => InvolutiveRing (Complex a) Source # | |||||||||
| (Additive a, FromIntegral a b) => FromIntegral (Complex a) b Source # | |||||||||
Defined in NumHask.Data.Complex Methods fromIntegral :: b -> Complex a Source # | |||||||||
| type Rep (Complex a) Source # | |||||||||
Defined in NumHask.Data.Complex | |||||||||
| type Whole (Complex a) Source # | |||||||||
Defined in NumHask.Data.Complex | |||||||||
| type Base (Complex a) Source # | |||||||||
Defined in NumHask.Data.Complex | |||||||||
| type Dir (Complex a) Source # | |||||||||
Defined in NumHask.Data.Complex | |||||||||
| type Mag (Complex a) Source # | |||||||||
Defined in NumHask.Data.Complex | |||||||||
(+:) :: a -> a -> Complex a infixl 6 Source #
Complex number constructor.
Internally, Complex derives most instances via EuclideanPair. For instance,
>>>sqrt (1.0 +: (-1.0)) :: Complex DoubleComplex {complexPair = (1.0986841134678098,-0.45508986056222733)}
>>>sqrt ((-1.0) +: 0.0) :: Complex DoubleComplex {complexPair = (6.123233995736766e-17,1.0)}
normSquared :: Distributive a => Complex a -> a Source #
The squared norm: frequently useful, and doesn't require the ability to take square roots.