{-# LINE 1 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}
{-# language CPP #-}


{-# LINE 4 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}
{-# OPTIONS_HADDOCK hide #-}

{-# LINE 6 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}

module OpenCV.Internal.Core.ArrayOps
    ( CmpType(..)
    , marshalCmpType
    , NormType(..)
    , NormAbsRel(..)
    , marshalNormType
    )
    where

import "base" Data.Bits ( (.|.) )
import "base" Data.Int

--------------------------------------------------------------------------------






--------------------------------------------------------------------------------

-- | Comparison type
data CmpType
   = Cmp_Eq
   | Cmp_Gt
   | Cmp_Ge
   | Cmp_Lt
   | Cmp_Le
   | Cmp_Ne
     deriving (Show, Eq)

c'CMP_EQ = 0
c'CMP_EQ :: (Num a) => a

{-# LINE 39 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}
c'CMP_GT = 1
c'CMP_GT :: (Num a) => a

{-# LINE 40 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}
c'CMP_GE = 2
c'CMP_GE :: (Num a) => a

{-# LINE 41 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}
c'CMP_LT = 3
c'CMP_LT :: (Num a) => a

{-# LINE 42 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}
c'CMP_LE = 4
c'CMP_LE :: (Num a) => a

{-# LINE 43 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}
c'CMP_NE = 5
c'CMP_NE :: (Num a) => a

{-# LINE 44 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}

marshalCmpType :: CmpType -> Int32
marshalCmpType cmpOp =
    case cmpOp of
      Cmp_Eq -> c'CMP_EQ
      Cmp_Gt -> c'CMP_GT
      Cmp_Ge -> c'CMP_GE
      Cmp_Lt -> c'CMP_LT
      Cmp_Le -> c'CMP_LE
      Cmp_Ne -> c'CMP_NE

-- | Normalization type
data NormType
   = Norm_Inf
   | Norm_L1
   | Norm_L2
   | Norm_L2SQR
   | Norm_Hamming
   | Norm_Hamming2
   | Norm_MinMax
     deriving (Show, Eq)

data NormAbsRel
   = NormRelative
   | NormAbsolute
     deriving (Show, Eq)

c'NORM_INF = 1
c'NORM_INF :: (Num a) => a

{-# LINE 72 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}
c'NORM_L1 = 2
c'NORM_L1 :: (Num a) => a

{-# LINE 73 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}
c'NORM_L2 = 4
c'NORM_L2 :: (Num a) => a

{-# LINE 74 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}
c'NORM_L2SQR = 5
c'NORM_L2SQR :: (Num a) => a

{-# LINE 75 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}
c'NORM_HAMMING = 6
c'NORM_HAMMING :: (Num a) => a

{-# LINE 76 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}
c'NORM_HAMMING2 = 7
c'NORM_HAMMING2 :: (Num a) => a

{-# LINE 77 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}
c'NORM_MINMAX = 32
c'NORM_MINMAX :: (Num a) => a

{-# LINE 78 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}

c'NORM_RELATIVE = 8
c'NORM_RELATIVE :: (Num a) => a

{-# LINE 80 "src/OpenCV/Internal/Core/ArrayOps.hsc" #-}

marshalNormType :: NormAbsRel -> NormType -> Int32
marshalNormType absRel normType =
    case absRel of
      NormRelative -> c'normType .|. c'NORM_RELATIVE
      NormAbsolute -> c'normType
  where
    c'normType = case normType of
        Norm_Inf      -> c'NORM_INF
        Norm_L1       -> c'NORM_L1
        Norm_L2       -> c'NORM_L2
        Norm_L2SQR    -> c'NORM_L2SQR
        Norm_Hamming  -> c'NORM_HAMMING
        Norm_Hamming2 -> c'NORM_HAMMING2
        Norm_MinMax   -> c'NORM_MINMAX