module Linalg.Matrix.Transpose_Test ( test ) where

import Test_Support
import Linalg.Matrix.Transpose
import Data.Matrix_Test()
import Data.Matrix ( Matrix, unsafeFromList, toList )
import qualified Data.List as List

test :: Test
test = testGroup "Linalg.Matrix.Tranpose" $ do
  testCase "transpose [[1]] = [[1]]" $
    [[1]] @=? (toList . transpose . unsafeFromList $ [[1]])

  testCase "transpose [[1, 2, 3], [4, 5, 6]] = [[1, 4], [2, 5], [3, 6]]" $
    [[1, 4], [2, 5], [3, 6]] @=? (toList . transpose . unsafeFromList $ [[1, 2, 3], [4, 5, 6]])

  testProperty "transpose . transpose = id" $
    (\matrix -> (transpose . transpose $ (matrix :: Matrix A)) == matrix)

  testProperty "transpose = unsafeFromList . List.transpose . toList" $
    (\matrix -> transpose (matrix :: Matrix A)
      == (unsafeFromList . List.transpose . toList $ matrix))
