{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE UndecidableInstances #-}
module Numeric.LAPACK.Matrix.Inverse where

import qualified Numeric.LAPACK.Matrix.Type.Private as Matrix
import qualified Numeric.LAPACK.Matrix.Layout.Private as Layout
import qualified Numeric.LAPACK.Matrix.Shape as MatrixShape
import qualified Numeric.LAPACK.Matrix.Shape.Omni as Omni
import qualified Numeric.LAPACK.Matrix.Extent.Private as Extent
import qualified Numeric.LAPACK.Matrix.Class as MatrixClass
import qualified Numeric.LAPACK.Matrix.Divide as Divide
import qualified Numeric.LAPACK.Matrix.Multiply as Multiply
import Numeric.LAPACK.Matrix.Divide ((#\|), (-/#))
import Numeric.LAPACK.Matrix.Type.Private (Matrix)

import qualified Type.Data.Num.Unary as Unary


{- |
You may wrap non-diagonal band matrices in 'Wrapper.FillStrips' first
in order to meet the 'Omni.PowerStrip' constraint.
-}
data Inverse typ
data instance
   Matrix (Inverse typ)
      extraLower extraUpper lowerf upperf meas vert horiz height width a
         where
      Inverse ::
         Matrix.QuadraticMeas typ xl xu upper lower meas width height a ->
         Matrix.QuadraticMeas (Inverse typ) (xl,lower) (xu,upper)
            lower upper meas height width a

type family Fill offDiag
type instance Fill (Layout.Bands Unary.Zero) = Layout.Bands Unary.Zero
type instance Fill (Layout.Bands (Unary.Succ k)) = Layout.Filled
type instance Fill Layout.Filled = Layout.Filled

type family InverseExtra xl
type instance InverseExtra (xl,lower) = xl
type family InverseStrip xl
type instance InverseStrip (xl,lower) = lower

data PowerStripFact c = (Omni.PowerStrip c) => PowerStripFact

filledPowerStripFact ::
   (Omni.Strip c) => Omni.StripSingleton c -> PowerStripFact (Fill c)
filledPowerStripFact :: forall c. Strip c => StripSingleton c -> PowerStripFact (Fill c)
filledPowerStripFact StripSingleton c
w =
   case StripSingleton c
w of
      StripSingleton c
Omni.StripFilled -> PowerStripFact Filled
PowerStripFact (Fill c)
forall c. PowerStrip c => PowerStripFact c
PowerStripFact
      Omni.StripBands HeadSingleton offDiag
Unary.Zero -> PowerStripFact (Bands Zero)
PowerStripFact (Fill c)
forall c. PowerStrip c => PowerStripFact c
PowerStripFact
      Omni.StripBands HeadSingleton offDiag
Unary.Succ -> PowerStripFact Filled
PowerStripFact (Fill c)
forall c. PowerStrip c => PowerStripFact c
PowerStripFact



instance (Matrix.Transpose typ) => Matrix.Transpose (Inverse typ) where
   type TransposeExtra (Inverse typ) extra =
         Matrix.TransposeExtra typ (InverseExtra extra)
   transpose :: forall xl xu meas vert horiz height width a lower upper.
(TransposeExtra (Inverse typ) xl, TransposeExtra (Inverse typ) xu,
 Measure meas, C vert, C horiz, C height, C width, Floating a) =>
Matrix
  (Inverse typ) xl xu lower upper meas vert horiz height width a
-> Matrix
     (Inverse typ) xu xl upper lower meas horiz vert width height a
transpose (Inverse QuadraticMeas typ xl xu upper lower meas width height a
a) = QuadraticMeas typ xu xl lower upper meas height width a
-> QuadraticMeas
     (Inverse typ)
     (xu, upper)
     (xl, lower)
     upper
     lower
     meas
     width
     height
     a
forall typ xl xu upper lower meas width height a.
QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     a
Inverse (QuadraticMeas typ xu xl lower upper meas height width a
 -> QuadraticMeas
      (Inverse typ)
      (xu, upper)
      (xl, lower)
      upper
      lower
      meas
      width
      height
      a)
-> QuadraticMeas typ xu xl lower upper meas height width a
-> QuadraticMeas
     (Inverse typ)
     (xu, upper)
     (xl, lower)
     upper
     lower
     meas
     width
     height
     a
forall a b. (a -> b) -> a -> b
$ QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas typ xu xl lower upper meas height width a
forall typ xl xu meas vert horiz height width a lower upper.
(Transpose typ, TransposeExtra typ xl, TransposeExtra typ xu,
 Measure meas, C vert, C horiz, C height, C width, Floating a) =>
Matrix typ xl xu lower upper meas vert horiz height width a
-> Matrix typ xu xl upper lower meas horiz vert width height a
forall xl xu meas vert horiz height width a lower upper.
(TransposeExtra typ xl, TransposeExtra typ xu, Measure meas,
 C vert, C horiz, C height, C width, Floating a) =>
Matrix typ xl xu lower upper meas vert horiz height width a
-> Matrix typ xu xl upper lower meas horiz vert width height a
Matrix.transpose QuadraticMeas typ xl xu upper lower meas width height a
a

instance (Matrix.MultiplySame typ) => Matrix.MultiplySame (Inverse typ) where
   type MultiplySameExtra (Inverse typ) extra =
         (Matrix.MultiplySameExtra typ (InverseExtra extra),
          MatrixShape.PowerStrip (InverseStrip extra))
   multiplySame :: forall matrix xl xu lower upper meas vert horiz sh a.
(matrix
 ~ Matrix (Inverse typ) xl xu lower upper meas vert horiz sh sh a,
 MultiplySameExtra (Inverse typ) xl,
 MultiplySameExtra (Inverse typ) xu, PowerStrip lower,
 PowerStrip upper, Measure meas, C vert, C horiz, C sh, Eq sh,
 Floating a) =>
matrix -> matrix -> matrix
multiplySame (Inverse QuadraticMeas typ xl xu upper lower meas sh sh a
a) (Inverse QuadraticMeas typ xl xu upper lower meas sh sh a
b) = QuadraticMeas typ xl xu upper lower meas sh sh a
-> QuadraticMeas
     (Inverse typ) (xl, lower) (xu, upper) lower upper meas sh sh a
forall typ xl xu upper lower meas width height a.
QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     a
Inverse (QuadraticMeas typ xl xu upper lower meas sh sh a
 -> QuadraticMeas
      (Inverse typ) (xl, lower) (xu, upper) lower upper meas sh sh a)
-> QuadraticMeas typ xl xu upper lower meas sh sh a
-> QuadraticMeas
     (Inverse typ) (xl, lower) (xu, upper) lower upper meas sh sh a
forall a b. (a -> b) -> a -> b
$ QuadraticMeas typ xl xu upper lower meas sh sh a
-> QuadraticMeas typ xl xu upper lower meas sh sh a
-> QuadraticMeas typ xl xu upper lower meas sh sh a
forall typ matrix xl xu lower upper meas vert horiz sh a.
(MultiplySame typ,
 matrix ~ Matrix typ xl xu lower upper meas vert horiz sh sh a,
 MultiplySameExtra typ xl, MultiplySameExtra typ xu,
 PowerStrip lower, PowerStrip upper, Measure meas, C vert, C horiz,
 C sh, Eq sh, Floating a) =>
matrix -> matrix -> matrix
forall matrix xl xu lower upper meas vert horiz sh a.
(matrix ~ Matrix typ xl xu lower upper meas vert horiz sh sh a,
 MultiplySameExtra typ xl, MultiplySameExtra typ xu,
 PowerStrip lower, PowerStrip upper, Measure meas, C vert, C horiz,
 C sh, Eq sh, Floating a) =>
matrix -> matrix -> matrix
Matrix.multiplySame QuadraticMeas typ xl xu upper lower meas sh sh a
b QuadraticMeas typ xl xu upper lower meas sh sh a
QuadraticMeas typ xl xu upper lower meas sh sh a
a

instance (Matrix.Box typ) => Matrix.Box (Inverse typ) where
   type BoxExtra (Inverse typ) extra = Matrix.BoxExtra typ (InverseExtra extra)
   extent :: forall xl xu meas vert horiz lower upper height width a.
(BoxExtra (Inverse typ) xl, BoxExtra (Inverse typ) xu,
 Measure meas, C vert, C horiz) =>
Matrix
  (Inverse typ) xl xu lower upper meas vert horiz height width a
-> Extent meas vert horiz height width
extent (Inverse QuadraticMeas typ xl xu upper lower meas width height a
m) = Extent meas horiz vert width height
-> Extent meas vert horiz height width
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 (Extent meas horiz vert width height
 -> Extent meas vert horiz height width)
-> Extent meas horiz vert width height
-> Extent meas vert horiz height width
forall a b. (a -> b) -> a -> b
$ Matrix typ xl xu upper lower meas horiz vert width height a
-> Extent meas horiz vert width height
forall typ xl xu meas vert horiz lower upper height width a.
(Box typ, BoxExtra typ xl, BoxExtra typ xu, Measure meas, C vert,
 C horiz) =>
Matrix typ xl xu lower upper meas vert horiz height width a
-> Extent meas vert horiz height width
forall xl xu meas vert horiz lower upper height width a.
(BoxExtra typ xl, BoxExtra typ xu, Measure meas, C vert,
 C horiz) =>
Matrix typ xl xu lower upper meas vert horiz height width a
-> Extent meas vert horiz height width
Matrix.extent Matrix typ xl xu upper lower meas horiz vert width height a
QuadraticMeas typ xl xu upper lower meas width height a
m
   height :: forall xl xu meas vert horiz lower upper height width a.
(BoxExtra (Inverse typ) xl, BoxExtra (Inverse typ) xu,
 Measure meas, C vert, C horiz) =>
Matrix
  (Inverse typ) xl xu lower upper meas vert horiz height width a
-> height
height (Inverse QuadraticMeas typ xl xu upper lower meas width height a
m) = QuadraticMeas typ xl xu upper lower meas width height a -> height
forall typ xl xu meas vert horiz lower upper height width a.
(Box typ, BoxExtra typ xl, BoxExtra typ xu, Measure meas, C vert,
 C horiz) =>
Matrix typ xl xu lower upper meas vert horiz height width a
-> width
forall xl xu meas vert horiz lower upper height width a.
(BoxExtra typ xl, BoxExtra typ xu, Measure meas, C vert,
 C horiz) =>
Matrix typ xl xu lower upper meas vert horiz height width a
-> width
Matrix.width QuadraticMeas typ xl xu upper lower meas width height a
m
   width :: forall xl xu meas vert horiz lower upper height width a.
(BoxExtra (Inverse typ) xl, BoxExtra (Inverse typ) xu,
 Measure meas, C vert, C horiz) =>
Matrix
  (Inverse typ) xl xu lower upper meas vert horiz height width a
-> width
width (Inverse QuadraticMeas typ xl xu upper lower meas width height a
m) = QuadraticMeas typ xl xu upper lower meas width height a -> width
forall typ xl xu meas vert horiz lower upper height width a.
(Box typ, BoxExtra typ xl, BoxExtra typ xu, Measure meas, C vert,
 C horiz) =>
Matrix typ xl xu lower upper meas vert horiz height width a
-> height
forall xl xu meas vert horiz lower upper height width a.
(BoxExtra typ xl, BoxExtra typ xu, Measure meas, C vert,
 C horiz) =>
Matrix typ xl xu lower upper meas vert horiz height width a
-> height
Matrix.height QuadraticMeas typ xl xu upper lower meas width height a
m

instance (Matrix.ToQuadratic typ) => Matrix.ToQuadratic (Inverse typ) where
   heightToQuadratic :: forall meas xl xu lower upper height width a.
Measure meas =>
QuadraticMeas (Inverse typ) xl xu lower upper meas height width a
-> Quadratic (Inverse typ) xl xu lower upper height a
heightToQuadratic (Inverse QuadraticMeas typ xl xu upper lower meas width height a
m) = QuadraticMeas typ xl xu upper lower Shape height height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     Shape
     height
     height
     a
forall typ xl xu upper lower meas width height a.
QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     a
Inverse (QuadraticMeas typ xl xu upper lower Shape height height a
 -> QuadraticMeas
      (Inverse typ)
      (xl, lower)
      (xu, upper)
      lower
      upper
      Shape
      height
      height
      a)
-> QuadraticMeas typ xl xu upper lower Shape height height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     Shape
     height
     height
     a
forall a b. (a -> b) -> a -> b
$ QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas typ xl xu upper lower Shape height height a
forall typ meas xl xu lower upper height width a.
(ToQuadratic typ, Measure meas) =>
QuadraticMeas typ xl xu lower upper meas height width a
-> Quadratic typ xl xu lower upper width a
forall meas xl xu lower upper height width a.
Measure meas =>
QuadraticMeas typ xl xu lower upper meas height width a
-> Quadratic typ xl xu lower upper width a
Matrix.widthToQuadratic QuadraticMeas typ xl xu upper lower meas width height a
m
   widthToQuadratic :: forall meas xl xu lower upper height width a.
Measure meas =>
QuadraticMeas (Inverse typ) xl xu lower upper meas height width a
-> Quadratic (Inverse typ) xl xu lower upper width a
widthToQuadratic (Inverse QuadraticMeas typ xl xu upper lower meas width height a
m) = QuadraticMeas typ xl xu upper lower Shape width width a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     Shape
     width
     width
     a
forall typ xl xu upper lower meas width height a.
QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     a
Inverse (QuadraticMeas typ xl xu upper lower Shape width width a
 -> QuadraticMeas
      (Inverse typ)
      (xl, lower)
      (xu, upper)
      lower
      upper
      Shape
      width
      width
      a)
-> QuadraticMeas typ xl xu upper lower Shape width width a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     Shape
     width
     width
     a
forall a b. (a -> b) -> a -> b
$ QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas typ xl xu upper lower Shape width width a
forall typ meas xl xu lower upper height width a.
(ToQuadratic typ, Measure meas) =>
QuadraticMeas typ xl xu lower upper meas height width a
-> Quadratic typ xl xu lower upper height a
forall meas xl xu lower upper height width a.
Measure meas =>
QuadraticMeas typ xl xu lower upper meas height width a
-> Quadratic typ xl xu lower upper height a
Matrix.heightToQuadratic QuadraticMeas typ xl xu upper lower meas width height a
m

instance (MatrixClass.Complex typ) => MatrixClass.Complex (Inverse typ) where
   conjugate :: forall xl xu lower upper meas vert horiz height width
       (matrix :: * -> *) a.
(Matrix
   (Inverse typ) xl xu lower upper meas vert horiz height width
 ~ matrix,
 Measure meas, C vert, C horiz, C height, C width, Floating a) =>
matrix a -> matrix a
conjugate (Inverse QuadraticMeas typ xl xu upper lower meas width height a
m) = QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     a
forall typ xl xu upper lower meas width height a.
QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     a
Inverse (QuadraticMeas typ xl xu upper lower meas width height a
 -> QuadraticMeas
      (Inverse typ)
      (xl, lower)
      (xu, upper)
      lower
      upper
      meas
      height
      width
      a)
-> QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     a
forall a b. (a -> b) -> a -> b
$ QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas typ xl xu upper lower meas width height a
forall typ xl xu lower upper meas vert horiz height width
       (matrix :: * -> *) a.
(Complex typ,
 Matrix typ xl xu lower upper meas vert horiz height width ~ matrix,
 Measure meas, C vert, C horiz, C height, C width, Floating a) =>
matrix a -> matrix a
forall xl xu lower upper meas vert horiz height width
       (matrix :: * -> *) a.
(Matrix typ xl xu lower upper meas vert horiz height width
 ~ matrix,
 Measure meas, C vert, C horiz, C height, C width, Floating a) =>
matrix a -> matrix a
MatrixClass.conjugate QuadraticMeas typ xl xu upper lower meas width height a
m
   fromReal :: forall xl xu lower upper meas vert horiz height width
       (matrix :: * -> *) a.
(Matrix
   (Inverse typ) xl xu lower upper meas vert horiz height width
 ~ matrix,
 Measure meas, C vert, C horiz, C height, C width, Floating a) =>
matrix (RealOf a) -> matrix a
fromReal (Inverse QuadraticMeas typ xl xu upper lower meas width height (RealOf a)
m) = QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     a
forall typ xl xu upper lower meas width height a.
QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     a
Inverse (QuadraticMeas typ xl xu upper lower meas width height a
 -> QuadraticMeas
      (Inverse typ)
      (xl, lower)
      (xu, upper)
      lower
      upper
      meas
      height
      width
      a)
-> QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     a
forall a b. (a -> b) -> a -> b
$ QuadraticMeas typ xl xu upper lower meas width height (RealOf a)
-> QuadraticMeas typ xl xu upper lower meas width height a
forall typ xl xu lower upper meas vert horiz height width
       (matrix :: * -> *) a.
(Complex typ,
 Matrix typ xl xu lower upper meas vert horiz height width ~ matrix,
 Measure meas, C vert, C horiz, C height, C width, Floating a) =>
matrix (RealOf a) -> matrix a
forall xl xu lower upper meas vert horiz height width
       (matrix :: * -> *) a.
(Matrix typ xl xu lower upper meas vert horiz height width
 ~ matrix,
 Measure meas, C vert, C horiz, C height, C width, Floating a) =>
matrix (RealOf a) -> matrix a
MatrixClass.fromReal QuadraticMeas typ xl xu upper lower meas width height (RealOf a)
m
   toComplex :: forall xl xu lower upper meas vert horiz height width
       (matrix :: * -> *) a.
(Matrix
   (Inverse typ) xl xu lower upper meas vert horiz height width
 ~ matrix,
 Measure meas, C vert, C horiz, C height, C width, Floating a) =>
matrix a -> matrix (ComplexOf a)
toComplex (Inverse QuadraticMeas typ xl xu upper lower meas width height a
m) = QuadraticMeas
  typ xl xu upper lower meas width height (Complex (RealOf a))
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     (Complex (RealOf a))
forall typ xl xu upper lower meas width height a.
QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     a
Inverse (QuadraticMeas
   typ xl xu upper lower meas width height (Complex (RealOf a))
 -> QuadraticMeas
      (Inverse typ)
      (xl, lower)
      (xu, upper)
      lower
      upper
      meas
      height
      width
      (Complex (RealOf a)))
-> QuadraticMeas
     typ xl xu upper lower meas width height (Complex (RealOf a))
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     (Complex (RealOf a))
forall a b. (a -> b) -> a -> b
$ QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas
     typ xl xu upper lower meas width height (Complex (RealOf a))
forall typ xl xu lower upper meas vert horiz height width
       (matrix :: * -> *) a.
(Complex typ,
 Matrix typ xl xu lower upper meas vert horiz height width ~ matrix,
 Measure meas, C vert, C horiz, C height, C width, Floating a) =>
matrix a -> matrix (ComplexOf a)
forall xl xu lower upper meas vert horiz height width
       (matrix :: * -> *) a.
(Matrix typ xl xu lower upper meas vert horiz height width
 ~ matrix,
 Measure meas, C vert, C horiz, C height, C width, Floating a) =>
matrix a -> matrix (ComplexOf a)
MatrixClass.toComplex QuadraticMeas typ xl xu upper lower meas width height a
m


instance
   (Divide.Solve typ, Matrix.ToQuadratic typ) =>
      Multiply.MultiplyVector (Inverse typ) where
   type MultiplyVectorExtra (Inverse typ) extra =
         (Multiply.MultiplyVectorExtra typ (InverseExtra extra),
          Divide.SolveExtra typ (InverseExtra extra),
          Matrix.BoxExtra typ (InverseExtra extra),
          Omni.Strip (InverseStrip extra))
   matrixVector :: forall xl xu lower upper meas vert horiz height width a.
(MultiplyVectorExtra (Inverse typ) xl,
 MultiplyVectorExtra (Inverse typ) xu, Strip lower, Strip upper,
 Measure meas, C vert, C horiz, C height, C width, Eq width,
 Floating a) =>
Matrix
  (Inverse typ) xl xu lower upper meas vert horiz height width a
-> Vector width a -> Vector height a
matrixVector (Inverse QuadraticMeas typ xl xu upper lower meas width height a
a) Vector width a
x = QuadraticMeas typ xl xu upper lower meas width height a
aQuadraticMeas typ xl xu upper lower meas width height a
-> Vector width a -> Vector height a
forall typ xl xu lower upper meas height width a.
(Solve typ, ToQuadratic typ, SolveExtra typ xl, SolveExtra typ xu,
 BoxExtra typ xl, BoxExtra typ xu, Strip lower, Strip upper,
 Measure meas, C height, C width, Eq height, Floating a) =>
QuadraticMeas typ xl xu lower upper meas height width a
-> Vector height a -> Vector width a
#\|Vector width a
x
   vectorMatrix :: forall xl xu lower upper meas vert horiz height width a.
(MultiplyVectorExtra (Inverse typ) xl,
 MultiplyVectorExtra (Inverse typ) xu, Strip lower, Strip upper,
 Measure meas, C vert, C horiz, C height, C width, Eq height,
 Floating a) =>
Vector height a
-> Matrix
     (Inverse typ) xl xu lower upper meas vert horiz height width a
-> Vector width a
vectorMatrix Vector height a
x (Inverse QuadraticMeas typ xl xu upper lower meas width height a
a) = Vector height a
xVector height a
-> QuadraticMeas typ xl xu upper lower meas width height a
-> Vector width a
forall typ xl xu lower upper meas height width a.
(Solve typ, ToQuadratic typ, SolveExtra typ xl, SolveExtra typ xu,
 BoxExtra typ xl, BoxExtra typ xu, Strip lower, Strip upper,
 Measure meas, C height, C width, Eq width, Floating a) =>
Vector width a
-> QuadraticMeas typ xl xu lower upper meas height width a
-> Vector height a
-/#QuadraticMeas typ xl xu upper lower meas width height a
a

instance
   (Divide.Solve typ, Matrix.ToQuadratic typ) =>
      Multiply.MultiplySquare (Inverse typ) where
   type MultiplySquareExtra (Inverse typ) extra =
         (Multiply.MultiplySquareExtra typ (InverseExtra extra),
          Divide.SolveExtra typ (InverseExtra extra),
          Matrix.BoxExtra typ (InverseExtra extra),
          Omni.Strip (InverseStrip extra))
   transposableSquare :: forall xl xu lower upper meas vert horiz height width a.
(MultiplySquareExtra (Inverse typ) xl,
 MultiplySquareExtra (Inverse typ) xu, Strip lower, Strip upper,
 Measure meas, C vert, C horiz, C height, Eq height, C width,
 Floating a) =>
Transposition
-> Quadratic (Inverse typ) xl xu lower upper height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
transposableSquare Transposition
trans (Inverse QuadraticMeas typ xl xu upper lower Shape height height a
a) = Transposition
-> QuadraticMeas typ xl xu upper lower Shape height height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
forall typ xl xu lower upper meas vert horiz height width a.
(Solve typ, SolveExtra typ xl, SolveExtra typ xu, Strip lower,
 Strip upper, Measure meas, C vert, C horiz, C height, C width,
 Eq height, Floating a) =>
Transposition
-> Quadratic typ xl xu lower upper height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
forall xl xu lower upper meas vert horiz height width a.
(SolveExtra typ xl, SolveExtra typ xu, Strip lower, Strip upper,
 Measure meas, C vert, C horiz, C height, C width, Eq height,
 Floating a) =>
Transposition
-> Quadratic typ xl xu lower upper height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
Divide.solve Transposition
trans QuadraticMeas typ xl xu upper lower Shape height height a
a
   squareFull :: forall xl xu lower upper meas vert horiz height width a.
(MultiplySquareExtra (Inverse typ) xl,
 MultiplySquareExtra (Inverse typ) xu, Strip lower, Strip upper,
 Measure meas, C vert, C horiz, C height, Eq height, C width,
 Floating a) =>
Quadratic (Inverse typ) xl xu lower upper height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
squareFull (Inverse QuadraticMeas typ xl xu upper lower Shape height height a
a) Full meas vert horiz height width a
b = QuadraticMeas typ xl xu upper lower Shape height height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
forall typ xl xu lower upper meas vert horiz height width a.
(Solve typ, SolveExtra typ xl, SolveExtra typ xu, Strip lower,
 Strip upper, Measure meas, C vert, C horiz, C height, C width,
 Eq height, Floating a) =>
Quadratic typ xl xu lower upper height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
forall xl xu lower upper meas vert horiz height width a.
(SolveExtra typ xl, SolveExtra typ xu, Strip lower, Strip upper,
 Measure meas, C vert, C horiz, C height, C width, Eq height,
 Floating a) =>
Quadratic typ xl xu lower upper height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
Divide.solveRight QuadraticMeas typ xl xu upper lower Shape height height a
a Full meas vert horiz height width a
b
   fullSquare :: forall xl xu lower upper meas vert horiz height width a.
(MultiplySquareExtra (Inverse typ) xl,
 MultiplySquareExtra (Inverse typ) xu, Strip lower, Strip upper,
 Measure meas, C vert, C horiz, C height, C width, Eq width,
 Floating a) =>
Full meas vert horiz height width a
-> Quadratic (Inverse typ) xl xu lower upper width a
-> Full meas vert horiz height width a
fullSquare Full meas vert horiz height width a
b (Inverse QuadraticMeas typ xl xu upper lower Shape width width a
a) = Full meas vert horiz height width a
-> QuadraticMeas typ xl xu upper lower Shape width width a
-> Full meas vert horiz height width a
forall typ xl xu lower upper meas vert horiz height width a.
(Solve typ, SolveExtra typ xl, SolveExtra typ xu, Strip lower,
 Strip upper, Measure meas, C vert, C horiz, C height, C width,
 Eq width, Floating a) =>
Full meas vert horiz height width a
-> Quadratic typ xl xu lower upper width a
-> Full meas vert horiz height width a
forall xl xu lower upper meas vert horiz height width a.
(SolveExtra typ xl, SolveExtra typ xu, Strip lower, Strip upper,
 Measure meas, C vert, C horiz, C height, C width, Eq width,
 Floating a) =>
Full meas vert horiz height width a
-> Quadratic typ xl xu lower upper width a
-> Full meas vert horiz height width a
Divide.solveLeft Full meas vert horiz height width a
b QuadraticMeas typ xl xu upper lower Shape width width a
a

instance (Multiply.Power typ) => Multiply.Power (Inverse typ) where
   type PowerExtra (Inverse typ) extra =
         (Multiply.PowerExtra typ (InverseExtra extra),
          MatrixShape.PowerStrip (InverseStrip extra))
   square :: forall xl xu lower upper sh a.
(PowerExtra (Inverse typ) xl, PowerExtra (Inverse typ) xu,
 PowerStrip lower, PowerStrip upper, C sh, Floating a) =>
Quadratic (Inverse typ) xl xu lower upper sh a
-> Quadratic (Inverse typ) xl xu lower upper sh a
square (Inverse QuadraticMeas typ xl xu upper lower Shape sh sh a
a) = QuadraticMeas typ xl xu upper lower Shape sh sh a
-> QuadraticMeas
     (Inverse typ) (xl, lower) (xu, upper) lower upper Shape sh sh a
forall typ xl xu upper lower meas width height a.
QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     a
Inverse (QuadraticMeas typ xl xu upper lower Shape sh sh a
 -> QuadraticMeas
      (Inverse typ) (xl, lower) (xu, upper) lower upper Shape sh sh a)
-> QuadraticMeas typ xl xu upper lower Shape sh sh a
-> QuadraticMeas
     (Inverse typ) (xl, lower) (xu, upper) lower upper Shape sh sh a
forall a b. (a -> b) -> a -> b
$ QuadraticMeas typ xl xu upper lower Shape sh sh a
-> QuadraticMeas typ xl xu upper lower Shape sh sh a
forall typ xl xu lower upper sh a.
(Power typ, PowerExtra typ xl, PowerExtra typ xu, PowerStrip lower,
 PowerStrip upper, C sh, Floating a) =>
Quadratic typ xl xu lower upper sh a
-> Quadratic typ xl xu lower upper sh a
forall xl xu lower upper sh a.
(PowerExtra typ xl, PowerExtra typ xu, PowerStrip lower,
 PowerStrip upper, C sh, Floating a) =>
Quadratic typ xl xu lower upper sh a
-> Quadratic typ xl xu lower upper sh a
Multiply.square QuadraticMeas typ xl xu upper lower Shape sh sh a
a
   power :: forall xl xu lower upper sh a.
(PowerExtra (Inverse typ) xl, PowerExtra (Inverse typ) xu,
 PowerStrip lower, PowerStrip upper, C sh, Floating a) =>
Integer
-> Quadratic (Inverse typ) xl xu lower upper sh a
-> Quadratic (Inverse typ) xl xu lower upper sh a
power Integer
n (Inverse QuadraticMeas typ xl xu upper lower Shape sh sh a
a) = QuadraticMeas typ xl xu upper lower Shape sh sh a
-> QuadraticMeas
     (Inverse typ) (xl, lower) (xu, upper) lower upper Shape sh sh a
forall typ xl xu upper lower meas width height a.
QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     a
Inverse (QuadraticMeas typ xl xu upper lower Shape sh sh a
 -> QuadraticMeas
      (Inverse typ) (xl, lower) (xu, upper) lower upper Shape sh sh a)
-> QuadraticMeas typ xl xu upper lower Shape sh sh a
-> QuadraticMeas
     (Inverse typ) (xl, lower) (xu, upper) lower upper Shape sh sh a
forall a b. (a -> b) -> a -> b
$ Integer
-> QuadraticMeas typ xl xu upper lower Shape sh sh a
-> QuadraticMeas typ xl xu upper lower Shape sh sh a
forall typ xl xu lower upper sh a.
(Power typ, PowerExtra typ xl, PowerExtra typ xu, PowerStrip lower,
 PowerStrip upper, C sh, Floating a) =>
Integer
-> Quadratic typ xl xu lower upper sh a
-> Quadratic typ xl xu lower upper sh a
forall xl xu lower upper sh a.
(PowerExtra typ xl, PowerExtra typ xu, PowerStrip lower,
 PowerStrip upper, C sh, Floating a) =>
Integer
-> Quadratic typ xl xu lower upper sh a
-> Quadratic typ xl xu lower upper sh a
Multiply.power Integer
n QuadraticMeas typ xl xu upper lower Shape sh sh a
a
   powers1 :: forall xl xu lower upper sh a.
(PowerExtra (Inverse typ) xl, PowerExtra (Inverse typ) xu,
 PowerStrip lower, PowerStrip upper, C sh, Floating a) =>
Quadratic (Inverse typ) xl xu lower upper sh a
-> Stream (Quadratic (Inverse typ) xl xu lower upper sh a)
powers1 (Inverse QuadraticMeas typ xl xu upper lower Shape sh sh a
a) = (QuadraticMeas typ xl xu upper lower Shape sh sh a
 -> Quadratic (Inverse typ) xl xu lower upper sh a)
-> Stream (QuadraticMeas typ xl xu upper lower Shape sh sh a)
-> Stream (Quadratic (Inverse typ) xl xu lower upper sh a)
forall a b. (a -> b) -> Stream a -> Stream b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap QuadraticMeas typ xl xu upper lower Shape sh sh a
-> Quadratic (Inverse typ) xl xu lower upper sh a
QuadraticMeas typ xl xu upper lower Shape sh sh a
-> QuadraticMeas
     (Inverse typ) (xl, lower) (xu, upper) lower upper Shape sh sh a
forall typ xl xu upper lower meas width height a.
QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     a
Inverse (Stream (QuadraticMeas typ xl xu upper lower Shape sh sh a)
 -> Stream (Quadratic (Inverse typ) xl xu lower upper sh a))
-> Stream (QuadraticMeas typ xl xu upper lower Shape sh sh a)
-> Stream (Quadratic (Inverse typ) xl xu lower upper sh a)
forall a b. (a -> b) -> a -> b
$ QuadraticMeas typ xl xu upper lower Shape sh sh a
-> Stream (QuadraticMeas typ xl xu upper lower Shape sh sh a)
forall typ xl xu lower upper sh a.
(Power typ, PowerExtra typ xl, PowerExtra typ xu, PowerStrip lower,
 PowerStrip upper, C sh, Floating a) =>
Quadratic typ xl xu lower upper sh a
-> Stream (Quadratic typ xl xu lower upper sh a)
forall xl xu lower upper sh a.
(PowerExtra typ xl, PowerExtra typ xu, PowerStrip lower,
 PowerStrip upper, C sh, Floating a) =>
Quadratic typ xl xu lower upper sh a
-> Stream (Quadratic typ xl xu lower upper sh a)
Multiply.powers1 QuadraticMeas typ xl xu upper lower Shape sh sh a
a


instance (Divide.Determinant typ) => Divide.Determinant (Inverse typ) where
   type DeterminantExtra (Inverse typ) extra =
         (Divide.DeterminantExtra typ (InverseExtra extra),
          MatrixShape.PowerStrip (InverseStrip extra))
   determinant :: forall xl xu lower upper sh a.
(DeterminantExtra (Inverse typ) xl,
 DeterminantExtra (Inverse typ) xu, Strip lower, Strip upper, C sh,
 Floating a) =>
Quadratic (Inverse typ) xl xu lower upper sh a -> a
determinant (Inverse QuadraticMeas typ xl xu upper lower Shape sh sh a
a) = a -> a
forall a. Fractional a => a -> a
recip (a -> a) -> a -> a
forall a b. (a -> b) -> a -> b
$ QuadraticMeas typ xl xu upper lower Shape sh sh a -> a
forall typ xl xu lower upper sh a.
(Determinant typ, DeterminantExtra typ xl, DeterminantExtra typ xu,
 Strip lower, Strip upper, C sh, Floating a) =>
Quadratic typ xl xu lower upper sh a -> a
forall xl xu lower upper sh a.
(DeterminantExtra typ xl, DeterminantExtra typ xu, Strip lower,
 Strip upper, C sh, Floating a) =>
Quadratic typ xl xu lower upper sh a -> a
Divide.determinant QuadraticMeas typ xl xu upper lower Shape sh sh a
a

instance
   (Multiply.MultiplySquare typ, Matrix.ToQuadratic typ) =>
      Divide.Solve (Inverse typ) where
   type SolveExtra (Inverse typ) extra =
         (Divide.SolveExtra typ (InverseExtra extra),
          Multiply.MultiplySquareExtra typ (InverseExtra extra),
          MatrixShape.PowerStrip (InverseStrip extra))
   solve :: forall xl xu lower upper meas vert horiz height width a.
(SolveExtra (Inverse typ) xl, SolveExtra (Inverse typ) xu,
 Strip lower, Strip upper, Measure meas, C vert, C horiz, C height,
 C width, Eq height, Floating a) =>
Transposition
-> Quadratic (Inverse typ) xl xu lower upper height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
solve Transposition
trans (Inverse QuadraticMeas typ xl xu upper lower Shape height height a
a) = Transposition
-> QuadraticMeas typ xl xu upper lower Shape height height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
forall typ xl xu lower upper meas vert horiz height width a.
(MultiplySquare typ, MultiplySquareExtra typ xl,
 MultiplySquareExtra typ xu, Strip lower, Strip upper, Measure meas,
 C vert, C horiz, C height, Eq height, C width, Floating a) =>
Transposition
-> Quadratic typ xl xu lower upper height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
forall xl xu lower upper meas vert horiz height width a.
(MultiplySquareExtra typ xl, MultiplySquareExtra typ xu,
 Strip lower, Strip upper, Measure meas, C vert, C horiz, C height,
 Eq height, C width, Floating a) =>
Transposition
-> Quadratic typ xl xu lower upper height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
Multiply.transposableSquare Transposition
trans QuadraticMeas typ xl xu upper lower Shape height height a
a
   solveRight :: forall xl xu lower upper meas vert horiz height width a.
(SolveExtra (Inverse typ) xl, SolveExtra (Inverse typ) xu,
 Strip lower, Strip upper, Measure meas, C vert, C horiz, C height,
 C width, Eq height, Floating a) =>
Quadratic (Inverse typ) xl xu lower upper height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
solveRight (Inverse QuadraticMeas typ xl xu upper lower Shape height height a
a) Full meas vert horiz height width a
b = QuadraticMeas typ xl xu upper lower Shape height height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
forall typ xl xu lower upper meas vert horiz height width a.
(MultiplySquare typ, MultiplySquareExtra typ xl,
 MultiplySquareExtra typ xu, Strip lower, Strip upper, Measure meas,
 C vert, C horiz, C height, Eq height, C width, Floating a) =>
Quadratic typ xl xu lower upper height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
forall xl xu lower upper meas vert horiz height width a.
(MultiplySquareExtra typ xl, MultiplySquareExtra typ xu,
 Strip lower, Strip upper, Measure meas, C vert, C horiz, C height,
 Eq height, C width, Floating a) =>
Quadratic typ xl xu lower upper height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
Multiply.squareFull QuadraticMeas typ xl xu upper lower Shape height height a
a Full meas vert horiz height width a
b
   solveLeft :: forall xl xu lower upper meas vert horiz height width a.
(SolveExtra (Inverse typ) xl, SolveExtra (Inverse typ) xu,
 Strip lower, Strip upper, Measure meas, C vert, C horiz, C height,
 C width, Eq width, Floating a) =>
Full meas vert horiz height width a
-> Quadratic (Inverse typ) xl xu lower upper width a
-> Full meas vert horiz height width a
solveLeft Full meas vert horiz height width a
b (Inverse QuadraticMeas typ xl xu upper lower Shape width width a
a) = Full meas vert horiz height width a
-> QuadraticMeas typ xl xu upper lower Shape width width a
-> Full meas vert horiz height width a
forall typ xl xu lower upper meas vert horiz height width a.
(MultiplySquare typ, MultiplySquareExtra typ xl,
 MultiplySquareExtra typ xu, Strip lower, Strip upper, Measure meas,
 C vert, C horiz, C height, C width, Eq width, Floating a) =>
Full meas vert horiz height width a
-> Quadratic typ xl xu lower upper width a
-> Full meas vert horiz height width a
forall xl xu lower upper meas vert horiz height width a.
(MultiplySquareExtra typ xl, MultiplySquareExtra typ xu,
 Strip lower, Strip upper, Measure meas, C vert, C horiz, C height,
 C width, Eq width, Floating a) =>
Full meas vert horiz height width a
-> Quadratic typ xl xu lower upper width a
-> Full meas vert horiz height width a
Multiply.fullSquare Full meas vert horiz height width a
b QuadraticMeas typ xl xu upper lower Shape width width a
a

instance
   (Divide.Inverse typ, Multiply.MultiplySquare typ, Matrix.ToQuadratic typ) =>
      Divide.Inverse (Inverse typ) where
   type InverseExtra (Inverse typ) extra =
         (Divide.InverseExtra typ (InverseExtra extra),
          Multiply.MultiplySquareExtra typ (InverseExtra extra),
          MatrixShape.PowerStrip (InverseStrip extra))
   inverse :: forall xl xu lower upper meas height width a.
(InverseExtra (Inverse typ) xl, InverseExtra (Inverse typ) xu,
 PowerStrip lower, PowerStrip upper, Measure meas, C height,
 C width, Floating a) =>
QuadraticMeas (Inverse typ) xl xu lower upper meas height width a
-> QuadraticMeas
     (Inverse typ) xl xu lower upper meas width height a
inverse (Inverse QuadraticMeas typ xl xu upper lower meas width height a
a) = QuadraticMeas typ xl xu upper lower meas height width a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     width
     height
     a
forall typ xl xu upper lower meas width height a.
QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     height
     width
     a
Inverse (QuadraticMeas typ xl xu upper lower meas height width a
 -> QuadraticMeas
      (Inverse typ)
      (xl, lower)
      (xu, upper)
      lower
      upper
      meas
      width
      height
      a)
-> QuadraticMeas typ xl xu upper lower meas height width a
-> QuadraticMeas
     (Inverse typ)
     (xl, lower)
     (xu, upper)
     lower
     upper
     meas
     width
     height
     a
forall a b. (a -> b) -> a -> b
$ QuadraticMeas typ xl xu upper lower meas width height a
-> QuadraticMeas typ xl xu upper lower meas height width a
forall typ xl xu lower upper meas height width a.
(Inverse typ, InverseExtra typ xl, InverseExtra typ xu,
 PowerStrip lower, PowerStrip upper, Measure meas, C height,
 C width, Floating a) =>
QuadraticMeas typ xl xu lower upper meas height width a
-> QuadraticMeas typ xl xu lower upper meas width height a
forall xl xu lower upper meas height width a.
(InverseExtra typ xl, InverseExtra typ xu, PowerStrip lower,
 PowerStrip upper, Measure meas, C height, C width, Floating a) =>
QuadraticMeas typ xl xu lower upper meas height width a
-> QuadraticMeas typ xl xu lower upper meas width height a
Divide.inverse QuadraticMeas typ xl xu upper lower meas width height a
a