{-# LANGUAGE GADTs #-}
module Numeric.LAPACK.Matrix.ModifierTyped where

import qualified Numeric.BLAS.Matrix.Modifier as Mod
import qualified Numeric.LAPACK.Matrix.Extent.Private as Extent
import Numeric.LAPACK.Matrix.Extent.Private (Extent, Small)


data Transposition heightA widthA heightB widthB where
   NonTransposed :: Transposition height width height width
   Transposed    :: Transposition height width width height

transposeTransposition ::
   Transposition heightA widthA heightB widthB ->
   Transposition widthA heightA widthB heightB
transposeTransposition :: forall heightA widthA heightB widthB.
Transposition heightA widthA heightB widthB
-> Transposition widthA heightA widthB heightB
transposeTransposition Transposition heightA widthA heightB widthB
trans =
   case Transposition heightA widthA heightB widthB
trans of
      Transposition heightA widthA heightB widthB
NonTransposed -> Transposition widthA heightA widthA heightA
Transposition widthA heightA widthB heightB
forall height width. Transposition height width height width
NonTransposed
      Transposition heightA widthA heightB widthB
Transposed -> Transposition widthA heightA heightA widthA
Transposition widthA heightA widthB heightB
forall height width. Transposition height width width height
Transposed

transposeSquareExtent ::
   (Extent.Measure meas) =>
   Transposition heightA widthA heightB widthB ->
   Extent meas Small Small heightA widthA ->
   Extent meas Small Small heightB widthB
transposeSquareExtent :: forall meas heightA widthA heightB widthB.
Measure meas =>
Transposition heightA widthA heightB widthB
-> Extent meas Small Small heightA widthA
-> Extent meas Small Small heightB widthB
transposeSquareExtent Transposition heightA widthA heightB widthB
trans =
   case Transposition heightA widthA heightB widthB
trans of
      Transposition heightA widthA heightB widthB
NonTransposed -> Extent meas Small Small heightA widthA
-> Extent meas Small Small heightA widthA
Extent meas Small Small heightA widthA
-> Extent meas Small Small heightB widthB
forall a. a -> a
id
      Transposition heightA widthA heightB widthB
Transposed -> Extent meas Small Small heightA widthA
-> Extent meas Small Small widthA heightA
Extent meas Small Small heightA widthA
-> Extent meas Small Small heightB widthB
forall meas vert horiz height width.
(Measure meas, C vert, C horiz) =>
Extent meas vert horiz height width
-> Extent meas horiz vert width height
Extent.transpose

transpositionToUntyped ::
   Transposition heightA widthA heightB widthB -> Mod.Transposition
transpositionToUntyped :: forall heightA widthA heightB widthB.
Transposition heightA widthA heightB widthB -> Transposition
transpositionToUntyped Transposition heightA widthA heightB widthB
trans =
   case Transposition heightA widthA heightB widthB
trans of
      Transposition heightA widthA heightB widthB
NonTransposed -> Transposition
Mod.NonTransposed
      Transposition heightA widthA heightB widthB
Transposed -> Transposition
Mod.Transposed


fromSquareTransposition :: Mod.Transposition -> Transposition sh sh sh sh
fromSquareTransposition :: forall sh. Transposition -> Transposition sh sh sh sh
fromSquareTransposition Transposition
trans =
   case Transposition
trans of
      Transposition
Mod.NonTransposed -> Transposition sh sh sh sh
forall height width. Transposition height width height width
NonTransposed
      Transposition
Mod.Transposed -> Transposition sh sh sh sh
forall height width. Transposition height width width height
Transposed


data SquareTransposition sh height width where
   SquareTransposition :: Mod.Transposition -> SquareTransposition sh sh sh

squareFromTransposition ::
   Transposition sh sh height width -> SquareTransposition sh height width
squareFromTransposition :: forall sh height width.
Transposition sh sh height width
-> SquareTransposition sh height width
squareFromTransposition Transposition sh sh height width
trans =
   case Transposition sh sh height width
trans of
      Transposition sh sh height width
NonTransposed -> Transposition -> SquareTransposition sh sh sh
forall sh. Transposition -> SquareTransposition sh sh sh
SquareTransposition Transposition
Mod.NonTransposed
      Transposition sh sh height width
Transposed -> Transposition -> SquareTransposition sh sh sh
forall sh. Transposition -> SquareTransposition sh sh sh
SquareTransposition Transposition
Mod.Transposed