[Haskell-cafe] NFData instance for Numeric.LinearAlgebra Matrix

Alberto Ruiz aruiz at um.es
Sun Mar 27 14:35:59 CEST 2011


Hello Tad,

It can be defined in terms of rwhnf, Matrix is strict:

ghci> rwhnf $ [1,2,3,undefined::Double]
()
ghci> rwhnf $ (2><2) [1,2,3,undefined::Double]
*** Exception: Prelude.undefined


instance NFData (Matrix t) where
     rnf = rwhnf

ms = [ident 3, (2><2) [1,2,3,undefined::Double]]


ghci> rwhnf ms
()
ghci> rnf ms
*** Exception: Prelude.undefined

HTH,
Alberto

On 03/26/2011 06:56 PM, Tad Doxsee wrote:
> Hello,
>
> Is there already an instance of NFData (from Control.DeepSeq in the
> deepseq package) for the type Matrix (from Numeric.LinearAlgebra in
> the hmatrix package) somewhere?  If not, how does one define one?
> (The data declaration for Matrix is in a hidden module,
> Data.Packed.Internal.Matrix, if that makes any difference).
>
> Thanks,
>
> Tad
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe




More information about the Haskell-Cafe mailing list