module Numeric.LAPACK.Permutation (
   Plain.Permutation,
   Plain.Shape(Shape), Plain.Element(Element),
   Plain.size,
   Plain.identity,
   Mod.Inversion(NonInverted,Inverted),
   Plain.fromPivots,
   Plain.toPivots,
   toMatrix,
   Plain.Sign(Positive,Negative),
   Plain.determinant,
   Plain.numberFromSign,
   Plain.transpose,
   Plain.inversionFromTransposition,
   Plain.multiply,
   apply,
   ) where

import qualified Numeric.LAPACK.Permutation.Private as Plain
import qualified Numeric.LAPACK.Matrix.Array.Private as ArrMatrix
import qualified Numeric.BLAS.Matrix.Modifier as Mod
import qualified Numeric.LAPACK.Matrix.Extent.Private as Extent
import Numeric.LAPACK.Permutation.Private (Permutation)
import Numeric.LAPACK.Matrix.Array.Private (Full, Square)

import qualified Numeric.Netlib.Class as Class

import qualified Data.Array.Comfort.Shape as Shape


toMatrix :: (Shape.C sh, Class.Floating a) => Permutation sh -> Square sh a
toMatrix :: forall sh a. (C sh, Floating a) => Permutation sh -> Square sh a
toMatrix = Array (Full Shape Small Small sh sh) a
-> Matrix
     (Array Unpacked Arbitrary)
     ()
     ()
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
PlainArray
  Unpacked Arbitrary Filled Filled Shape Small Small sh sh a
-> Matrix
     (Array Unpacked Arbitrary)
     ()
     ()
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
forall pack prop lower upper meas vert horiz height width a.
FromPlain pack prop lower upper meas vert horiz height width =>
PlainArray pack prop lower upper meas vert horiz height width a
-> ArrayMatrix pack prop lower upper meas vert horiz height width a
ArrMatrix.lift0 (Array (Full Shape Small Small sh sh) a
 -> Matrix
      (Array Unpacked Arbitrary)
      ()
      ()
      Filled
      Filled
      Shape
      Small
      Small
      sh
      sh
      a)
-> (Permutation sh -> Array (Full Shape Small Small sh sh) a)
-> Permutation sh
-> Matrix
     (Array Unpacked Arbitrary)
     ()
     ()
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Permutation sh -> Array (Full Shape Small Small sh sh) a
forall sh a. (C sh, Floating a) => Permutation sh -> Square sh a
Plain.toMatrix

apply ::
   (Extent.Measure meas, Extent.C vert, Extent.C horiz,
    Shape.C height, Eq height, Shape.C width, Class.Floating a) =>
   Mod.Inversion -> Permutation height ->
   Full meas vert horiz height width a ->
   Full meas vert horiz height width a
apply :: forall meas vert horiz height width a.
(Measure meas, C vert, C horiz, C height, Eq height, C width,
 Floating a) =>
Inversion
-> Permutation height
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
apply Inversion
inverted = (Array (Full meas vert horiz height width) a
 -> Array (Full meas vert horiz height width) a)
-> Matrix
     (Array Unpacked Arbitrary)
     ()
     ()
     Filled
     Filled
     meas
     vert
     horiz
     height
     width
     a
-> Matrix
     (Array Unpacked Arbitrary)
     ()
     ()
     Filled
     Filled
     meas
     vert
     horiz
     height
     width
     a
(PlainArray
   Unpacked Arbitrary Filled Filled meas vert horiz height width a
 -> PlainArray
      Unpacked Arbitrary Filled Filled meas vert horiz height width a)
-> Matrix
     (Array Unpacked Arbitrary)
     ()
     ()
     Filled
     Filled
     meas
     vert
     horiz
     height
     width
     a
-> Matrix
     (Array Unpacked Arbitrary)
     ()
     ()
     Filled
     Filled
     meas
     vert
     horiz
     height
     width
     a
forall packA propA lowerA upperA measA vertA horizA heightA widthA
       packB propB lowerB upperB measB vertB horizB heightB widthB a b.
(ToPlain
   packA propA lowerA upperA measA vertA horizA heightA widthA,
 FromPlain
   packB propB lowerB upperB measB vertB horizB heightB widthB) =>
(PlainArray
   packA propA lowerA upperA measA vertA horizA heightA widthA a
 -> PlainArray
      packB propB lowerB upperB measB vertB horizB heightB widthB b)
-> ArrayMatrix
     packA propA lowerA upperA measA vertA horizA heightA widthA a
-> ArrayMatrix
     packB propB lowerB upperB measB vertB horizB heightB widthB b
ArrMatrix.lift1 ((Array (Full meas vert horiz height width) a
  -> Array (Full meas vert horiz height width) a)
 -> Matrix
      (Array Unpacked Arbitrary)
      ()
      ()
      Filled
      Filled
      meas
      vert
      horiz
      height
      width
      a
 -> Matrix
      (Array Unpacked Arbitrary)
      ()
      ()
      Filled
      Filled
      meas
      vert
      horiz
      height
      width
      a)
-> (Permutation height
    -> Array (Full meas vert horiz height width) a
    -> Array (Full meas vert horiz height width) a)
-> Permutation height
-> Matrix
     (Array Unpacked Arbitrary)
     ()
     ()
     Filled
     Filled
     meas
     vert
     horiz
     height
     width
     a
-> Matrix
     (Array Unpacked Arbitrary)
     ()
     ()
     Filled
     Filled
     meas
     vert
     horiz
     height
     width
     a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inversion
-> Permutation height
-> Array (Full meas vert horiz height width) a
-> Array (Full meas vert horiz height width) a
forall meas vert horiz height width a.
(Measure meas, C vert, C horiz, C height, Eq height, C width,
 Floating a) =>
Inversion
-> Permutation height
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
Plain.apply Inversion
inverted