Copyright | (c) Galois Inc 2014-2020 |
---|---|

License | BSD3 |

Maintainer | Joe Hendrix <jhendrix@galois.com> |

Stability | provisional |

Safe Haskell | Safe |

Language | Haskell2010 |

This module provides complex numbers without the RealFloat constraints that Data.Complex has. This is useful for representing various intermediate symbolic representations of complex numbers that are not literally number representations.

## Synopsis

- data Complex a = !a :+ !a
- realPart :: Complex a -> a
- imagPart :: Complex a -> a
- magnitude :: Floating a => Complex a -> a
- magnitudeSq :: Num a => Complex a -> a
- complexNegate :: Num a => Complex a -> Complex a
- complexAdd :: Num a => Complex a -> Complex a -> Complex a
- complexSub :: Num a => Complex a -> Complex a -> Complex a
- complexMul :: Num a => Complex a -> Complex a -> Complex a
- complexDiv :: Fractional a => Complex a -> Complex a -> Complex a
- complexRecip :: Fractional a => Complex a -> Complex a
- tryComplexSqrt :: (Ord a, Fractional a, Monad m) => (a -> m a) -> Complex a -> m (Complex a)
- tryMagnitude :: Num a => (a -> b) -> Complex a -> b
- complexAsRational :: Complex Rational -> Maybe Rational

# Documentation

A complex pair over an arbitrary type.

!a :+ !a infix 6 |

## Instances

magnitudeSq :: Num a => Complex a -> a Source #

Returns square of magnitude.

complexDiv :: Fractional a => Complex a -> Complex a -> Complex a Source #

complexRecip :: Fractional a => Complex a -> Complex a Source #

:: (Ord a, Fractional a, Monad m) | |

=> (a -> m a) | Square-root function defined for non-negative values a. |

-> Complex a | |

-> m (Complex a) |