[Haskell-cafe] Data.Complex.magnitude slow?

stefan kersten sk at k-hornz.de
Fri Jul 18 07:25:55 EDT 2008


On 18.07.2008, at 13:05, Henning Thielemann wrote:
> On Fri, 18 Jul 2008, stefan kersten wrote:
>
>> On 17.07.2008, at 21:46, Lennart Augustsson wrote:
>>> If scaleFloat and exponent are implemented with bit twiddling  
>>> they can
>>> be quite fast.
>>
>> is there a way in ghc to 'cast' between float/int32 and double/ 
>> int64 (without going through memory)?
>
> What speaks against going through memory? If you want to write a  
> large chunk of Doubles to disk, you may write it to a  
> StorableVector and write that to disk. However shipping internal  
> bit patterns to disk may violate portability, because on different  
> machines there can be different floating point formats. What other  
> situations might be there, where you want to cast Float to Int32  
> and so on?

for implementing scaleFloat and exponent on the bitlevel as lennart  
suggested, it would be preferable if the cast would be compiled to a  
register move/reinterpretation, rather than a store/load through  
several layers of abstraction (such as Data.Binary). i'm just curious ;)

<sk>



More information about the Haskell-Cafe mailing list