Skip to content

Unusable with Data.Complex #41

@Abbath

Description

@Abbath

I want to use Data.Complex to do tricks like this:

ghci> (-5) ** 5 :: Complex (CReal 50)
-3125.0000000000000000 :+ 0.0000000000000000

But some functions from Data.Complex (log, sqrt) use magnitude, which uses scaleFloat and exponent from RealFloat. While scaleFloat works, exponent throws an error.

magnitude :: (RealFloat a) => Complex a -> a
magnitude (x:+y) =  scaleFloat k
                     (sqrt (sqr (scaleFloat mk x) + sqr (scaleFloat mk y)))
                    where k  = max (exponent x) (exponent y)
                          mk = - k
                          sqr z = z * z

I have tried changing exponent to

exponent _ = 0

and it works just fine, tests are passing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions