module Algorithms.Geometry.SoS.Determinant where

import           Algorithms.Geometry.SoS.Sign
import           Algorithms.Geometry.SoS.Symbolic
import           Data.Geometry.Matrix


-- | pre: computes the sign of the determinant
signDet   :: (HasDeterminant d, Ord i, Num r, Ord r) => Matrix d d (Symbolic i r) -> Sign
signDet :: Matrix d d (Symbolic i r) -> Sign
signDet Matrix d d (Symbolic i r)
m = case Matrix d d (Symbolic i r) -> Symbolic i r
forall (d :: Nat) r. (HasDeterminant d, Num r) => Matrix d d r -> r
det Matrix d d (Symbolic i r)
m Symbolic i r -> Symbolic i r -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` Symbolic i r
0 of
              Ordering
LT -> Sign
Negative
              Ordering
GT -> Sign
Positive
              Ordering
EQ -> [Char] -> Sign
forall a. HasCallStack => [Char] -> a
error [Char]
"signDet: determinant is zero! this should not happen!"