module Biobase.Types.Energy where
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Generic.Mutable as VGM
import Data.Primitive.Types
import Biobase.Types.Ring
newtype Energy = Energy {unEnergy :: Int}
deriving (Show, Read, Eq, Ord)
instance Ring Energy where
(Energy a) .+. (Energy b) = Energy $ a `min` b
(Energy a) .*. (Energy b) = Energy $ a + b
(Energy a) .^. k = Energy $ a * k
(Energy a) .^^. k = Energy . round $ fromIntegral a * k
neg (Energy a) = Energy $ negate a
one = Energy 0
zero = Energy 10000000
isZero (Energy a) = a >= 1000000
deriving instance VGM.MVector VU.MVector Energy
deriving instance VG.Vector VU.Vector Energy
deriving instance VU.Unbox Energy
deriving instance Prim Energy