module Data.TimeSeries.Storable (
TSeries(..),
valuesAsHmatrixVector
) where
import Data.Typeable (Typeable)
import Data.TimeSeries.Class hiding (TSeries)
import Data.UTime (UTime)
import qualified Data.TimeSeries.Class as TSC
import qualified Data.Vector.Storable as VS
import qualified Data.Vector.Hybrid as H
newtype TSeries a = TSeries (H.Vector VS.Vector VS.Vector (UTime, a))
deriving (Eq, Show, Typeable)
type instance TSVector TSeries = H.Vector VS.Vector VS.Vector
type instance TSTimes TSeries = VS.Vector
type instance TSValues TSeries = VS.Vector
instance VS.Storable a => TSC.TSeries TSeries a where
toVector (TSeries v) = v
fromVector = TSeries
tsValues (TSeries v) = H.projectSnd v
tsTimes (TSeries v) = H.projectFst v
fromTimesValues ts vs = TSeries $ H.unsafeZip ts vs
valuesAsHmatrixVector :: VS.Storable a => TSeries a -> VS.Vector a
valuesAsHmatrixVector = tsValues