Files
haskell-math/test/GF2test.hs
2026-01-19 15:15:01 +01:00

44 lines
1.0 KiB
Haskell

module GF2test (run) where
import Test.HUnit
import LinearAlgebra.GF2
( fromBools
, gaussianEliminationIndices
)
run :: IO ()
run = do
putStrLn "GF2 Gaussian elimination test"
let rowsBools =
[ [True, False, True]
, [False, True, True]
, [True, True, True]
, [True, True, False]
]
nCols = length (head rowsBools)
rowsBits = map fromBools rowsBools
maybeIndices = gaussianEliminationIndices nCols rowsBits
case maybeIndices of
Nothing -> assertFailure "expected rows 0,1,3"
Just rows -> assertEqual "expected rows 0,1,3" rows [0,1,3]
-- no depency case
let rowsBools2 =
[ [True, False, True]
, [False, True, True]
, [True, True, True]
]
nCols2 = length (head rowsBools2)
rowsBits2 = map fromBools rowsBools2
maybeIndices2 = gaussianEliminationIndices nCols2 rowsBits2
assertEqual "Expected no dependency" Nothing maybeIndices2
putStrLn "GF2 test done."