From e97a22d5bbdde5b96d9401a7abb25534a2d45bd1 Mon Sep 17 00:00:00 2001 From: Justin Le Date: Tue, 22 Dec 2015 22:15:53 -0800 Subject: NFData instances for various Static types, and mapping and outer product methods to Domain --- packages/base/src/Internal/Static.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'packages/base/src/Internal/Static.hs') diff --git a/packages/base/src/Internal/Static.hs b/packages/base/src/Internal/Static.hs index 0068313..419ff07 100644 --- a/packages/base/src/Internal/Static.hs +++ b/packages/base/src/Internal/Static.hs @@ -11,6 +11,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE BangPatterns #-} {- | Module : Internal.Static @@ -28,6 +29,7 @@ import qualified Numeric.LinearAlgebra as LA import Numeric.LinearAlgebra hiding (konst,size,R,C) import Internal.Vector as D hiding (R,C) import Internal.ST +import Control.DeepSeq import Data.Proxy(Proxy) import Foreign.Storable(Storable) import Text.Printf @@ -50,6 +52,9 @@ lift2F -> Dim n (c t) -> Dim n (c t) -> Dim n (c t) lift2F f (Dim u) (Dim v) = Dim (f u v) +instance NFData t => NFData (Dim n t) where + rnf (Dim (force -> !_)) = () + -------------------------------------------------------------------------------- newtype R n = R (Dim n (Vector ℝ)) @@ -75,6 +80,18 @@ mkL x = L (Dim (Dim x)) mkM :: Matrix ℂ -> M m n mkM x = M (Dim (Dim x)) +instance NFData (R n) where + rnf (R (force -> !_)) = () + +instance NFData (C n) where + rnf (C (force -> !_)) = () + +instance NFData (L n m) where + rnf (L (force -> !_)) = () + +instance NFData (M n m) where + rnf (M (force -> !_)) = () + -------------------------------------------------------------------------------- type V n t = Dim n (Vector t) -- cgit v1.2.3