{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE GADTs #-}
module Numeric.LAPACK.Matrix.Hermitian (
   FlexHermitian,
   Hermitian,
   HermitianPosDef,
   HermitianPosSemidef,
   Transposition(..),

   Hermitian.Semidefinite,
   Hermitian.assureFullRank,
   Hermitian.assureAnyRank,
   Hermitian.relaxSemidefinite,
   Hermitian.relaxIndefinite,
   Hermitian.assurePositiveDefiniteness,
   Hermitian.relaxDefiniteness,
   Hermitian.asUnknownDefiniteness,

   pack,
   size,
   fromList,
   autoFromList,
   identity,
   diagonal,
   takeDiagonal,
   forceOrder,

   stack, (*%%%#),
   split,
   takeTopLeft,
   takeTopRight,
   takeBottomRight,

   toSquare,
   fromSymmetric,

   negate,

   multiplyVector,
   multiplyFull,
   square,

   outer,
   sumRank1, sumRank1NonEmpty,
   sumRank2, sumRank2NonEmpty,

   gramian,            gramianAdjoint,
   congruenceDiagonal, congruenceDiagonalAdjoint,
   congruence,         congruenceAdjoint,
   anticommutator,     anticommutatorAdjoint,
   addAdjoint,

   solve,
   inverse,
   determinant,

   eigenvalues,
   eigensystem,
   ) where

import qualified Numeric.LAPACK.Matrix.Hermitian.Linear as Linear
import qualified Numeric.LAPACK.Matrix.HermitianPositiveDefinite.Linear
                                                         as LinearPD
import qualified Numeric.LAPACK.Matrix.Hermitian.Eigen as Eigen
import qualified Numeric.LAPACK.Matrix.Hermitian.Basic as Basic
import qualified Numeric.LAPACK.Matrix.Symmetric.Unified as Symmetric
import qualified Numeric.LAPACK.Matrix.Mosaic.Packed as Packed
import qualified Numeric.LAPACK.Matrix.Mosaic.Basic as Mosaic
import qualified Numeric.LAPACK.Matrix.Basic as FullBasic

import qualified Numeric.LAPACK.Matrix.Full as Full
import qualified Numeric.LAPACK.Matrix.Array.Hermitian as Hermitian
import qualified Numeric.LAPACK.Matrix.Array.Unpacked as ArrUnpacked
import qualified Numeric.LAPACK.Matrix.Array.Basic as OmniMatrix
import qualified Numeric.LAPACK.Matrix.Array.Private as ArrMatrix
import qualified Numeric.LAPACK.Matrix.Layout.Private as Layout
import qualified Numeric.LAPACK.Matrix.Shape.Omni as Omni
import qualified Numeric.LAPACK.Matrix.Extent as Extent
import qualified Numeric.LAPACK.Vector as Vector
import qualified Numeric.LAPACK.Scalar as Scalar
import qualified Numeric.LAPACK.Shape as ExtShape
import Numeric.LAPACK.Matrix.Array.Mosaic
         (FlexHermitian, FlexHermitianP,
          Hermitian, HermitianP,
          HermitianPosSemidef, HermitianPosSemidefP, HermitianPosDef,
          SymmetricP)
import Numeric.LAPACK.Matrix.Array.Private (Full, General, Square, packTag)
import Numeric.LAPACK.Matrix.Layout.Private (Order)
import Numeric.LAPACK.Matrix.Modifier (Transposition(NonTransposed, Transposed))
import Numeric.LAPACK.Matrix.Private (ShapeInt)
import Numeric.LAPACK.Vector (Vector)
import Numeric.LAPACK.Scalar (RealOf, one)

import qualified Numeric.Netlib.Class as Class

import qualified Type.Data.Bool as TBool
import Type.Data.Bool (True)

import qualified Data.Array.Comfort.Storable.Unchecked as Array
import qualified Data.Array.Comfort.Shape as Shape
import Data.Array.Comfort.Shape ((::+))

import qualified Data.NonEmpty as NonEmpty
import Data.Tuple.HT (mapFst)

import Prelude hiding (negate)


size :: FlexHermitianP pack neg zero pos sh a -> sh
size :: FlexHermitianP pack neg zero pos sh a -> sh
size = Omni
  pack (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh
-> sh
forall pack property lower upper sh.
Omni pack property lower upper Shape Small Small sh sh -> sh
Omni.squareSize (Omni
   pack (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh
 -> sh)
-> (FlexHermitianP pack neg zero pos sh a
    -> Omni
         pack
         (Hermitian neg zero pos)
         Filled
         Filled
         Shape
         Small
         Small
         sh
         sh)
-> FlexHermitianP pack neg zero pos sh a
-> sh
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FlexHermitianP pack neg zero pos sh a
-> Omni
     pack (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh
forall pack property lower upper meas vert horiz height width a.
ArrayMatrix
  pack property lower upper meas vert horiz height width a
-> Omni pack property lower upper meas vert horiz height width
ArrMatrix.shape


fromList ::
   (Shape.C sh, Class.Floating a) => Order -> sh -> [a] -> Hermitian sh a
fromList :: Order -> sh -> [a] -> Hermitian sh a
fromList Order
order sh
sh = Array (Mosaic Packed ConjugateMirror Upper sh) a -> Hermitian sh a
forall pack prop lower upper meas vert horiz height width shape a.
(FromPlain pack prop lower upper meas vert horiz height width,
 Plain pack prop lower upper meas vert horiz height width ~ shape,
 Measure meas, C vert, C horiz, C height, C width, Floating a) =>
Array shape a
-> ArrayMatrix pack prop lower upper meas vert horiz height width a
ArrMatrix.fromVector (Array (Mosaic Packed ConjugateMirror Upper sh) a
 -> Hermitian sh a)
-> ([a] -> Array (Mosaic Packed ConjugateMirror Upper sh) a)
-> [a]
-> Hermitian sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Order
-> sh -> [a] -> Array (Mosaic Packed ConjugateMirror Upper sh) a
forall pack mirror uplo sh a.
(Packing pack, Mirror mirror, UpLo uplo, C sh, Storable a) =>
Order -> sh -> [a] -> Mosaic pack mirror uplo sh a
Mosaic.fromList Order
order sh
sh

autoFromList :: (Class.Floating a) => Order -> [a] -> Hermitian ShapeInt a
autoFromList :: Order -> [a] -> Hermitian ShapeInt a
autoFromList Order
order = Array (Mosaic Packed ConjugateMirror Upper ShapeInt) a
-> Hermitian ShapeInt a
forall pack prop lower upper meas vert horiz height width shape a.
(FromPlain pack prop lower upper meas vert horiz height width,
 Plain pack prop lower upper meas vert horiz height width ~ shape,
 Measure meas, C vert, C horiz, C height, C width, Floating a) =>
Array shape a
-> ArrayMatrix pack prop lower upper meas vert horiz height width a
ArrMatrix.fromVector (Array (Mosaic Packed ConjugateMirror Upper ShapeInt) a
 -> Hermitian ShapeInt a)
-> ([a] -> Array (Mosaic Packed ConjugateMirror Upper ShapeInt) a)
-> [a]
-> Hermitian ShapeInt a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Order
-> [a] -> Array (Mosaic Packed ConjugateMirror Upper ShapeInt) a
forall pack mirror uplo a.
(Packing pack, Mirror mirror, UpLo uplo, Storable a) =>
Order -> [a] -> Mosaic pack mirror uplo ShapeInt a
Mosaic.autoFromList Order
order


identity ::
   (Shape.C sh, Class.Floating a) =>
   Order -> sh -> HermitianPosDef sh a
identity :: Order -> sh -> HermitianPosDef sh a
identity Order
order = Array (HermitianP Packed sh) a -> HermitianPosDef 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 (HermitianP Packed sh) a -> HermitianPosDef sh a)
-> (sh -> Array (HermitianP Packed sh) a)
-> sh
-> HermitianPosDef sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Order -> sh -> Array (HermitianP Packed sh) a
forall mirror uplo sh a.
(Mirror mirror, UpLo uplo, C sh, Floating a) =>
Order -> sh -> Mosaic mirror uplo sh a
Packed.identity Order
order

diagonal ::
   (Shape.C sh, Class.Floating a) =>
   Order -> Vector sh (RealOf a) -> Hermitian sh a
diagonal :: Order -> Vector sh (RealOf a) -> Hermitian sh a
diagonal Order
order = Array (HermitianP Packed sh) a -> Hermitian 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 (HermitianP Packed sh) a -> Hermitian sh a)
-> (Vector sh (RealOf a) -> Array (HermitianP Packed sh) a)
-> Vector sh (RealOf a)
-> Hermitian sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Order -> Vector sh (RealOf a) -> Array (HermitianP Packed sh) a
forall sh a.
(C sh, Floating a) =>
Order -> Vector sh (RealOf a) -> Hermitian sh a
Basic.diagonal Order
order

takeDiagonal ::
   (TBool.C neg, TBool.C zero, TBool.C pos,
    Shape.C sh, Class.Floating a) =>
   FlexHermitian neg zero pos sh a -> Vector sh (RealOf a)
takeDiagonal :: FlexHermitian neg zero pos sh a -> Vector sh (RealOf a)
takeDiagonal = Hermitian sh a -> Vector sh (RealOf a)
forall sh a.
(C sh, Floating a) =>
Hermitian sh a -> Vector sh (RealOf a)
Basic.takeDiagonal (Hermitian sh a -> Vector sh (RealOf a))
-> (FlexHermitian neg zero pos sh a -> Hermitian sh a)
-> FlexHermitian neg zero pos sh a
-> Vector sh (RealOf a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FlexHermitian neg zero pos sh a -> Hermitian sh a
forall pack property lower upper meas vert horiz height width a.
ToPlain pack property lower upper meas vert horiz height width =>
ArrayMatrix
  pack property lower upper meas vert horiz height width a
-> PlainArray
     pack property lower upper meas vert horiz height width a
ArrMatrix.toVector

forceOrder ::
   (Layout.Packing pack, TBool.C neg, TBool.C zero, TBool.C pos,
    Shape.C sh, Class.Floating a) =>
   Order ->
   FlexHermitianP pack neg zero pos sh a ->
   FlexHermitianP pack neg zero pos sh a
forceOrder :: Order
-> FlexHermitianP pack neg zero pos sh a
-> FlexHermitianP pack neg zero pos sh a
forceOrder Order
order FlexHermitianP pack neg zero pos sh a
a =
   case FlexHermitianP pack neg zero pos sh a -> PackingSingleton pack
forall pack diag lower upper meas vert horiz height width a.
Packing pack =>
ArrayMatrix pack diag lower upper meas vert horiz height width a
-> PackingSingleton pack
packTag FlexHermitianP pack neg zero pos sh a
a of
      PackingSingleton pack
Layout.Packed -> (PlainArray
   pack
   (Hermitian neg zero pos)
   Filled
   Filled
   Shape
   Small
   Small
   sh
   sh
   a
 -> PlainArray
      pack
      (Hermitian neg zero pos)
      Filled
      Filled
      Shape
      Small
      Small
      sh
      sh
      a)
-> FlexHermitianP pack neg zero pos sh a
-> FlexHermitianP pack neg zero pos sh 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 (Order
-> Mosaic ConjugateMirror Upper sh a
-> Mosaic ConjugateMirror Upper sh a
forall uplo sh a mirror.
(UpLo uplo, C sh, Floating a) =>
Order -> Mosaic mirror uplo sh a -> Mosaic mirror uplo sh a
Packed.forceOrder Order
order) FlexHermitianP pack neg zero pos sh a
a
      PackingSingleton pack
Layout.Unpacked -> (FullArray Shape Small Small sh sh a
 -> FullArray Shape Small Small sh sh a)
-> UnpackedMatrix
     (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh a
-> UnpackedMatrix
     (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh a
forall propertyA lowerA upperA propertyB lowerB upperB measA vertA
       horizA heightA widthA a measB vertB horizB heightB widthB b.
(Property propertyA, Strip lowerA, Strip upperA,
 Property propertyB, Strip lowerB, Strip upperB) =>
(FullArray measA vertA horizA heightA widthA a
 -> FullArray measB vertB horizB heightB widthB b)
-> UnpackedMatrix
     propertyA lowerA upperA measA vertA horizA heightA widthA a
-> UnpackedMatrix
     propertyB lowerB upperB measB vertB horizB heightB widthB b
ArrMatrix.liftUnpacked1 (Order
-> FullArray Shape Small Small sh sh a
-> FullArray Shape Small Small sh sh a
forall meas vert horiz height width a.
(Measure meas, C vert, C horiz, C height, C width, Floating a) =>
Order
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
FullBasic.forceOrder Order
order) FlexHermitianP pack neg zero pos sh a
UnpackedMatrix
  (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh a
a


pack ::
   (Layout.Packing pack, TBool.C neg, TBool.C zero, TBool.C pos,
    Shape.C sh, Class.Floating a) =>
   FlexHermitianP pack neg zero pos sh a -> FlexHermitian neg zero pos sh a
pack :: FlexHermitianP pack neg zero pos sh a
-> FlexHermitian neg zero pos sh a
pack = (PlainArray
   pack
   (Hermitian neg zero pos)
   Filled
   Filled
   Shape
   Small
   Small
   sh
   sh
   a
 -> PlainArray
      Packed
      (Hermitian neg zero pos)
      Filled
      Filled
      Shape
      Small
      Small
      sh
      sh
      a)
-> FlexHermitianP pack neg zero pos sh a
-> FlexHermitian neg zero pos sh 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 PlainArray
  pack
  (Hermitian neg zero pos)
  Filled
  Filled
  Shape
  Small
  Small
  sh
  sh
  a
-> PlainArray
     Packed
     (Hermitian neg zero pos)
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
forall uplo sh a pack mirror.
(UpLo uplo, C sh, Floating a) =>
Mosaic pack mirror uplo sh a -> Mosaic mirror uplo sh a
Mosaic.pack


{- |
> toSquare (stack a b c)
>
> =
>
> toSquare a ||| b
> ===
> adjoint b ||| toSquare c

It holds @order (stack a b c) = order b@.
The function is most efficient when the order of all blocks match.
-}
stack ::
   (Layout.Packing pack,
    Shape.C sh0, Eq sh0, Shape.C sh1, Eq sh1, Class.Floating a) =>
   HermitianP pack sh0 a -> General sh0 sh1 a -> HermitianP pack sh1 a ->
   HermitianP pack (sh0::+sh1) a
stack :: HermitianP pack sh0 a
-> General sh0 sh1 a
-> HermitianP pack sh1 a
-> HermitianP pack (sh0 ::+ sh1) a
stack HermitianP pack sh0 a
a =
   case HermitianP pack sh0 a -> PackingSingleton pack
forall pack diag lower upper meas vert horiz height width a.
Packing pack =>
ArrayMatrix pack diag lower upper meas vert horiz height width a
-> PackingSingleton pack
packTag HermitianP pack sh0 a
a of
      PackingSingleton pack
Layout.Packed -> (PlainArray
   pack
   HermitianUnknownDefiniteness
   Filled
   Filled
   Shape
   Small
   Small
   sh0
   sh0
   a
 -> PlainArray
      Unpacked Arbitrary Filled Filled Size Big Big sh0 sh1 a
 -> PlainArray
      pack
      HermitianUnknownDefiniteness
      Filled
      Filled
      Shape
      Small
      Small
      sh1
      sh1
      a
 -> PlainArray
      pack
      HermitianUnknownDefiniteness
      Filled
      Filled
      Shape
      Small
      Small
      (sh0 ::+ sh1)
      (sh0 ::+ sh1)
      a)
-> HermitianP pack sh0 a
-> General sh0 sh1 a
-> HermitianP pack sh1 a
-> HermitianP pack (sh0 ::+ sh1) a
forall packA propA lowerA upperA measA vertA horizA heightA widthA
       packB propB lowerB upperB measB vertB horizB heightB widthB packC
       propC lowerC upperC measC vertC horizC heightC widthC packD propD
       lowerD upperD measD vertD horizD heightD widthD a b c d.
(ToPlain
   packA propA lowerA upperA measA vertA horizA heightA widthA,
 ToPlain
   packB propB lowerB upperB measB vertB horizB heightB widthB,
 ToPlain
   packC propC lowerC upperC measC vertC horizC heightC widthC,
 FromPlain
   packD propD lowerD upperD measD vertD horizD heightD widthD) =>
(PlainArray
   packA propA lowerA upperA measA vertA horizA heightA widthA a
 -> PlainArray
      packB propB lowerB upperB measB vertB horizB heightB widthB b
 -> PlainArray
      packC propC lowerC upperC measC vertC horizC heightC widthC c
 -> PlainArray
      packD propD lowerD upperD measD vertD horizD heightD widthD d)
-> ArrayMatrix
     packA propA lowerA upperA measA vertA horizA heightA widthA a
-> ArrayMatrix
     packB propB lowerB upperB measB vertB horizB heightB widthB b
-> ArrayMatrix
     packC propC lowerC upperC measC vertC horizC heightC widthC c
-> ArrayMatrix
     packD propD lowerD upperD measD vertD horizD heightD widthD d
ArrMatrix.lift3 PlainArray
  pack
  HermitianUnknownDefiniteness
  Filled
  Filled
  Shape
  Small
  Small
  sh0
  sh0
  a
-> PlainArray
     Unpacked Arbitrary Filled Filled Size Big Big sh0 sh1 a
-> PlainArray
     pack
     HermitianUnknownDefiniteness
     Filled
     Filled
     Shape
     Small
     Small
     sh1
     sh1
     a
-> PlainArray
     pack
     HermitianUnknownDefiniteness
     Filled
     Filled
     Shape
     Small
     Small
     (sh0 ::+ sh1)
     (sh0 ::+ sh1)
     a
forall height width a mirror.
(C height, Eq height, C width, Eq width, Floating a) =>
MosaicUpper mirror height a
-> General height width a
-> MosaicUpper mirror width a
-> MosaicUpper mirror (height ::+ width) a
Packed.stackUpper HermitianP pack sh0 a
a
      PackingSingleton pack
Layout.Unpacked ->
         (FullArray Shape Small Small sh0 sh0 a
 -> FullArray Size Big Big sh0 sh1 a
 -> FullArray Shape Small Small sh1 sh1 a
 -> FullArray Shape Small Small (sh0 ::+ sh1) (sh0 ::+ sh1) a)
-> UnpackedMatrix
     HermitianUnknownDefiniteness
     Filled
     Filled
     Shape
     Small
     Small
     sh0
     sh0
     a
-> General sh0 sh1 a
-> UnpackedMatrix
     HermitianUnknownDefiniteness
     Filled
     Filled
     Shape
     Small
     Small
     sh1
     sh1
     a
-> UnpackedMatrix
     HermitianUnknownDefiniteness
     Filled
     Filled
     Shape
     Small
     Small
     (sh0 ::+ sh1)
     (sh0 ::+ sh1)
     a
forall propertyA lowerA upperA propertyB lowerB upperB propertyC
       lowerC upperC propertyD lowerD upperD measA vertA horizA heightA
       widthA a measB vertB horizB heightB widthB b measC vertC horizC
       heightC widthC c measD vertD horizD heightD widthD d.
(Property propertyA, Strip lowerA, Strip upperA,
 Property propertyB, Strip lowerB, Strip upperB, Property propertyC,
 Strip lowerC, Strip upperC, Property propertyD, Strip lowerD,
 Strip upperD) =>
(FullArray measA vertA horizA heightA widthA a
 -> FullArray measB vertB horizB heightB widthB b
 -> FullArray measC vertC horizC heightC widthC c
 -> FullArray measD vertD horizD heightD widthD d)
-> UnpackedMatrix
     propertyA lowerA upperA measA vertA horizA heightA widthA a
-> UnpackedMatrix
     propertyB lowerB upperB measB vertB horizB heightB widthB b
-> UnpackedMatrix
     propertyC lowerC upperC measC vertC horizC heightC widthC c
-> UnpackedMatrix
     propertyD lowerD upperD measD vertD horizD heightD widthD d
ArrMatrix.liftUnpacked3
            (\FullArray Shape Small Small sh0 sh0 a
a_ FullArray Size Big Big sh0 sh1 a
b_ FullArray Shape Small Small sh1 sh1 a
c_ ->
               FullArray Shape Small Small sh0 sh0 a
-> FullArray Size Big Big sh0 sh1 a
-> General sh1 sh0 a
-> FullArray Shape Small Small sh1 sh1 a
-> FullArray Shape Small Small (sh0 ::+ sh1) (sh0 ::+ sh1) a
forall shA shB a.
(C shA, Eq shA, C shB, Eq shB, Floating a) =>
Square shA a
-> General shA shB a
-> General shB shA a
-> Square shB a
-> Square (shA ::+ shB) a
FullBasic.stackMosaic FullArray Shape Small Small sh0 sh0 a
a_ FullArray Size Big Big sh0 sh1 a
b_ (FullArray Size Big Big sh0 sh1 a -> General sh1 sh0 a
forall meas vert horiz height width a.
(Measure meas, C vert, C horiz, C height, C width, Floating a) =>
Full meas vert horiz height width a
-> Full meas horiz vert width height a
FullBasic.adjoint FullArray Size Big Big sh0 sh1 a
b_) FullArray Shape Small Small sh1 sh1 a
c_)
            HermitianP pack sh0 a
UnpackedMatrix
  HermitianUnknownDefiniteness
  Filled
  Filled
  Shape
  Small
  Small
  sh0
  sh0
  a
a

infixr 2 *%%%#

(*%%%#) ::
   (Layout.Packing pack,
    Shape.C sh0, Eq sh0, Shape.C sh1, Eq sh1, Class.Floating a) =>
   (HermitianP pack sh0 a, General sh0 sh1 a) -> HermitianP pack sh1 a ->
   HermitianP pack (sh0::+sh1) a
*%%%# :: (HermitianP pack sh0 a, General sh0 sh1 a)
-> HermitianP pack sh1 a -> HermitianP pack (sh0 ::+ sh1) a
(*%%%#) = (HermitianP pack sh0 a
 -> General sh0 sh1 a
 -> HermitianP pack sh1 a
 -> HermitianP pack (sh0 ::+ sh1) a)
-> (HermitianP pack sh0 a, General sh0 sh1 a)
-> HermitianP pack sh1 a
-> HermitianP pack (sh0 ::+ sh1) a
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry HermitianP pack sh0 a
-> General sh0 sh1 a
-> HermitianP pack sh1 a
-> HermitianP pack (sh0 ::+ sh1) a
forall pack sh0 sh1 a.
(Packing pack, C sh0, Eq sh0, C sh1, Eq sh1, Floating a) =>
HermitianP pack sh0 a
-> General sh0 sh1 a
-> HermitianP pack sh1 a
-> HermitianP pack (sh0 ::+ sh1) a
stack


{-
The definiteness is transfered from the big matrix to its parts,
because it literally means to restrict the set of vectors in @x^T*A*x@
to ones that have parts of the vectors zeroed.
-}
split ::
   (Layout.Packing pack, TBool.C neg, TBool.C zero, TBool.C pos,
    Shape.C sh0, Shape.C sh1, Class.Floating a) =>
   FlexHermitianP pack neg zero pos (sh0::+sh1) a ->
   (FlexHermitianP pack neg zero pos sh0 a,
    General sh0 sh1 a,
    FlexHermitianP pack neg zero pos sh1 a)
split :: FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
-> (FlexHermitianP pack neg zero pos sh0 a, General sh0 sh1 a,
    FlexHermitianP pack neg zero pos sh1 a)
split FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
a = (FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
-> FlexHermitianP pack neg zero pos sh0 a
forall pack neg zero pos sh0 sh1 a.
(Packing pack, C neg, C zero, C pos, C sh0, C sh1, Floating a) =>
FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
-> FlexHermitianP pack neg zero pos sh0 a
takeTopLeft FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
a, FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
-> General sh0 sh1 a
forall pack neg zero pos sh0 sh1 a.
(Packing pack, C neg, C zero, C pos, C sh0, C sh1, Floating a) =>
FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
-> General sh0 sh1 a
takeTopRight FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
a, FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
-> FlexHermitianP pack neg zero pos sh1 a
forall pack neg zero pos sh0 sh1 a.
(Packing pack, C neg, C zero, C pos, C sh0, C sh1, Floating a) =>
FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
-> FlexHermitianP pack neg zero pos sh1 a
takeBottomRight FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
a)

{- |
Sub-matrices maintain definiteness of the original matrix.
Consider x^* A x > 0.
Then y^* (take A) y = x^* A x where some components of x are zero.
-}
takeTopLeft ::
   (Layout.Packing pack, TBool.C neg, TBool.C zero, TBool.C pos,
    Shape.C sh0, Shape.C sh1, Class.Floating a) =>
   FlexHermitianP pack neg zero pos (sh0::+sh1) a ->
   FlexHermitianP pack neg zero pos sh0 a
takeTopLeft :: FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
-> FlexHermitianP pack neg zero pos sh0 a
takeTopLeft FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
a =
   case FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
-> PackingSingleton pack
forall pack diag lower upper meas vert horiz height width a.
Packing pack =>
ArrayMatrix pack diag lower upper meas vert horiz height width a
-> PackingSingleton pack
packTag FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
a of
      PackingSingleton pack
Layout.Packed -> (PlainArray
   pack
   (Hermitian neg zero pos)
   Filled
   Filled
   Shape
   Small
   Small
   (sh0 ::+ sh1)
   (sh0 ::+ sh1)
   a
 -> PlainArray
      pack
      (Hermitian neg zero pos)
      Filled
      Filled
      Shape
      Small
      Small
      sh0
      sh0
      a)
-> FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
-> FlexHermitianP pack neg zero pos sh0 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 PlainArray
  pack
  (Hermitian neg zero pos)
  Filled
  Filled
  Shape
  Small
  Small
  (sh0 ::+ sh1)
  (sh0 ::+ sh1)
  a
-> PlainArray
     pack
     (Hermitian neg zero pos)
     Filled
     Filled
     Shape
     Small
     Small
     sh0
     sh0
     a
forall uplo height width a mirror.
(UpLo uplo, C height, C width, Floating a) =>
Mosaic mirror uplo (height ::+ width) a
-> Mosaic mirror uplo height a
Packed.takeTopLeft FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
a
      PackingSingleton pack
Layout.Unpacked -> Quadratic (Hermitian neg zero pos) Filled Filled (sh0 ::+ sh1) a
-> Quadratic (Hermitian neg zero pos) Filled Filled sh0 a
forall property lower upper sh0 sh1 a.
(Property property, Strip lower, Strip upper, C sh0, C sh1,
 Floating a) =>
Quadratic property lower upper (sh0 ::+ sh1) a
-> Quadratic property lower upper sh0 a
ArrUnpacked.takeTopLeft FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
Quadratic (Hermitian neg zero pos) Filled Filled (sh0 ::+ sh1) a
a

takeTopRight ::
   (Layout.Packing pack, TBool.C neg, TBool.C zero, TBool.C pos,
    Shape.C sh0, Shape.C sh1, Class.Floating a) =>
   FlexHermitianP pack neg zero pos (sh0::+sh1) a -> General sh0 sh1 a
takeTopRight :: FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
-> General sh0 sh1 a
takeTopRight FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
a =
   case FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
-> PackingSingleton pack
forall pack diag lower upper meas vert horiz height width a.
Packing pack =>
ArrayMatrix pack diag lower upper meas vert horiz height width a
-> PackingSingleton pack
packTag FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
a of
      PackingSingleton pack
Layout.Packed -> (PlainArray
   pack
   (Hermitian neg zero pos)
   Filled
   Filled
   Shape
   Small
   Small
   (sh0 ::+ sh1)
   (sh0 ::+ sh1)
   a
 -> PlainArray
      Unpacked Arbitrary Filled Filled Size Big Big sh0 sh1 a)
-> FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
-> General sh0 sh1 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 PlainArray
  pack
  (Hermitian neg zero pos)
  Filled
  Filled
  Shape
  Small
  Small
  (sh0 ::+ sh1)
  (sh0 ::+ sh1)
  a
-> PlainArray
     Unpacked Arbitrary Filled Filled Size Big Big sh0 sh1 a
forall height width a mirror.
(C height, C width, Floating a) =>
MosaicUpper mirror (height ::+ width) a -> General height width a
Packed.takeTopRight FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
a
      PackingSingleton pack
Layout.Unpacked -> Quadratic (Hermitian neg zero pos) Filled Filled (sh0 ::+ sh1) a
-> General sh0 sh1 a
forall property lower upper sh0 sh1 a.
(Property property, Strip lower, Strip upper, C sh0, C sh1,
 Floating a) =>
Quadratic property lower upper (sh0 ::+ sh1) a -> General sh0 sh1 a
ArrUnpacked.takeTopRight FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
Quadratic (Hermitian neg zero pos) Filled Filled (sh0 ::+ sh1) a
a

takeBottomRight ::
   (Layout.Packing pack, TBool.C neg, TBool.C zero, TBool.C pos,
    Shape.C sh0, Shape.C sh1, Class.Floating a) =>
   FlexHermitianP pack neg zero pos (sh0::+sh1) a ->
   FlexHermitianP pack neg zero pos sh1 a
takeBottomRight :: FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
-> FlexHermitianP pack neg zero pos sh1 a
takeBottomRight FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
a =
   case FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
-> PackingSingleton pack
forall pack diag lower upper meas vert horiz height width a.
Packing pack =>
ArrayMatrix pack diag lower upper meas vert horiz height width a
-> PackingSingleton pack
packTag FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
a of
      PackingSingleton pack
Layout.Unpacked -> Quadratic (Hermitian neg zero pos) Filled Filled (sh0 ::+ sh1) a
-> Quadratic (Hermitian neg zero pos) Filled Filled sh1 a
forall property lower upper sh0 sh1 a.
(Property property, Strip lower, Strip upper, C sh0, C sh1,
 Floating a) =>
Quadratic property lower upper (sh0 ::+ sh1) a
-> Quadratic property lower upper sh1 a
ArrUnpacked.takeBottomRight FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
Quadratic (Hermitian neg zero pos) Filled Filled (sh0 ::+ sh1) a
a
      PackingSingleton pack
Layout.Packed -> (PlainArray
   pack
   (Hermitian neg zero pos)
   Filled
   Filled
   Shape
   Small
   Small
   (sh0 ::+ sh1)
   (sh0 ::+ sh1)
   a
 -> PlainArray
      pack
      (Hermitian neg zero pos)
      Filled
      Filled
      Shape
      Small
      Small
      sh1
      sh1
      a)
-> FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
-> FlexHermitianP pack neg zero pos sh1 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 PlainArray
  pack
  (Hermitian neg zero pos)
  Filled
  Filled
  Shape
  Small
  Small
  (sh0 ::+ sh1)
  (sh0 ::+ sh1)
  a
-> PlainArray
     pack
     (Hermitian neg zero pos)
     Filled
     Filled
     Shape
     Small
     Small
     sh1
     sh1
     a
forall uplo height width a mirror.
(UpLo uplo, C height, C width, Floating a) =>
Mosaic mirror uplo (height ::+ width) a
-> Mosaic mirror uplo width a
Packed.takeBottomRight FlexHermitianP pack neg zero pos (sh0 ::+ sh1) a
a


negate ::
   (TBool.C neg, TBool.C zero, TBool.C pos, Shape.C sh, Class.Floating a) =>
   Hermitian.AnyHermitianP pack neg zero pos bands sh a ->
   Hermitian.AnyHermitianP pack pos zero neg bands sh a
negate :: AnyHermitianP pack neg zero pos bands sh a
-> AnyHermitianP pack pos zero neg bands sh a
negate AnyHermitianP pack neg zero pos bands sh a
a =
   case AnyHermitianP pack neg zero pos bands sh a
-> Omni
     pack (Hermitian neg zero pos) bands bands Shape Small Small sh sh
forall pack property lower upper meas vert horiz height width a.
ArrayMatrix
  pack property lower upper meas vert horiz height width a
-> Omni pack property lower upper meas vert horiz height width
ArrMatrix.shape AnyHermitianP pack neg zero pos bands sh a
a of
      Omni.Full Full Shape Small Small sh sh
_ -> (FullArray Shape Small Small sh sh a
 -> FullArray Shape Small Small sh sh a)
-> UnpackedMatrix
     (Hermitian neg zero pos) bands bands Shape Small Small sh sh a
-> UnpackedMatrix
     (Hermitian pos zero neg) bands bands Shape Small Small sh sh a
forall propertyA lowerA upperA propertyB lowerB upperB measA vertA
       horizA heightA widthA a measB vertB horizB heightB widthB b.
(Property propertyA, Strip lowerA, Strip upperA,
 Property propertyB, Strip lowerB, Strip upperB) =>
(FullArray measA vertA horizA heightA widthA a
 -> FullArray measB vertB horizB heightB widthB b)
-> UnpackedMatrix
     propertyA lowerA upperA measA vertA horizA heightA widthA a
-> UnpackedMatrix
     propertyB lowerB upperB measB vertB horizB heightB widthB b
ArrMatrix.liftUnpacked1 FullArray Shape Small Small sh sh a
-> FullArray Shape Small Small sh sh a
forall sh a. (C sh, Floating a) => Vector sh a -> Vector sh a
Vector.negate AnyHermitianP pack neg zero pos bands sh a
UnpackedMatrix
  (Hermitian neg zero pos) bands bands Shape Small Small sh sh a
a
      Omni.Hermitian Hermitian sh
_ -> (PlainArray
   pack (Hermitian neg zero pos) bands bands Shape Small Small sh sh a
 -> PlainArray
      pack
      (Hermitian pos zero neg)
      bands
      bands
      Shape
      Small
      Small
      sh
      sh
      a)
-> AnyHermitianP pack neg zero pos bands sh a
-> AnyHermitianP pack pos zero neg bands sh 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 PlainArray
  pack (Hermitian neg zero pos) bands bands Shape Small Small sh sh a
-> PlainArray
     pack (Hermitian pos zero neg) bands bands Shape Small Small sh sh a
forall sh a. (C sh, Floating a) => Vector sh a -> Vector sh a
Vector.negate AnyHermitianP pack neg zero pos bands sh a
a
      Omni.BandedHermitian BandedHermitian offDiag sh
_ -> (PlainArray
   pack (Hermitian neg zero pos) bands bands Shape Small Small sh sh a
 -> PlainArray
      pack
      (Hermitian pos zero neg)
      bands
      bands
      Shape
      Small
      Small
      sh
      sh
      a)
-> AnyHermitianP pack neg zero pos bands sh a
-> AnyHermitianP pack pos zero neg bands sh 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 PlainArray
  pack (Hermitian neg zero pos) bands bands Shape Small Small sh sh a
-> PlainArray
     pack (Hermitian pos zero neg) bands bands Shape Small Small sh sh a
forall sh a. (C sh, Floating a) => Vector sh a -> Vector sh a
Vector.negate AnyHermitianP pack neg zero pos bands sh a
a


multiplyVector ::
   (Layout.Packing pack) =>
   (TBool.C neg, TBool.C zero, TBool.C pos,
    Shape.C sh, Eq sh, Class.Floating a) =>
   Transposition -> FlexHermitianP pack neg zero pos sh a ->
   Vector sh a -> Vector sh a
multiplyVector :: Transposition
-> FlexHermitianP pack neg zero pos sh a
-> Vector sh a
-> Vector sh a
multiplyVector Transposition
trans =
   (case Transposition
trans of
      Transposition
NonTransposed -> Mosaic pack ConjugateMirror Upper sh a
-> Vector sh a -> Vector sh a
forall mirror sh a pack uplo.
(Mirror mirror, C sh, Eq sh, Floating a) =>
Mosaic pack mirror uplo sh a -> Vector sh a -> Vector sh a
Symmetric.multiplyVector
      Transposition
Transposed -> Mosaic pack ConjugateMirror Lower sh a
-> Vector sh a -> Vector sh a
forall mirror sh a pack uplo.
(Mirror mirror, C sh, Eq sh, Floating a) =>
Mosaic pack mirror uplo sh a -> Vector sh a -> Vector sh a
Symmetric.multiplyVector (Mosaic pack ConjugateMirror Lower sh a
 -> Vector sh a -> Vector sh a)
-> (Mosaic pack ConjugateMirror Upper sh a
    -> Mosaic pack ConjugateMirror Lower sh a)
-> Mosaic pack ConjugateMirror Upper sh a
-> Vector sh a
-> Vector sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Mosaic pack ConjugateMirror Upper sh a
-> Mosaic pack ConjugateMirror Lower sh a
forall uplo pack mirror sh a.
UpLo uplo =>
Mosaic pack mirror uplo sh a
-> Mosaic pack mirror (TriTransposed uplo) sh a
Mosaic.transpose) (Mosaic pack ConjugateMirror Upper sh a
 -> Vector sh a -> Vector sh a)
-> (FlexHermitianP pack neg zero pos sh a
    -> Mosaic pack ConjugateMirror Upper sh a)
-> FlexHermitianP pack neg zero pos sh a
-> Vector sh a
-> Vector sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
   FlexHermitianP pack neg zero pos sh a
-> Mosaic pack ConjugateMirror Upper sh a
forall pack property lower upper meas vert horiz height width a.
ToPlain pack property lower upper meas vert horiz height width =>
ArrayMatrix
  pack property lower upper meas vert horiz height width a
-> PlainArray
     pack property lower upper meas vert horiz height width a
ArrMatrix.toVector

multiplyFull ::
   (Layout.Packing pack) =>
   (TBool.C neg, TBool.C zero, TBool.C pos,
    Extent.Measure meas, Extent.C vert, Extent.C horiz,
    Shape.C height, Eq height, Shape.C width,
    Class.Floating a) =>
   Transposition -> FlexHermitianP pack neg zero pos height a ->
   Full meas vert horiz height width a ->
   Full meas vert horiz height width a
multiplyFull :: Transposition
-> FlexHermitianP pack neg zero pos height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
multiplyFull Transposition
trans =
   (PlainArray
   pack
   (Hermitian neg zero pos)
   Filled
   Filled
   Shape
   Small
   Small
   height
   height
   a
 -> PlainArray
      Unpacked Arbitrary Filled Filled meas vert horiz height width a
 -> PlainArray
      Unpacked Arbitrary Filled Filled meas vert horiz height width a)
-> FlexHermitianP pack neg zero pos height a
-> Full meas vert horiz height width a
-> Full 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 packC
       propC lowerC upperC measC vertC horizC heightC widthC a b c.
(ToPlain
   packA propA lowerA upperA measA vertA horizA heightA widthA,
 ToPlain
   packB propB lowerB upperB measB vertB horizB heightB widthB,
 FromPlain
   packC propC lowerC upperC measC vertC horizC heightC widthC) =>
(PlainArray
   packA propA lowerA upperA measA vertA horizA heightA widthA a
 -> PlainArray
      packB propB lowerB upperB measB vertB horizB heightB widthB b
 -> PlainArray
      packC propC lowerC upperC measC vertC horizC heightC widthC c)
-> ArrayMatrix
     packA propA lowerA upperA measA vertA horizA heightA widthA a
-> ArrayMatrix
     packB propB lowerB upperB measB vertB horizB heightB widthB b
-> ArrayMatrix
     packC propC lowerC upperC measC vertC horizC heightC widthC c
ArrMatrix.lift2 ((PlainArray
    pack
    (Hermitian neg zero pos)
    Filled
    Filled
    Shape
    Small
    Small
    height
    height
    a
  -> PlainArray
       Unpacked Arbitrary Filled Filled meas vert horiz height width a
  -> PlainArray
       Unpacked Arbitrary Filled Filled meas vert horiz height width a)
 -> FlexHermitianP pack neg zero pos height a
 -> Full meas vert horiz height width a
 -> Full meas vert horiz height width a)
-> (PlainArray
      pack
      (Hermitian neg zero pos)
      Filled
      Filled
      Shape
      Small
      Small
      height
      height
      a
    -> PlainArray
         Unpacked Arbitrary Filled Filled meas vert horiz height width a
    -> PlainArray
         Unpacked Arbitrary Filled Filled meas vert horiz height width a)
-> FlexHermitianP pack neg zero pos height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
forall a b. (a -> b) -> a -> b
$
   case Transposition
trans of
      Transposition
NonTransposed -> PlainArray
  pack
  (Hermitian neg zero pos)
  Filled
  Filled
  Shape
  Small
  Small
  height
  height
  a
-> PlainArray
     Unpacked Arbitrary Filled Filled meas vert horiz height width a
-> PlainArray
     Unpacked Arbitrary Filled Filled meas vert horiz height width a
forall uplo meas vert horiz height width a pack mirror.
(UpLo uplo, Measure meas, C vert, C horiz, C height, Eq height,
 C width, Floating a) =>
Mosaic pack mirror uplo height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
Symmetric.multiplyFull
      Transposition
Transposed -> Mosaic pack ConjugateMirror Lower height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
forall uplo meas vert horiz height width a pack mirror.
(UpLo uplo, Measure meas, C vert, C horiz, C height, Eq height,
 C width, Floating a) =>
Mosaic pack mirror uplo height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
Symmetric.multiplyFull (Mosaic pack ConjugateMirror Lower height a
 -> Full meas vert horiz height width a
 -> Full meas vert horiz height width a)
-> (Mosaic pack ConjugateMirror Upper height a
    -> Mosaic pack ConjugateMirror Lower height a)
-> Mosaic pack ConjugateMirror Upper height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Mosaic pack ConjugateMirror Upper height a
-> Mosaic pack ConjugateMirror Lower height a
forall uplo pack mirror sh a.
UpLo uplo =>
Mosaic pack mirror uplo sh a
-> Mosaic pack mirror (TriTransposed uplo) sh a
Mosaic.transpose

square ::
   (Layout.Packing pack) =>
   (TBool.C neg, TBool.C zero, TBool.C pos,
    Shape.C sh, Class.Floating a) =>
   FlexHermitianP pack neg zero pos sh a ->
   FlexHermitianP pack neg zero pos sh a
square :: FlexHermitianP pack neg zero pos sh a
-> FlexHermitianP pack neg zero pos sh a
square = (PlainArray
   pack
   (Hermitian neg zero pos)
   Filled
   Filled
   Shape
   Small
   Small
   sh
   sh
   a
 -> PlainArray
      pack
      (Hermitian neg zero pos)
      Filled
      Filled
      Shape
      Small
      Small
      sh
      sh
      a)
-> FlexHermitianP pack neg zero pos sh a
-> FlexHermitianP pack neg zero pos sh 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 ((PlainArray
    pack
    (Hermitian neg zero pos)
    Filled
    Filled
    Shape
    Small
    Small
    sh
    sh
    a
  -> PlainArray
       pack
       (Hermitian neg zero pos)
       Filled
       Filled
       Shape
       Small
       Small
       sh
       sh
       a)
 -> FlexHermitianP pack neg zero pos sh a
 -> FlexHermitianP pack neg zero pos sh a)
-> (PlainArray
      pack
      (Hermitian neg zero pos)
      Filled
      Filled
      Shape
      Small
      Small
      sh
      sh
      a
    -> PlainArray
         pack
         (Hermitian neg zero pos)
         Filled
         Filled
         Shape
         Small
         Small
         sh
         sh
         a)
-> FlexHermitianP pack neg zero pos sh a
-> FlexHermitianP pack neg zero pos sh a
forall a b. (a -> b) -> a -> b
$ DiagSingleton Arbitrary
-> Mosaic pack ConjugateMirror Upper sh a
-> Mosaic pack ConjugateMirror Upper sh a
forall pack diag uplo sh a mirror.
(Packing pack, TriDiag diag, UpLo uplo, C sh, Floating a) =>
DiagSingleton diag
-> Mosaic pack mirror uplo sh a -> Mosaic pack mirror uplo sh a
Mosaic.square DiagSingleton Arbitrary
Omni.Arbitrary


outer ::
   (Layout.Packing pack, Shape.C sh, Class.Floating a) =>
   Order -> Vector sh a -> HermitianPosSemidefP pack sh a
outer :: Order -> Vector sh a -> HermitianPosSemidefP pack sh a
outer Order
order = Array (HermitianP pack sh) a -> HermitianPosSemidefP pack 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 (HermitianP pack sh) a -> HermitianPosSemidefP pack sh a)
-> (Vector sh a -> Array (HermitianP pack sh) a)
-> Vector sh a
-> HermitianPosSemidefP pack sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Order -> Vector sh a -> Array (HermitianP pack sh) a
forall pack mirror sh a.
(Packing pack, Mirror mirror, C sh, Floating a) =>
Order -> Vector sh a -> Mosaic pack mirror Upper sh a
Symmetric.outerUpper Order
order

sumRank1 ::
   (Layout.Packing pack, Shape.C sh, Eq sh, Class.Floating a) =>
   Order -> sh -> [(RealOf a, Vector sh a)] -> HermitianPosSemidefP pack sh a
sumRank1 :: Order
-> sh
-> [(RealOf a, Vector sh a)]
-> HermitianPosSemidefP pack sh a
sumRank1 Order
order sh
sh = Array (HermitianP pack sh) a -> HermitianPosSemidefP pack 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 (HermitianP pack sh) a -> HermitianPosSemidefP pack sh a)
-> ([(RealOf a, Vector sh a)] -> Array (HermitianP pack sh) a)
-> [(RealOf a, Vector sh a)]
-> HermitianPosSemidefP pack sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Order
-> sh -> [(RealOf a, Vector sh a)] -> Array (HermitianP pack sh) a
forall pack sh a.
(Packing pack, C sh, Eq sh, Floating a) =>
Order -> sh -> [(RealOf a, Vector sh a)] -> HermitianP pack sh a
Basic.sumRank1 Order
order sh
sh

sumRank1NonEmpty ::
   (Layout.Packing pack, Shape.C sh, Eq sh, Class.Floating a) =>
   Order ->
   NonEmpty.T [] (RealOf a, Vector sh a) -> HermitianPosSemidefP pack sh a
sumRank1NonEmpty :: Order
-> T [] (RealOf a, Vector sh a) -> HermitianPosSemidefP pack sh a
sumRank1NonEmpty Order
order (NonEmpty.Cons (RealOf a, Vector sh a)
x [(RealOf a, Vector sh a)]
xs) =
   Order
-> sh
-> [(RealOf a, Vector sh a)]
-> HermitianPosSemidefP pack sh a
forall pack sh a.
(Packing pack, C sh, Eq sh, Floating a) =>
Order
-> sh
-> [(RealOf a, Vector sh a)]
-> HermitianPosSemidefP pack sh a
sumRank1 Order
order (Vector sh a -> sh
forall sh a. Array sh a -> sh
Array.shape (Vector sh a -> sh) -> Vector sh a -> sh
forall a b. (a -> b) -> a -> b
$ (RealOf a, Vector sh a) -> Vector sh a
forall a b. (a, b) -> b
snd (RealOf a, Vector sh a)
x) ((RealOf a, Vector sh a)
x(RealOf a, Vector sh a)
-> [(RealOf a, Vector sh a)] -> [(RealOf a, Vector sh a)]
forall a. a -> [a] -> [a]
:[(RealOf a, Vector sh a)]
xs)

sumRank2 ::
   (Layout.Packing pack, Shape.C sh, Eq sh, Class.Floating a) =>
   Order -> sh -> [(a, (Vector sh a, Vector sh a))] -> HermitianP pack sh a
sumRank2 :: Order
-> sh -> [(a, (Vector sh a, Vector sh a))] -> HermitianP pack sh a
sumRank2 Order
order sh
sh = Array (HermitianP pack sh) a -> HermitianP pack 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 (HermitianP pack sh) a -> HermitianP pack sh a)
-> ([(a, (Vector sh a, Vector sh a))]
    -> Array (HermitianP pack sh) a)
-> [(a, (Vector sh a, Vector sh a))]
-> HermitianP pack sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Order
-> sh
-> [(a, (Vector sh a, Vector sh a))]
-> Array (HermitianP pack sh) a
forall pack sh a.
(Packing pack, C sh, Eq sh, Floating a) =>
Order
-> sh -> [(a, (Vector sh a, Vector sh a))] -> HermitianP pack sh a
Basic.sumRank2 Order
order sh
sh

sumRank2NonEmpty ::
   (Layout.Packing pack, Shape.C sh, Eq sh, Class.Floating a) =>
   Order ->
   NonEmpty.T [] (a, (Vector sh a, Vector sh a)) -> HermitianP pack sh a
sumRank2NonEmpty :: Order
-> T [] (a, (Vector sh a, Vector sh a)) -> HermitianP pack sh a
sumRank2NonEmpty Order
order (NonEmpty.Cons (a, (Vector sh a, Vector sh a))
xy [(a, (Vector sh a, Vector sh a))]
xys) =
   Order
-> sh -> [(a, (Vector sh a, Vector sh a))] -> HermitianP pack sh a
forall pack sh a.
(Packing pack, C sh, Eq sh, Floating a) =>
Order
-> sh -> [(a, (Vector sh a, Vector sh a))] -> HermitianP pack sh a
sumRank2 Order
order (Vector sh a -> sh
forall sh a. Array sh a -> sh
Array.shape (Vector sh a -> sh) -> Vector sh a -> sh
forall a b. (a -> b) -> a -> b
$ (Vector sh a, Vector sh a) -> Vector sh a
forall a b. (a, b) -> a
fst ((Vector sh a, Vector sh a) -> Vector sh a)
-> (Vector sh a, Vector sh a) -> Vector sh a
forall a b. (a -> b) -> a -> b
$ (a, (Vector sh a, Vector sh a)) -> (Vector sh a, Vector sh a)
forall a b. (a, b) -> b
snd (a, (Vector sh a, Vector sh a))
xy) ((a, (Vector sh a, Vector sh a))
xy(a, (Vector sh a, Vector sh a))
-> [(a, (Vector sh a, Vector sh a))]
-> [(a, (Vector sh a, Vector sh a))]
forall a. a -> [a] -> [a]
:[(a, (Vector sh a, Vector sh a))]
xys)


toSquare ::
   (Layout.Packing pack,
    TBool.C neg, TBool.C zero, TBool.C pos, Shape.C sh, Class.Floating a) =>
   FlexHermitianP pack neg zero pos sh a -> Square sh a
toSquare :: FlexHermitianP pack neg zero pos sh a -> Square sh a
toSquare FlexHermitianP pack neg zero pos sh a
a =
   case FlexHermitianP pack neg zero pos sh a -> PackingSingleton pack
forall pack diag lower upper meas vert horiz height width a.
Packing pack =>
ArrayMatrix pack diag lower upper meas vert horiz height width a
-> PackingSingleton pack
packTag FlexHermitianP pack neg zero pos sh a
a of
      PackingSingleton pack
Layout.Packed -> (PlainArray
   pack
   (Hermitian neg zero pos)
   Filled
   Filled
   Shape
   Small
   Small
   sh
   sh
   a
 -> PlainArray
      Unpacked Arbitrary Filled Filled Shape Small Small sh sh a)
-> FlexHermitianP pack neg zero pos sh a -> Square sh 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 PlainArray
  pack
  (Hermitian neg zero pos)
  Filled
  Filled
  Shape
  Small
  Small
  sh
  sh
  a
-> PlainArray
     Unpacked Arbitrary Filled Filled Shape Small Small sh sh a
forall mirror sh a.
(Mirror mirror, C sh, Floating a) =>
Mosaic mirror Upper sh a -> Square sh a
Symmetric.toSquare FlexHermitianP pack neg zero pos sh a
a
      PackingSingleton pack
Layout.Unpacked -> (FullArray Shape Small Small sh sh a
 -> FullArray Shape Small Small sh sh a)
-> UnpackedMatrix
     (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh a
-> Square sh a
forall propertyA lowerA upperA propertyB lowerB upperB measA vertA
       horizA heightA widthA a measB vertB horizB heightB widthB b.
(Property propertyA, Strip lowerA, Strip upperA,
 Property propertyB, Strip lowerB, Strip upperB) =>
(FullArray measA vertA horizA heightA widthA a
 -> FullArray measB vertB horizB heightB widthB b)
-> UnpackedMatrix
     propertyA lowerA upperA measA vertA horizA heightA widthA a
-> UnpackedMatrix
     propertyB lowerB upperB measB vertB horizB heightB widthB b
ArrMatrix.liftUnpacked1 FullArray Shape Small Small sh sh a
-> FullArray Shape Small Small sh sh a
forall a. a -> a
id FlexHermitianP pack neg zero pos sh a
UnpackedMatrix
  (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh a
a

fromSymmetric ::
   (Layout.Packing pack, Shape.C sh, Class.Real a) =>
   SymmetricP pack sh a -> HermitianP pack sh a
fromSymmetric :: SymmetricP pack sh a -> HermitianP pack sh a
fromSymmetric =
   (PlainArray pack Symmetric Filled Filled Shape Small Small sh sh a
 -> PlainArray
      pack
      HermitianUnknownDefiniteness
      Filled
      Filled
      Shape
      Small
      Small
      sh
      sh
      a)
-> SymmetricP pack sh a -> HermitianP pack sh 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 ((PlainArray pack Symmetric Filled Filled Shape Small Small sh sh a
  -> PlainArray
       pack
       HermitianUnknownDefiniteness
       Filled
       Filled
       Shape
       Small
       Small
       sh
       sh
       a)
 -> SymmetricP pack sh a -> HermitianP pack sh a)
-> (PlainArray
      pack Symmetric Filled Filled Shape Small Small sh sh a
    -> PlainArray
         pack
         HermitianUnknownDefiniteness
         Filled
         Filled
         Shape
         Small
         Small
         sh
         sh
         a)
-> SymmetricP pack sh a
-> HermitianP pack sh a
forall a b. (a -> b) -> a -> b
$ (SymmetricP pack sh -> HermitianP pack sh)
-> Array (SymmetricP pack sh) a -> Array (HermitianP pack sh) a
forall sh0 sh1 a. (sh0 -> sh1) -> Array sh0 a -> Array sh1 a
Array.mapShape SymmetricP pack sh -> HermitianP pack sh
forall pack size. SymmetricP pack size -> HermitianP pack size
Layout.hermitianFromSymmetric


{- |
gramian A = A^H * A
-}
gramian ::
   (Layout.Packing pack) =>
   (Shape.C height, Shape.C width, Class.Floating a) =>
   General height width a -> HermitianPosSemidefP pack width a
gramian :: General height width a -> HermitianPosSemidefP pack width a
gramian = (PlainArray
   Unpacked Arbitrary Filled Filled Size Big Big height width a
 -> PlainArray
      pack
      HermitianPositiveSemidefinite
      Filled
      Filled
      Shape
      Small
      Small
      width
      width
      a)
-> General height width a -> HermitianPosSemidefP pack 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 PlainArray
  Unpacked Arbitrary Filled Filled Size Big Big height width a
-> PlainArray
     pack
     HermitianPositiveSemidefinite
     Filled
     Filled
     Shape
     Small
     Small
     width
     width
     a
forall pack mirror height width a.
(Packing pack, Mirror mirror, C height, C width, Floating a) =>
General height width a -> Mosaic pack mirror Upper width a
Symmetric.gramian

{- |
gramianAdjoint A = A * A^H = gramian (A^H)
-}
gramianAdjoint ::
   (Layout.Packing pack) =>
   (Shape.C height, Shape.C width, Class.Floating a) =>
   General height width a -> HermitianPosSemidefP pack height a
gramianAdjoint :: General height width a -> HermitianPosSemidefP pack height a
gramianAdjoint = (PlainArray
   Unpacked Arbitrary Filled Filled Size Big Big height width a
 -> PlainArray
      pack
      HermitianPositiveSemidefinite
      Filled
      Filled
      Shape
      Small
      Small
      height
      height
      a)
-> General height width a -> HermitianPosSemidefP pack height 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 PlainArray
  Unpacked Arbitrary Filled Filled Size Big Big height width a
-> PlainArray
     pack
     HermitianPositiveSemidefinite
     Filled
     Filled
     Shape
     Small
     Small
     height
     height
     a
forall pack mirror height width a.
(Packing pack, Mirror mirror, C height, C width, Floating a) =>
General height width a -> Mosaic pack mirror Upper height a
Symmetric.gramianTransposed

{- |
congruenceDiagonal D A = A^H * D * A
-}
congruenceDiagonal ::
   (Layout.Packing pack) =>
   (Shape.C height, Eq height, Shape.C width, Class.Floating a) =>
   Vector height (RealOf a) -> General height width a -> HermitianP pack width a
congruenceDiagonal :: Vector height (RealOf a)
-> General height width a -> HermitianP pack width a
congruenceDiagonal = (Array (Full Size Big Big height width) a
 -> Array (HermitianP pack width) a)
-> General height width a -> HermitianP pack 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 Size Big Big height width) a
  -> Array (HermitianP pack width) a)
 -> General height width a -> HermitianP pack width a)
-> (Vector height (RealOf a)
    -> Array (Full Size Big Big height width) a
    -> Array (HermitianP pack width) a)
-> Vector height (RealOf a)
-> General height width a
-> HermitianP pack width a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector height (RealOf a)
-> Array (Full Size Big Big height width) a
-> Array (HermitianP pack width) a
forall pack mirror height width a.
(Packing pack, Mirror mirror, C height, Eq height, C width,
 Floating a) =>
Vector height (RealOf a)
-> General height width a -> Mosaic pack mirror Upper width a
Symmetric.congruenceRealDiagonal

{- |
congruenceDiagonalAdjoint A D = A * D * A^H
-}
congruenceDiagonalAdjoint ::
   (Layout.Packing pack) =>
   (Shape.C height, Shape.C width, Eq width, Class.Floating a) =>
   General height width a -> Vector width (RealOf a) -> HermitianP pack height a
congruenceDiagonalAdjoint :: General height width a
-> Vector width (RealOf a) -> HermitianP pack height a
congruenceDiagonalAdjoint General height width a
a =
   Array (HermitianP pack height) a -> HermitianP pack height 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 (HermitianP pack height) a -> HermitianP pack height a)
-> (Vector width (RealOf a) -> Array (HermitianP pack height) a)
-> Vector width (RealOf a)
-> HermitianP pack height a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
      General height width a
-> Vector width (RealOf a) -> Array (HermitianP pack height) a
forall pack mirror height width a.
(Packing pack, Mirror mirror, C height, C width, Eq width,
 Floating a) =>
General height width a
-> Vector width (RealOf a) -> Mosaic pack mirror Upper height a
Symmetric.congruenceRealDiagonalTransposed (General height width a
-> PlainArray
     Unpacked Arbitrary Filled Filled Size Big Big height width a
forall pack property lower upper meas vert horiz height width a.
ToPlain pack property lower upper meas vert horiz height width =>
ArrayMatrix
  pack property lower upper meas vert horiz height width a
-> PlainArray
     pack property lower upper meas vert horiz height width a
ArrMatrix.toVector General height width a
a)

{- |
congruence B A = A^H * B * A
-}
congruence ::
   (Layout.Packing pack) =>
   (TBool.C neg, TBool.C pos,
    Shape.C height, Eq height, Shape.C width, Class.Floating a) =>
   FlexHermitianP pack neg True pos height a ->
   General height width a ->
   FlexHermitianP pack neg True pos width a
congruence :: FlexHermitianP pack neg True pos height a
-> General height width a
-> FlexHermitianP pack neg True pos width a
congruence =
   (PlainArray
   pack
   (Hermitian neg True pos)
   Filled
   Filled
   Shape
   Small
   Small
   height
   height
   a
 -> PlainArray
      Unpacked Arbitrary Filled Filled Size Big Big height width a
 -> PlainArray
      pack
      (Hermitian neg True pos)
      Filled
      Filled
      Shape
      Small
      Small
      width
      width
      a)
-> FlexHermitianP pack neg True pos height a
-> General height width a
-> FlexHermitianP pack neg True pos width a
forall packA propA lowerA upperA measA vertA horizA heightA widthA
       packB propB lowerB upperB measB vertB horizB heightB widthB packC
       propC lowerC upperC measC vertC horizC heightC widthC a b c.
(ToPlain
   packA propA lowerA upperA measA vertA horizA heightA widthA,
 ToPlain
   packB propB lowerB upperB measB vertB horizB heightB widthB,
 FromPlain
   packC propC lowerC upperC measC vertC horizC heightC widthC) =>
(PlainArray
   packA propA lowerA upperA measA vertA horizA heightA widthA a
 -> PlainArray
      packB propB lowerB upperB measB vertB horizB heightB widthB b
 -> PlainArray
      packC propC lowerC upperC measC vertC horizC heightC widthC c)
-> ArrayMatrix
     packA propA lowerA upperA measA vertA horizA heightA widthA a
-> ArrayMatrix
     packB propB lowerB upperB measB vertB horizB heightB widthB b
-> ArrayMatrix
     packC propC lowerC upperC measC vertC horizC heightC widthC c
ArrMatrix.lift2 ((PlainArray
    pack
    (Hermitian neg True pos)
    Filled
    Filled
    Shape
    Small
    Small
    height
    height
    a
  -> PlainArray
       Unpacked Arbitrary Filled Filled Size Big Big height width a
  -> PlainArray
       pack
       (Hermitian neg True pos)
       Filled
       Filled
       Shape
       Small
       Small
       width
       width
       a)
 -> FlexHermitianP pack neg True pos height a
 -> General height width a
 -> FlexHermitianP pack neg True pos width a)
-> (PlainArray
      pack
      (Hermitian neg True pos)
      Filled
      Filled
      Shape
      Small
      Small
      height
      height
      a
    -> PlainArray
         Unpacked Arbitrary Filled Filled Size Big Big height width a
    -> PlainArray
         pack
         (Hermitian neg True pos)
         Filled
         Filled
         Shape
         Small
         Small
         width
         width
         a)
-> FlexHermitianP pack neg True pos height a
-> General height width a
-> FlexHermitianP pack neg True pos width a
forall a b. (a -> b) -> a -> b
$ \PlainArray
  pack
  (Hermitian neg True pos)
  Filled
  Filled
  Shape
  Small
  Small
  height
  height
  a
b -> Mosaic ConjugateMirror Upper height a
-> General height width a
-> Mosaic pack ConjugateMirror Upper width a
forall pack mirror height width a.
(Packing pack, Mirror mirror, C height, Eq height, C width,
 Floating a) =>
Mosaic mirror Upper height a
-> General height width a -> Mosaic pack mirror Upper width a
Symmetric.congruence (Mosaic pack ConjugateMirror Upper height a
-> Mosaic ConjugateMirror Upper height a
forall uplo sh a pack mirror.
(UpLo uplo, C sh, Floating a) =>
Mosaic pack mirror uplo sh a -> MosaicUnpacked mirror uplo sh a
Mosaic.unpackDirty Mosaic pack ConjugateMirror Upper height a
PlainArray
  pack
  (Hermitian neg True pos)
  Filled
  Filled
  Shape
  Small
  Small
  height
  height
  a
b)

{- |
congruenceAdjoint B A = A * B * A^H
-}
congruenceAdjoint ::
   (Layout.Packing pack) =>
   (TBool.C neg, TBool.C pos,
    Shape.C height, Shape.C width, Eq width, Class.Floating a) =>
   General height width a ->
   FlexHermitianP pack neg True pos width a ->
   FlexHermitianP pack neg True pos height a
congruenceAdjoint :: General height width a
-> FlexHermitianP pack neg True pos width a
-> FlexHermitianP pack neg True pos height a
congruenceAdjoint =
   (PlainArray
   Unpacked Arbitrary Filled Filled Size Big Big height width a
 -> PlainArray
      pack
      (Hermitian neg True pos)
      Filled
      Filled
      Shape
      Small
      Small
      width
      width
      a
 -> PlainArray
      pack
      (Hermitian neg True pos)
      Filled
      Filled
      Shape
      Small
      Small
      height
      height
      a)
-> General height width a
-> FlexHermitianP pack neg True pos width a
-> FlexHermitianP pack neg True pos height a
forall packA propA lowerA upperA measA vertA horizA heightA widthA
       packB propB lowerB upperB measB vertB horizB heightB widthB packC
       propC lowerC upperC measC vertC horizC heightC widthC a b c.
(ToPlain
   packA propA lowerA upperA measA vertA horizA heightA widthA,
 ToPlain
   packB propB lowerB upperB measB vertB horizB heightB widthB,
 FromPlain
   packC propC lowerC upperC measC vertC horizC heightC widthC) =>
(PlainArray
   packA propA lowerA upperA measA vertA horizA heightA widthA a
 -> PlainArray
      packB propB lowerB upperB measB vertB horizB heightB widthB b
 -> PlainArray
      packC propC lowerC upperC measC vertC horizC heightC widthC c)
-> ArrayMatrix
     packA propA lowerA upperA measA vertA horizA heightA widthA a
-> ArrayMatrix
     packB propB lowerB upperB measB vertB horizB heightB widthB b
-> ArrayMatrix
     packC propC lowerC upperC measC vertC horizC heightC widthC c
ArrMatrix.lift2 ((PlainArray
    Unpacked Arbitrary Filled Filled Size Big Big height width a
  -> PlainArray
       pack
       (Hermitian neg True pos)
       Filled
       Filled
       Shape
       Small
       Small
       width
       width
       a
  -> PlainArray
       pack
       (Hermitian neg True pos)
       Filled
       Filled
       Shape
       Small
       Small
       height
       height
       a)
 -> General height width a
 -> FlexHermitianP pack neg True pos width a
 -> FlexHermitianP pack neg True pos height a)
-> (PlainArray
      Unpacked Arbitrary Filled Filled Size Big Big height width a
    -> PlainArray
         pack
         (Hermitian neg True pos)
         Filled
         Filled
         Shape
         Small
         Small
         width
         width
         a
    -> PlainArray
         pack
         (Hermitian neg True pos)
         Filled
         Filled
         Shape
         Small
         Small
         height
         height
         a)
-> General height width a
-> FlexHermitianP pack neg True pos width a
-> FlexHermitianP pack neg True pos height a
forall a b. (a -> b) -> a -> b
$ \PlainArray
  Unpacked Arbitrary Filled Filled Size Big Big height width a
a ->
      General height width a
-> Mosaic ConjugateMirror Upper width a
-> Mosaic pack ConjugateMirror Upper height a
forall pack mirror height width a.
(Packing pack, Mirror mirror, C height, C width, Eq width,
 Floating a) =>
General height width a
-> Mosaic mirror Upper width a -> Mosaic pack mirror Upper height a
Symmetric.congruenceTransposed General height width a
PlainArray
  Unpacked Arbitrary Filled Filled Size Big Big height width a
a (Mosaic ConjugateMirror Upper width a
 -> Mosaic pack ConjugateMirror Upper height a)
-> (Mosaic pack ConjugateMirror Upper width a
    -> Mosaic ConjugateMirror Upper width a)
-> Mosaic pack ConjugateMirror Upper width a
-> Mosaic pack ConjugateMirror Upper height a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Mosaic pack ConjugateMirror Upper width a
-> Mosaic ConjugateMirror Upper width a
forall uplo sh a pack mirror.
(UpLo uplo, C sh, Floating a) =>
Mosaic pack mirror uplo sh a -> MosaicUnpacked mirror uplo sh a
Mosaic.unpackDirty


{- |
anticommutator A B  =  A^H * B + B^H * A

Not exactly a matrix anticommutator,
thus I like to call it Hermitian anticommutator.
-}
anticommutator ::
   (Layout.Packing pack) =>
   (Extent.Measure meas, Extent.C vert, Extent.C horiz,
    Shape.C height, Eq height, Shape.C width, Eq width,
    Class.Floating a) =>
   Full meas vert horiz height width a ->
   Full meas vert horiz height width a -> HermitianP pack width a
anticommutator :: Full meas vert horiz height width a
-> Full meas vert horiz height width a -> HermitianP pack width a
anticommutator =
   (PlainArray
   Unpacked Arbitrary Filled Filled meas vert horiz height width a
 -> PlainArray
      Unpacked Arbitrary Filled Filled meas vert horiz height width a
 -> PlainArray
      pack
      HermitianUnknownDefiniteness
      Filled
      Filled
      Shape
      Small
      Small
      width
      width
      a)
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
-> HermitianP pack width a
forall packA propA lowerA upperA measA vertA horizA heightA widthA
       packB propB lowerB upperB measB vertB horizB heightB widthB packC
       propC lowerC upperC measC vertC horizC heightC widthC a b c.
(ToPlain
   packA propA lowerA upperA measA vertA horizA heightA widthA,
 ToPlain
   packB propB lowerB upperB measB vertB horizB heightB widthB,
 FromPlain
   packC propC lowerC upperC measC vertC horizC heightC widthC) =>
(PlainArray
   packA propA lowerA upperA measA vertA horizA heightA widthA a
 -> PlainArray
      packB propB lowerB upperB measB vertB horizB heightB widthB b
 -> PlainArray
      packC propC lowerC upperC measC vertC horizC heightC widthC c)
-> ArrayMatrix
     packA propA lowerA upperA measA vertA horizA heightA widthA a
-> ArrayMatrix
     packB propB lowerB upperB measB vertB horizB heightB widthB b
-> ArrayMatrix
     packC propC lowerC upperC measC vertC horizC heightC widthC c
ArrMatrix.lift2 ((PlainArray
    Unpacked Arbitrary Filled Filled meas vert horiz height width a
  -> PlainArray
       Unpacked Arbitrary Filled Filled meas vert horiz height width a
  -> PlainArray
       pack
       HermitianUnknownDefiniteness
       Filled
       Filled
       Shape
       Small
       Small
       width
       width
       a)
 -> Full meas vert horiz height width a
 -> Full meas vert horiz height width a
 -> HermitianP pack width a)
-> (PlainArray
      Unpacked Arbitrary Filled Filled meas vert horiz height width a
    -> PlainArray
         Unpacked Arbitrary Filled Filled meas vert horiz height width a
    -> PlainArray
         pack
         HermitianUnknownDefiniteness
         Filled
         Filled
         Shape
         Small
         Small
         width
         width
         a)
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
-> HermitianP pack width a
forall a b. (a -> b) -> a -> b
$
      MirrorSingleton ConjugateMirror
-> a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
-> Mosaic pack ConjugateMirror Upper width a
forall pack mirror meas vert horiz height width a.
(Packing pack, Mirror mirror, Measure meas, C vert, C horiz,
 C height, Eq height, C width, Eq width, Floating a) =>
MirrorSingleton mirror
-> a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
-> Mosaic pack mirror Upper width a
Symmetric.scaledAnticommutator MirrorSingleton ConjugateMirror
Layout.ConjugateMirror a
forall a. Floating a => a
one

{- |
anticommutatorAdjoint A B
   = A * B^H + B * A^H
   = anticommutator (adjoint A) (adjoint B)
-}
anticommutatorAdjoint ::
   (Layout.Packing pack) =>
   (Extent.Measure meas, Extent.C vert, Extent.C horiz,
    Shape.C height, Eq height, Shape.C width, Eq width,
    Class.Floating a) =>
   Full meas vert horiz height width a ->
   Full meas vert horiz height width a -> HermitianP pack height a
anticommutatorAdjoint :: Full meas vert horiz height width a
-> Full meas vert horiz height width a -> HermitianP pack height a
anticommutatorAdjoint =
   (PlainArray
   Unpacked Arbitrary Filled Filled meas vert horiz height width a
 -> PlainArray
      Unpacked Arbitrary Filled Filled meas vert horiz height width a
 -> PlainArray
      pack
      HermitianUnknownDefiniteness
      Filled
      Filled
      Shape
      Small
      Small
      height
      height
      a)
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
-> HermitianP pack height a
forall packA propA lowerA upperA measA vertA horizA heightA widthA
       packB propB lowerB upperB measB vertB horizB heightB widthB packC
       propC lowerC upperC measC vertC horizC heightC widthC a b c.
(ToPlain
   packA propA lowerA upperA measA vertA horizA heightA widthA,
 ToPlain
   packB propB lowerB upperB measB vertB horizB heightB widthB,
 FromPlain
   packC propC lowerC upperC measC vertC horizC heightC widthC) =>
(PlainArray
   packA propA lowerA upperA measA vertA horizA heightA widthA a
 -> PlainArray
      packB propB lowerB upperB measB vertB horizB heightB widthB b
 -> PlainArray
      packC propC lowerC upperC measC vertC horizC heightC widthC c)
-> ArrayMatrix
     packA propA lowerA upperA measA vertA horizA heightA widthA a
-> ArrayMatrix
     packB propB lowerB upperB measB vertB horizB heightB widthB b
-> ArrayMatrix
     packC propC lowerC upperC measC vertC horizC heightC widthC c
ArrMatrix.lift2 ((PlainArray
    Unpacked Arbitrary Filled Filled meas vert horiz height width a
  -> PlainArray
       Unpacked Arbitrary Filled Filled meas vert horiz height width a
  -> PlainArray
       pack
       HermitianUnknownDefiniteness
       Filled
       Filled
       Shape
       Small
       Small
       height
       height
       a)
 -> Full meas vert horiz height width a
 -> Full meas vert horiz height width a
 -> HermitianP pack height a)
-> (PlainArray
      Unpacked Arbitrary Filled Filled meas vert horiz height width a
    -> PlainArray
         Unpacked Arbitrary Filled Filled meas vert horiz height width a
    -> PlainArray
         pack
         HermitianUnknownDefiniteness
         Filled
         Filled
         Shape
         Small
         Small
         height
         height
         a)
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
-> HermitianP pack height a
forall a b. (a -> b) -> a -> b
$
      MirrorSingleton ConjugateMirror
-> a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
-> Mosaic pack ConjugateMirror Upper height a
forall pack mirror meas vert horiz height width a.
(Packing pack, Mirror mirror, Measure meas, C vert, C horiz,
 C height, Eq height, C width, Eq width, Floating a) =>
MirrorSingleton mirror
-> a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
-> Mosaic pack mirror Upper height a
Symmetric.scaledAnticommutatorTransposed MirrorSingleton ConjugateMirror
Layout.ConjugateMirror a
forall a. Floating a => a
one

{- |
scaledAnticommutator alpha A B  =  alpha * A^H * B + conj alpha * B^H * A
-}
_scaledAnticommutator ::
   (Layout.Packing pack) =>
   (Extent.Measure meas, Extent.C vert, Extent.C horiz,
    Shape.C height, Eq height, Shape.C width, Eq width,
    Class.Floating a) =>
   a ->
   Full meas vert horiz height width a ->
   Full meas vert horiz height width a -> HermitianP pack width a
_scaledAnticommutator :: a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
-> HermitianP pack width a
_scaledAnticommutator =
   (Array (Full meas vert horiz height width) a
 -> Array (Full meas vert horiz height width) a
 -> Array (HermitianP pack width) a)
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
-> HermitianP pack width a
forall packA propA lowerA upperA measA vertA horizA heightA widthA
       packB propB lowerB upperB measB vertB horizB heightB widthB packC
       propC lowerC upperC measC vertC horizC heightC widthC a b c.
(ToPlain
   packA propA lowerA upperA measA vertA horizA heightA widthA,
 ToPlain
   packB propB lowerB upperB measB vertB horizB heightB widthB,
 FromPlain
   packC propC lowerC upperC measC vertC horizC heightC widthC) =>
(PlainArray
   packA propA lowerA upperA measA vertA horizA heightA widthA a
 -> PlainArray
      packB propB lowerB upperB measB vertB horizB heightB widthB b
 -> PlainArray
      packC propC lowerC upperC measC vertC horizC heightC widthC c)
-> ArrayMatrix
     packA propA lowerA upperA measA vertA horizA heightA widthA a
-> ArrayMatrix
     packB propB lowerB upperB measB vertB horizB heightB widthB b
-> ArrayMatrix
     packC propC lowerC upperC measC vertC horizC heightC widthC c
ArrMatrix.lift2 ((Array (Full meas vert horiz height width) a
  -> Array (Full meas vert horiz height width) a
  -> Array (HermitianP pack width) a)
 -> Full meas vert horiz height width a
 -> Full meas vert horiz height width a
 -> HermitianP pack width a)
-> (a
    -> Array (Full meas vert horiz height width) a
    -> Array (Full meas vert horiz height width) a
    -> Array (HermitianP pack width) a)
-> a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
-> HermitianP pack width a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
      MirrorSingleton ConjugateMirror
-> a
-> Array (Full meas vert horiz height width) a
-> Array (Full meas vert horiz height width) a
-> Array (HermitianP pack width) a
forall pack mirror meas vert horiz height width a.
(Packing pack, Mirror mirror, Measure meas, C vert, C horiz,
 C height, Eq height, C width, Eq width, Floating a) =>
MirrorSingleton mirror
-> a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
-> Mosaic pack mirror Upper width a
Symmetric.scaledAnticommutator MirrorSingleton ConjugateMirror
Layout.ConjugateMirror

{- |
addAdjoint A = A^H + A
-}
addAdjoint ::
   (Layout.Packing pack, Shape.C sh, Class.Floating a) =>
   Square sh a -> HermitianP pack sh a
addAdjoint :: Square sh a -> HermitianP pack sh a
addAdjoint Square sh a
a =
   let pck :: PackingSingleton pack
pck = PackingSingleton pack
forall pack. Packing pack => PackingSingleton pack
Layout.autoPacking
   in PackingSingleton pack -> Id (HermitianP pack sh a)
forall pack property lower upper meas vert horiz height width a.
PackingSingleton pack
-> Id
     (ArrayMatrix
        pack property lower upper meas vert horiz height width a)
ArrMatrix.requirePacking PackingSingleton pack
pck Id (HermitianP pack sh a) -> Id (HermitianP pack sh a)
forall a b. (a -> b) -> a -> b
$
      case PackingSingleton pack
pck of
         PackingSingleton pack
Layout.Packed -> (PlainArray
   Unpacked Arbitrary Filled Filled Shape Small Small sh sh a
 -> PlainArray
      pack
      HermitianUnknownDefiniteness
      Filled
      Filled
      Shape
      Small
      Small
      sh
      sh
      a)
-> Square sh a -> HermitianP pack sh 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 PlainArray
  Unpacked Arbitrary Filled Filled Shape Small Small sh sh a
-> PlainArray
     pack
     HermitianUnknownDefiniteness
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
forall mirror sh a.
(Mirror mirror, C sh, Floating a) =>
Square sh a -> Mosaic mirror Upper sh a
Symmetric.addMirrored Square sh a
a
         PackingSingleton pack
Layout.Unpacked ->
            (FullArray Shape Small Small (Unchecked sh) (Unchecked sh) a
 -> FullArray Shape Small Small sh sh a)
-> UnpackedMatrix
     Arbitrary
     Filled
     Filled
     Shape
     Small
     Small
     (Unchecked sh)
     (Unchecked sh)
     a
-> UnpackedMatrix
     HermitianUnknownDefiniteness
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
forall propertyA lowerA upperA propertyB lowerB upperB measA vertA
       horizA heightA widthA a measB vertB horizB heightB widthB b.
(Property propertyA, Strip lowerA, Strip upperA,
 Property propertyB, Strip lowerB, Strip upperB) =>
(FullArray measA vertA horizA heightA widthA a
 -> FullArray measB vertB horizB heightB widthB b)
-> UnpackedMatrix
     propertyA lowerA upperA measA vertA horizA heightA widthA a
-> UnpackedMatrix
     propertyB lowerB upperB measB vertB horizB heightB widthB b
ArrMatrix.liftUnpacked1 FullArray Shape Small Small (Unchecked sh) (Unchecked sh) a
-> FullArray Shape Small Small sh sh a
forall meas vert horiz height width a.
(Measure meas, C vert, C horiz) =>
Full meas vert horiz (Unchecked height) (Unchecked width) a
-> Full meas vert horiz height width a
FullBasic.recheck (UnpackedMatrix
   Arbitrary
   Filled
   Filled
   Shape
   Small
   Small
   (Unchecked sh)
   (Unchecked sh)
   a
 -> UnpackedMatrix
      HermitianUnknownDefiniteness
      Filled
      Filled
      Shape
      Small
      Small
      sh
      sh
      a)
-> UnpackedMatrix
     Arbitrary
     Filled
     Filled
     Shape
     Small
     Small
     (Unchecked sh)
     (Unchecked sh)
     a
-> UnpackedMatrix
     HermitianUnknownDefiniteness
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
forall a b. (a -> b) -> a -> b
$
               let au :: UnpackedMatrix
  Arbitrary
  Filled
  Filled
  Shape
  Small
  Small
  (Unchecked sh)
  (Unchecked sh)
  a
au = Square sh a
-> UnpackedMatrix
     Arbitrary
     Filled
     Filled
     Shape
     Small
     Small
     (Unchecked sh)
     (Unchecked sh)
     a
forall property lower upper meas vert horiz height width a.
(Property property, Strip lower, Strip upper, Measure meas, C vert,
 C horiz) =>
Unpacked property lower upper meas vert horiz height width a
-> Unpacked
     property
     lower
     upper
     meas
     vert
     horiz
     (Unchecked height)
     (Unchecked width)
     a
ArrUnpacked.uncheck Square sh a
a
               in UnpackedMatrix
  Arbitrary
  Filled
  Filled
  Shape
  Small
  Small
  (Unchecked sh)
  (Unchecked sh)
  a
-> UnpackedMatrix
     Arbitrary
     Filled
     Filled
     Shape
     Small
     Small
     (Unchecked sh)
     (Unchecked sh)
     a
-> UnpackedMatrix
     Arbitrary
     Filled
     Filled
     Shape
     Small
     Small
     (Unchecked sh)
     (Unchecked sh)
     a
forall meas vert horiz property height width a pack lower upper.
(Measure meas, C vert, C horiz, Additive property, C height,
 Eq height, C width, Eq width, Floating a) =>
ArrayMatrix
  pack property lower upper meas vert horiz height width a
-> ArrayMatrix
     pack property lower upper meas vert horiz height width a
-> ArrayMatrix
     pack property lower upper meas vert horiz height width a
ArrMatrix.add (UnpackedMatrix
  Arbitrary
  Filled
  Filled
  Shape
  Small
  Small
  (Unchecked sh)
  (Unchecked sh)
  a
-> UnpackedMatrix
     Arbitrary
     Filled
     Filled
     Shape
     Small
     Small
     (Unchecked sh)
     (Unchecked sh)
     a
forall meas vert horiz height width a.
(Measure meas, C vert, C horiz, C height, C width, Floating a) =>
Full meas vert horiz height width a
-> Full meas horiz vert width height a
Full.adjoint UnpackedMatrix
  Arbitrary
  Filled
  Filled
  Shape
  Small
  Small
  (Unchecked sh)
  (Unchecked sh)
  a
au) UnpackedMatrix
  Arbitrary
  Filled
  Filled
  Shape
  Small
  Small
  (Unchecked sh)
  (Unchecked sh)
  a
au



solve ::
   (Layout.Packing pack) =>
   (TBool.C neg, TBool.C zero, TBool.C pos,
    Extent.Measure meas, Extent.C vert, Extent.C horiz,
    Shape.C sh, Eq sh, Shape.C nrhs, Class.Floating a) =>
   FlexHermitianP pack neg zero pos sh a ->
   Full meas vert horiz sh nrhs a -> Full meas vert horiz sh nrhs a
solve :: FlexHermitianP pack neg zero pos sh a
-> Full meas vert horiz sh nrhs a -> Full meas vert horiz sh nrhs a
solve FlexHermitianP pack neg zero pos sh a
a =
   case Omni
  pack (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh
-> (Singleton neg, Singleton zero, Singleton pos)
forall neg zero pos pack lower upper meas vert horiz height width.
(C neg, C zero, C pos) =>
Omni
  pack
  (Hermitian neg zero pos)
  lower
  upper
  meas
  vert
  horiz
  height
  width
-> (Singleton neg, Singleton zero, Singleton pos)
Omni.hermitianSet (Omni
   pack (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh
 -> (Singleton neg, Singleton zero, Singleton pos))
-> Omni
     pack (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh
-> (Singleton neg, Singleton zero, Singleton pos)
forall a b. (a -> b) -> a -> b
$ FlexHermitianP pack neg zero pos sh a
-> Omni
     pack (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh
forall pack property lower upper meas vert horiz height width a.
ArrayMatrix
  pack property lower upper meas vert horiz height width a
-> Omni pack property lower upper meas vert horiz height width
ArrMatrix.shape FlexHermitianP pack neg zero pos sh a
a of
      (Singleton neg
TBool.False, Singleton zero
_, Singleton pos
TBool.True) -> (PlainArray
   pack
   (Hermitian neg zero pos)
   Filled
   Filled
   Shape
   Small
   Small
   sh
   sh
   a
 -> PlainArray
      Unpacked Arbitrary Filled Filled meas vert horiz sh nrhs a
 -> PlainArray
      Unpacked Arbitrary Filled Filled meas vert horiz sh nrhs a)
-> FlexHermitianP pack neg zero pos sh a
-> Full meas vert horiz sh nrhs a
-> Full meas vert horiz sh nrhs a
forall packA propA lowerA upperA measA vertA horizA heightA widthA
       packB propB lowerB upperB measB vertB horizB heightB widthB packC
       propC lowerC upperC measC vertC horizC heightC widthC a b c.
(ToPlain
   packA propA lowerA upperA measA vertA horizA heightA widthA,
 ToPlain
   packB propB lowerB upperB measB vertB horizB heightB widthB,
 FromPlain
   packC propC lowerC upperC measC vertC horizC heightC widthC) =>
(PlainArray
   packA propA lowerA upperA measA vertA horizA heightA widthA a
 -> PlainArray
      packB propB lowerB upperB measB vertB horizB heightB widthB b
 -> PlainArray
      packC propC lowerC upperC measC vertC horizC heightC widthC c)
-> ArrayMatrix
     packA propA lowerA upperA measA vertA horizA heightA widthA a
-> ArrayMatrix
     packB propB lowerB upperB measB vertB horizB heightB widthB b
-> ArrayMatrix
     packC propC lowerC upperC measC vertC horizC heightC widthC c
ArrMatrix.lift2 PlainArray
  pack
  (Hermitian neg zero pos)
  Filled
  Filled
  Shape
  Small
  Small
  sh
  sh
  a
-> PlainArray
     Unpacked Arbitrary Filled Filled meas vert horiz sh nrhs a
-> PlainArray
     Unpacked Arbitrary Filled Filled meas vert horiz sh nrhs a
forall meas vert horiz sh nrhs a pack.
(Measure meas, C vert, C horiz, C sh, Eq sh, C nrhs, Floating a) =>
Hermitian pack sh a
-> Full meas vert horiz sh nrhs a -> Full meas vert horiz sh nrhs a
LinearPD.solve FlexHermitianP pack neg zero pos sh a
a
      (Singleton neg
TBool.True, Singleton zero
_, Singleton pos
TBool.False) ->
         Full meas vert horiz sh nrhs a -> Full meas vert horiz sh nrhs a
forall property meas vert horiz height width a pack lower upper.
(Homogeneous property, Measure meas, C vert, C horiz, C height,
 C width, Floating a) =>
ArrayMatrix
  pack property lower upper meas vert horiz height width a
-> ArrayMatrix
     pack property lower upper meas vert horiz height width a
ArrMatrix.negate (Full meas vert horiz sh nrhs a -> Full meas vert horiz sh nrhs a)
-> (Full meas vert horiz sh nrhs a
    -> Full meas vert horiz sh nrhs a)
-> Full meas vert horiz sh nrhs a
-> Full meas vert horiz sh nrhs a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PlainArray
   pack
   (Hermitian pos zero neg)
   Filled
   Filled
   Shape
   Small
   Small
   sh
   sh
   a
 -> PlainArray
      Unpacked Arbitrary Filled Filled meas vert horiz sh nrhs a
 -> PlainArray
      Unpacked Arbitrary Filled Filled meas vert horiz sh nrhs a)
-> ArrayMatrix
     pack
     (Hermitian pos zero neg)
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
-> Full meas vert horiz sh nrhs a
-> Full meas vert horiz sh nrhs a
forall packA propA lowerA upperA measA vertA horizA heightA widthA
       packB propB lowerB upperB measB vertB horizB heightB widthB packC
       propC lowerC upperC measC vertC horizC heightC widthC a b c.
(ToPlain
   packA propA lowerA upperA measA vertA horizA heightA widthA,
 ToPlain
   packB propB lowerB upperB measB vertB horizB heightB widthB,
 FromPlain
   packC propC lowerC upperC measC vertC horizC heightC widthC) =>
(PlainArray
   packA propA lowerA upperA measA vertA horizA heightA widthA a
 -> PlainArray
      packB propB lowerB upperB measB vertB horizB heightB widthB b
 -> PlainArray
      packC propC lowerC upperC measC vertC horizC heightC widthC c)
-> ArrayMatrix
     packA propA lowerA upperA measA vertA horizA heightA widthA a
-> ArrayMatrix
     packB propB lowerB upperB measB vertB horizB heightB widthB b
-> ArrayMatrix
     packC propC lowerC upperC measC vertC horizC heightC widthC c
ArrMatrix.lift2 PlainArray
  pack
  (Hermitian pos zero neg)
  Filled
  Filled
  Shape
  Small
  Small
  sh
  sh
  a
-> PlainArray
     Unpacked Arbitrary Filled Filled meas vert horiz sh nrhs a
-> PlainArray
     Unpacked Arbitrary Filled Filled meas vert horiz sh nrhs a
forall meas vert horiz sh nrhs a pack.
(Measure meas, C vert, C horiz, C sh, Eq sh, C nrhs, Floating a) =>
Hermitian pack sh a
-> Full meas vert horiz sh nrhs a -> Full meas vert horiz sh nrhs a
LinearPD.solve (FlexHermitianP pack neg zero pos sh a
-> ArrayMatrix
     pack
     (Hermitian pos zero neg)
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
forall neg zero pos sh a pack bands.
(C neg, C zero, C pos, C sh, Floating a) =>
AnyHermitianP pack neg zero pos bands sh a
-> AnyHermitianP pack pos zero neg bands sh a
negate FlexHermitianP pack neg zero pos sh a
a)
      (Singleton neg, Singleton zero, Singleton pos)
_ -> (PlainArray
   pack
   (Hermitian neg zero pos)
   Filled
   Filled
   Shape
   Small
   Small
   sh
   sh
   a
 -> PlainArray
      Unpacked Arbitrary Filled Filled meas vert horiz sh nrhs a
 -> PlainArray
      Unpacked Arbitrary Filled Filled meas vert horiz sh nrhs a)
-> FlexHermitianP pack neg zero pos sh a
-> Full meas vert horiz sh nrhs a
-> Full meas vert horiz sh nrhs a
forall packA propA lowerA upperA measA vertA horizA heightA widthA
       packB propB lowerB upperB measB vertB horizB heightB widthB packC
       propC lowerC upperC measC vertC horizC heightC widthC a b c.
(ToPlain
   packA propA lowerA upperA measA vertA horizA heightA widthA,
 ToPlain
   packB propB lowerB upperB measB vertB horizB heightB widthB,
 FromPlain
   packC propC lowerC upperC measC vertC horizC heightC widthC) =>
(PlainArray
   packA propA lowerA upperA measA vertA horizA heightA widthA a
 -> PlainArray
      packB propB lowerB upperB measB vertB horizB heightB widthB b
 -> PlainArray
      packC propC lowerC upperC measC vertC horizC heightC widthC c)
-> ArrayMatrix
     packA propA lowerA upperA measA vertA horizA heightA widthA a
-> ArrayMatrix
     packB propB lowerB upperB measB vertB horizB heightB widthB b
-> ArrayMatrix
     packC propC lowerC upperC measC vertC horizC heightC widthC c
ArrMatrix.lift2 PlainArray
  pack
  (Hermitian neg zero pos)
  Filled
  Filled
  Shape
  Small
  Small
  sh
  sh
  a
-> PlainArray
     Unpacked Arbitrary Filled Filled meas vert horiz sh nrhs a
-> PlainArray
     Unpacked Arbitrary Filled Filled meas vert horiz sh nrhs a
forall mirror meas vert horiz height width a pack.
(Mirror mirror, Measure meas, C vert, C horiz, Eq height, C height,
 C width, Floating a) =>
Mosaic pack mirror Upper height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
Symmetric.solve FlexHermitianP pack neg zero pos sh a
a

inverse ::
   (Layout.Packing pack,
    TBool.C neg, TBool.C zero, TBool.C pos, Shape.C sh, Class.Floating a) =>
   FlexHermitianP pack neg zero pos sh a ->
   FlexHermitianP pack neg zero pos sh a
inverse :: FlexHermitianP pack neg zero pos sh a
-> FlexHermitianP pack neg zero pos sh a
inverse FlexHermitianP pack neg zero pos sh a
a =
   case Omni
  pack (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh
-> (Singleton neg, Singleton zero, Singleton pos)
forall neg zero pos pack lower upper meas vert horiz height width.
(C neg, C zero, C pos) =>
Omni
  pack
  (Hermitian neg zero pos)
  lower
  upper
  meas
  vert
  horiz
  height
  width
-> (Singleton neg, Singleton zero, Singleton pos)
Omni.hermitianSet (Omni
   pack (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh
 -> (Singleton neg, Singleton zero, Singleton pos))
-> Omni
     pack (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh
-> (Singleton neg, Singleton zero, Singleton pos)
forall a b. (a -> b) -> a -> b
$ FlexHermitianP pack neg zero pos sh a
-> Omni
     pack (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh
forall pack property lower upper meas vert horiz height width a.
ArrayMatrix
  pack property lower upper meas vert horiz height width a
-> Omni pack property lower upper meas vert horiz height width
ArrMatrix.shape FlexHermitianP pack neg zero pos sh a
a of
      (Singleton neg
TBool.False, Singleton zero
_, Singleton pos
TBool.True) -> (PlainArray
   pack
   (Hermitian neg zero pos)
   Filled
   Filled
   Shape
   Small
   Small
   sh
   sh
   a
 -> PlainArray
      pack
      (Hermitian neg zero pos)
      Filled
      Filled
      Shape
      Small
      Small
      sh
      sh
      a)
-> FlexHermitianP pack neg zero pos sh a
-> FlexHermitianP pack neg zero pos sh 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 PlainArray
  pack
  (Hermitian neg zero pos)
  Filled
  Filled
  Shape
  Small
  Small
  sh
  sh
  a
-> PlainArray
     pack
     (Hermitian neg zero pos)
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
forall sh a pack.
(C sh, Floating a) =>
Hermitian pack sh a -> Hermitian pack sh a
LinearPD.inverse FlexHermitianP pack neg zero pos sh a
a
      (Singleton neg
TBool.True, Singleton zero
_, Singleton pos
TBool.False) ->
         AnyHermitianP pack pos zero neg Filled sh a
-> FlexHermitianP pack neg zero pos sh a
forall neg zero pos sh a pack bands.
(C neg, C zero, C pos, C sh, Floating a) =>
AnyHermitianP pack neg zero pos bands sh a
-> AnyHermitianP pack pos zero neg bands sh a
negate (AnyHermitianP pack pos zero neg Filled sh a
 -> FlexHermitianP pack neg zero pos sh a)
-> AnyHermitianP pack pos zero neg Filled sh a
-> FlexHermitianP pack neg zero pos sh a
forall a b. (a -> b) -> a -> b
$ (PlainArray
   pack
   (Hermitian pos zero neg)
   Filled
   Filled
   Shape
   Small
   Small
   sh
   sh
   a
 -> PlainArray
      pack
      (Hermitian pos zero neg)
      Filled
      Filled
      Shape
      Small
      Small
      sh
      sh
      a)
-> AnyHermitianP pack pos zero neg Filled sh a
-> AnyHermitianP pack pos zero neg Filled sh 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 PlainArray
  pack
  (Hermitian pos zero neg)
  Filled
  Filled
  Shape
  Small
  Small
  sh
  sh
  a
-> PlainArray
     pack
     (Hermitian pos zero neg)
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
forall sh a pack.
(C sh, Floating a) =>
Hermitian pack sh a -> Hermitian pack sh a
LinearPD.inverse (AnyHermitianP pack pos zero neg Filled sh a
 -> AnyHermitianP pack pos zero neg Filled sh a)
-> AnyHermitianP pack pos zero neg Filled sh a
-> AnyHermitianP pack pos zero neg Filled sh a
forall a b. (a -> b) -> a -> b
$ FlexHermitianP pack neg zero pos sh a
-> AnyHermitianP pack pos zero neg Filled sh a
forall neg zero pos sh a pack bands.
(C neg, C zero, C pos, C sh, Floating a) =>
AnyHermitianP pack neg zero pos bands sh a
-> AnyHermitianP pack pos zero neg bands sh a
negate FlexHermitianP pack neg zero pos sh a
a
      (Singleton neg, Singleton zero, Singleton pos)
_ -> (PlainArray
   pack
   (Hermitian neg zero pos)
   Filled
   Filled
   Shape
   Small
   Small
   sh
   sh
   a
 -> PlainArray
      pack
      (Hermitian neg zero pos)
      Filled
      Filled
      Shape
      Small
      Small
      sh
      sh
      a)
-> FlexHermitianP pack neg zero pos sh a
-> FlexHermitianP pack neg zero pos sh 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 PlainArray
  pack
  (Hermitian neg zero pos)
  Filled
  Filled
  Shape
  Small
  Small
  sh
  sh
  a
-> PlainArray
     pack
     (Hermitian neg zero pos)
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
forall mirror uplo sh a pack.
(Mirror mirror, UpLo uplo, C sh, Floating a) =>
Mosaic pack mirror uplo sh a -> Mosaic pack mirror uplo sh a
Symmetric.inverse FlexHermitianP pack neg zero pos sh a
a

determinant ::
   (Layout.Packing pack,
    TBool.C neg, TBool.C zero, TBool.C pos, Shape.C sh, Class.Floating a) =>
   FlexHermitianP pack neg zero pos sh a -> RealOf a
determinant :: FlexHermitianP pack neg zero pos sh a -> RealOf a
determinant FlexHermitianP pack neg zero pos sh a
a =
   case Omni
  pack (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh
-> (Singleton neg, Singleton zero, Singleton pos)
forall neg zero pos pack lower upper meas vert horiz height width.
(C neg, C zero, C pos) =>
Omni
  pack
  (Hermitian neg zero pos)
  lower
  upper
  meas
  vert
  horiz
  height
  width
-> (Singleton neg, Singleton zero, Singleton pos)
Omni.hermitianSet (Omni
   pack (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh
 -> (Singleton neg, Singleton zero, Singleton pos))
-> Omni
     pack (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh
-> (Singleton neg, Singleton zero, Singleton pos)
forall a b. (a -> b) -> a -> b
$ FlexHermitianP pack neg zero pos sh a
-> Omni
     pack (Hermitian neg zero pos) Filled Filled Shape Small Small sh sh
forall pack property lower upper meas vert horiz height width a.
ArrayMatrix
  pack property lower upper meas vert horiz height width a
-> Omni pack property lower upper meas vert horiz height width
ArrMatrix.shape FlexHermitianP pack neg zero pos sh a
a of
      (Singleton neg
TBool.False, Singleton zero
TBool.False, Singleton pos
TBool.True) ->
         Hermitian pack sh a -> RealOf a
forall sh a pack.
(C sh, Floating a) =>
Hermitian pack sh a -> RealOf a
LinearPD.determinant (Hermitian pack sh a -> RealOf a)
-> Hermitian pack sh a -> RealOf a
forall a b. (a -> b) -> a -> b
$ FlexHermitianP pack neg zero pos sh a
-> PlainArray
     pack
     (Hermitian neg zero pos)
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
forall pack property lower upper meas vert horiz height width a.
ToPlain pack property lower upper meas vert horiz height width =>
ArrayMatrix
  pack property lower upper meas vert horiz height width a
-> PlainArray
     pack property lower upper meas vert horiz height width a
ArrMatrix.toVector FlexHermitianP pack neg zero pos sh a
a
      (Singleton neg
TBool.True, Singleton zero
TBool.False, Singleton pos
TBool.False) ->
         case FlexHermitianP pack neg zero pos sh a -> ComplexSingleton a
forall a (f :: * -> *). Floating a => f a -> ComplexSingleton a
Scalar.complexSingletonOfFunctor FlexHermitianP pack neg zero pos sh a
a of
            ComplexSingleton a
Scalar.Real -> FlexHermitianP pack True False False sh a -> a
forall pack sh a ar.
(Packing pack, C sh, Floating a, RealOf a ~ ar, Real ar) =>
FlexHermitianP pack True False False sh a -> ar
determinantNegDef FlexHermitianP pack neg zero pos sh a
FlexHermitianP pack True False False sh a
a
            ComplexSingleton a
Scalar.Complex -> FlexHermitianP pack True False False sh a -> a
forall pack sh a ar.
(Packing pack, C sh, Floating a, RealOf a ~ ar, Real ar) =>
FlexHermitianP pack True False False sh a -> ar
determinantNegDef FlexHermitianP pack neg zero pos sh a
FlexHermitianP pack True False False sh a
a
      (Singleton neg, Singleton zero, Singleton pos)
_ -> Hermitian pack sh a -> RealOf a
forall pack sh a.
(Packing pack, C sh, Floating a) =>
HermitianP pack sh a -> RealOf a
Linear.determinant (Hermitian pack sh a -> RealOf a)
-> Hermitian pack sh a -> RealOf a
forall a b. (a -> b) -> a -> b
$ FlexHermitianP pack neg zero pos sh a
-> PlainArray
     pack
     (Hermitian neg zero pos)
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
forall pack property lower upper meas vert horiz height width a.
ToPlain pack property lower upper meas vert horiz height width =>
ArrayMatrix
  pack property lower upper meas vert horiz height width a
-> PlainArray
     pack property lower upper meas vert horiz height width a
ArrMatrix.toVector FlexHermitianP pack neg zero pos sh a
a

determinantNegDef ::
   (Layout.Packing pack,
    Shape.C sh, Class.Floating a, RealOf a ~ ar, Class.Real ar) =>
   FlexHermitianP pack TBool.True TBool.False TBool.False sh a -> ar
determinantNegDef :: FlexHermitianP pack True False False sh a -> ar
determinantNegDef FlexHermitianP pack True False False sh a
a =
   Quadratic pack (Hermitian True False False) Filled Filled sh -> ar
forall sh a pack property lower upper.
(C sh, Floating a) =>
Quadratic pack property lower upper sh -> a
OmniMatrix.signNegativeDeterminant (FlexHermitianP pack True False False sh a
-> Quadratic pack (Hermitian True False False) Filled Filled sh
forall pack property lower upper meas vert horiz height width a.
ArrayMatrix
  pack property lower upper meas vert horiz height width a
-> Omni pack property lower upper meas vert horiz height width
ArrMatrix.shape FlexHermitianP pack True False False sh a
a) ar -> ar -> ar
forall a. Num a => a -> a -> a
*
   (Hermitian pack sh a -> RealOf a
forall sh a pack.
(C sh, Floating a) =>
Hermitian pack sh a -> RealOf a
LinearPD.determinant (Hermitian pack sh a -> RealOf a)
-> Hermitian pack sh a -> RealOf a
forall a b. (a -> b) -> a -> b
$ ArrayMatrix
  pack
  (Hermitian False False True)
  Filled
  Filled
  Shape
  Small
  Small
  sh
  sh
  a
-> PlainArray
     pack
     (Hermitian False False True)
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
forall pack property lower upper meas vert horiz height width a.
ToPlain pack property lower upper meas vert horiz height width =>
ArrayMatrix
  pack property lower upper meas vert horiz height width a
-> PlainArray
     pack property lower upper meas vert horiz height width a
ArrMatrix.toVector (ArrayMatrix
   pack
   (Hermitian False False True)
   Filled
   Filled
   Shape
   Small
   Small
   sh
   sh
   a
 -> PlainArray
      pack
      (Hermitian False False True)
      Filled
      Filled
      Shape
      Small
      Small
      sh
      sh
      a)
-> ArrayMatrix
     pack
     (Hermitian False False True)
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
-> PlainArray
     pack
     (Hermitian False False True)
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
forall a b. (a -> b) -> a -> b
$ FlexHermitianP pack True False False sh a
-> ArrayMatrix
     pack
     (Hermitian False False True)
     Filled
     Filled
     Shape
     Small
     Small
     sh
     sh
     a
forall neg zero pos sh a pack bands.
(C neg, C zero, C pos, C sh, Floating a) =>
AnyHermitianP pack neg zero pos bands sh a
-> AnyHermitianP pack pos zero neg bands sh a
negate FlexHermitianP pack True False False sh a
a)



eigenvalues ::
   (Layout.Packing pack, TBool.C neg, TBool.C zero, TBool.C pos,
    ExtShape.Permutable sh, Class.Floating a) =>
   FlexHermitianP pack neg zero pos sh a -> Vector sh (RealOf a)
eigenvalues :: FlexHermitianP pack neg zero pos sh a -> Vector sh (RealOf a)
eigenvalues = HermitianP pack sh a -> Vector sh (RealOf a)
forall sh a pack.
(Permutable sh, Floating a) =>
HermitianP pack sh a -> Vector sh (RealOf a)
Eigen.values (HermitianP pack sh a -> Vector sh (RealOf a))
-> (FlexHermitianP pack neg zero pos sh a -> HermitianP pack sh a)
-> FlexHermitianP pack neg zero pos sh a
-> Vector sh (RealOf a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FlexHermitianP pack neg zero pos sh a -> HermitianP pack sh a
forall pack property lower upper meas vert horiz height width a.
ToPlain pack property lower upper meas vert horiz height width =>
ArrayMatrix
  pack property lower upper meas vert horiz height width a
-> PlainArray
     pack property lower upper meas vert horiz height width a
ArrMatrix.toVector

{- |
For symmetric eigenvalue problems, @eigensystem@ and @schur@ coincide.
-}
eigensystem ::
   (Layout.Packing pack, TBool.C neg, TBool.C zero, TBool.C pos,
    ExtShape.Permutable sh, Class.Floating a) =>
   FlexHermitianP pack neg zero pos sh a -> (Square sh a, Vector sh (RealOf a))
eigensystem :: FlexHermitianP pack neg zero pos sh a
-> (Square sh a, Vector sh (RealOf a))
eigensystem = (Array (Full Shape Small Small sh sh) a -> Square sh a)
-> (Array (Full Shape Small Small sh sh) a, Vector sh (RealOf a))
-> (Square sh a, Vector sh (RealOf a))
forall a c b. (a -> c) -> (a, b) -> (c, b)
mapFst Array (Full Shape Small Small sh sh) a -> Square 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, Vector sh (RealOf a))
 -> (Square sh a, Vector sh (RealOf a)))
-> (FlexHermitianP pack neg zero pos sh a
    -> (Array (Full Shape Small Small sh sh) a, Vector sh (RealOf a)))
-> FlexHermitianP pack neg zero pos sh a
-> (Square sh a, Vector sh (RealOf a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HermitianP pack sh a
-> (Array (Full Shape Small Small sh sh) a, Vector sh (RealOf a))
forall sh a pack.
(Permutable sh, Floating a) =>
HermitianP pack sh a -> (Square sh a, Vector sh (RealOf a))
Eigen.decompose (HermitianP pack sh a
 -> (Array (Full Shape Small Small sh sh) a, Vector sh (RealOf a)))
-> (FlexHermitianP pack neg zero pos sh a -> HermitianP pack sh a)
-> FlexHermitianP pack neg zero pos sh a
-> (Array (Full Shape Small Small sh sh) a, Vector sh (RealOf a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FlexHermitianP pack neg zero pos sh a -> HermitianP pack sh a
forall pack property lower upper meas vert horiz height width a.
ToPlain pack property lower upper meas vert horiz height width =>
ArrayMatrix
  pack property lower upper meas vert horiz height width a
-> PlainArray
     pack property lower upper meas vert horiz height width a
ArrMatrix.toVector