Opened 11 years ago

Closed 6 years ago

#2450 closed bug (fixed)

Data.Complex.magnitude squares using ^(2 :: Int), which is slow

Reported by: igloo Owned by:
Priority: lowest Milestone: 7.6.2
Component: libraries/base Version: 6.8.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Data.Complex.magnitude squares using ^(2 :: Int), which is slow. Either it should use sqr x = x * x or a rule should rewrite e ^ (2 :: Int) to do so (or perhaps both; the RULE for general cases, and the manual sqr for hugs etc).

More detail in this thread: http://www.haskell.org/pipermail/haskell-cafe/2008-July/045327.html

Change History (15)

comment:1 Changed 11 years ago by igloo

Type: bugrun-time performance bug

comment:2 Changed 11 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:3 Changed 11 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:4 Changed 11 years ago by igloo

Owner: set to igloo

comment:5 Changed 11 years ago by igloo

Milestone: 6.10.16.12 branch
Owner: igloo deleted

I've fixed magnitude, but we might still want to add the RULE.

comment:6 Changed 10 years ago by simonmar

Type of failure: Runtime performance bug

comment:7 Changed 9 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:8 Changed 9 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:9 Changed 9 years ago by igloo

Milestone: 7.0.17.0.2

comment:10 Changed 9 years ago by igloo

Milestone: 7.0.27.2.1

comment:11 Changed 8 years ago by igloo

Milestone: 7.2.17.4.1

comment:12 Changed 8 years ago by igloo

Milestone: 7.4.17.6.1
Priority: lowlowest

comment:13 Changed 7 years ago by igloo

Milestone: 7.6.17.6.2

comment:14 Changed 6 years ago by cdk

It looks like this has been resolved, Data.Complex.magnitude now uses sqr z = z * z and GHC.Real has rewrite rules for small, known constant exponents:

https://github.com/ghc/packages-base/blob/master/Data/Complex.hs https://github.com/ghc/packages-base/blob/master/GHC/Real.lhs

I found this bug on the list of 'getting started' bugs, but it's already been fixed. Time to close?

comment:15 Changed 6 years ago by monoidal

Resolution: fixed
Status: newclosed

You are right, I see that originally the bug was left open because of missing rewrite rules (https://github.com/ghc/packages-base/commit/d6adf6bd595c3b8f750acc9293f5847f176b521b) but they were added in #5237. Thanks!

Note: See TracTickets for help on using tickets.