{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module Numeric.LAPACK.Matrix.BandedHermitian (
   BandedHermitian,
   Transposition(..),

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

   size,
   fromList,
   identity,
   diagonal,
   takeDiagonal,
   toHermitian,
   toBanded,
   forceOrder,
   takeTopLeft,
   takeBottomRight,
   negate,
   multiplyVector,
   multiplyFull,
   gramian,
   sumRank1,

   eigenvalues,
   eigensystem,
   ) where

import qualified Numeric.LAPACK.Matrix.BandedHermitian.Eigen as Eigen
import qualified Numeric.LAPACK.Matrix.BandedHermitian.Basic as Basic

import qualified Numeric.LAPACK.Matrix.Array.Hermitian as Hermitian
import qualified Numeric.LAPACK.Matrix.Array.Banded as Banded
import qualified Numeric.LAPACK.Matrix.Array as ArrMatrix
import qualified Numeric.LAPACK.Matrix.Shape.Omni as Omni
import qualified Numeric.LAPACK.Matrix.Shape as MatrixShape
import qualified Numeric.LAPACK.Matrix.Extent as Extent
import qualified Numeric.LAPACK.Vector as Vector
import qualified Numeric.LAPACK.Shape as ExtShape
import Numeric.LAPACK.Matrix.Array.Banded (Square)
import Numeric.LAPACK.Matrix.Array.Mosaic (FlexHermitian)
import Numeric.LAPACK.Matrix.Array (Full)
import Numeric.LAPACK.Matrix.Layout.Private (Order, UnaryProxy, natFromProxy)
import Numeric.LAPACK.Matrix.Modifier (Transposition(NonTransposed, Transposed))
import Numeric.LAPACK.Vector (Vector)
import Numeric.LAPACK.Scalar (RealOf)

import qualified Numeric.Netlib.Class as Class

import qualified Type.Data.Num.Unary.Literal as TypeNum
import qualified Type.Data.Num.Unary.Proof as Proof
import qualified Type.Data.Num.Unary as Unary
import qualified Type.Data.Bool as TBool
import Type.Data.Num.Unary ((:+:))

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

import Data.Tuple.HT (mapPair, mapFst)

import Prelude hiding (negate)


type BandedHermitian offDiag sh = Banded.Hermitian offDiag sh
type Diagonal size = BandedHermitian TypeNum.U0 size


size :: BandedHermitian offDiag sh a -> sh
size :: BandedHermitian offDiag sh a -> sh
size = Omni
  Packed
  HermitianUnknownDefiniteness
  (Bands offDiag)
  (Bands offDiag)
  Shape
  Small
  Small
  sh
  sh
-> sh
forall meas vert horiz pack property lower upper height width.
(Measure meas, C vert, C horiz) =>
Omni pack property lower upper meas vert horiz height width
-> height
Omni.height (Omni
   Packed
   HermitianUnknownDefiniteness
   (Bands offDiag)
   (Bands offDiag)
   Shape
   Small
   Small
   sh
   sh
 -> sh)
-> (BandedHermitian offDiag sh a
    -> Omni
         Packed
         HermitianUnknownDefiniteness
         (Bands offDiag)
         (Bands offDiag)
         Shape
         Small
         Small
         sh
         sh)
-> BandedHermitian offDiag sh a
-> sh
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BandedHermitian offDiag sh a
-> Omni
     Packed
     HermitianUnknownDefiniteness
     (Bands offDiag)
     (Bands offDiag)
     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 ::
   (Unary.Natural offDiag, Shape.C size, Class.Floating a) =>
   UnaryProxy offDiag -> Order -> size -> [a] ->
   BandedHermitian offDiag size a
fromList :: UnaryProxy offDiag
-> Order -> size -> [a] -> BandedHermitian offDiag size a
fromList UnaryProxy offDiag
numOff Order
order size
size_ =
   Array (BandedHermitian offDiag size) a
-> BandedHermitian offDiag size 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 (BandedHermitian offDiag size) a
 -> BandedHermitian offDiag size a)
-> ([a] -> Array (BandedHermitian offDiag size) a)
-> [a]
-> BandedHermitian offDiag size a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnaryProxy offDiag
-> Order -> size -> [a] -> Array (BandedHermitian offDiag size) a
forall offDiag size a.
(Natural offDiag, C size, Storable a) =>
UnaryProxy offDiag
-> Order -> size -> [a] -> BandedHermitian offDiag size a
Basic.fromList UnaryProxy offDiag
numOff Order
order size
size_

identity ::
   (Shape.C sh, Class.Floating a) =>
   sh -> Banded.HermitianPosDef TypeNum.U0 sh a
identity :: sh -> HermitianPosDef U0 sh a
identity = Array (BandedHermitian U0 sh) a -> HermitianPosDef U0 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 (BandedHermitian U0 sh) a -> HermitianPosDef U0 sh a)
-> (sh -> Array (BandedHermitian U0 sh) a)
-> sh
-> HermitianPosDef U0 sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. sh -> Array (BandedHermitian U0 sh) a
forall sh a. (C sh, Floating a) => sh -> Diagonal sh a
Basic.identity

diagonal ::
   (Shape.C sh, Class.Floating a) => Vector sh (RealOf a) -> Diagonal sh a
diagonal :: Vector sh (RealOf a) -> Diagonal sh a
diagonal = Array (BandedHermitian U0 sh) a -> Diagonal 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 (BandedHermitian U0 sh) a -> Diagonal sh a)
-> (Vector sh (RealOf a) -> Array (BandedHermitian U0 sh) a)
-> Vector sh (RealOf a)
-> Diagonal sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector sh (RealOf a) -> Array (BandedHermitian U0 sh) a
forall sh a.
(C sh, Floating a) =>
Vector sh (RealOf a) -> Diagonal sh a
Basic.diagonal

takeDiagonal ::
   (TBool.C neg, TBool.C zero, TBool.C pos) =>
   (Unary.Natural offDiag, Shape.C size, Class.Floating a) =>
   Banded.FlexHermitian neg zero pos offDiag size a ->
   Vector size (RealOf a)
takeDiagonal :: FlexHermitian neg zero pos offDiag size a -> Vector size (RealOf a)
takeDiagonal = BandedHermitian offDiag size a -> Vector size (RealOf a)
forall offDiag size a.
(Natural offDiag, C size, Floating a) =>
BandedHermitian offDiag size a -> Vector size (RealOf a)
Basic.takeDiagonal (BandedHermitian offDiag size a -> Vector size (RealOf a))
-> (FlexHermitian neg zero pos offDiag size a
    -> BandedHermitian offDiag size a)
-> FlexHermitian neg zero pos offDiag size a
-> Vector size (RealOf a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FlexHermitian neg zero pos offDiag size a
-> BandedHermitian offDiag size 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

toHermitian ::
   (TBool.C neg, TBool.C zero, TBool.C pos) =>
   (Unary.Natural offDiag, Shape.C size, Class.Floating a) =>
   Banded.FlexHermitian neg zero pos offDiag size a ->
   FlexHermitian neg zero pos size a
toHermitian :: FlexHermitian neg zero pos offDiag size a
-> FlexHermitian neg zero pos size a
toHermitian = (PlainArray
   Packed
   (Hermitian neg zero pos)
   (Bands offDiag)
   (Bands offDiag)
   Shape
   Small
   Small
   size
   size
   a
 -> PlainArray
      Packed
      (Hermitian neg zero pos)
      Filled
      Filled
      Shape
      Small
      Small
      size
      size
      a)
-> FlexHermitian neg zero pos offDiag size a
-> FlexHermitian neg zero pos size 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
  Packed
  (Hermitian neg zero pos)
  (Bands offDiag)
  (Bands offDiag)
  Shape
  Small
  Small
  size
  size
  a
-> PlainArray
     Packed
     (Hermitian neg zero pos)
     Filled
     Filled
     Shape
     Small
     Small
     size
     size
     a
forall offDiag size a.
(Natural offDiag, C size, Floating a) =>
BandedHermitian offDiag size a -> Hermitian size a
Basic.toHermitian

toBanded ::
   (TBool.C neg, TBool.C zero, TBool.C pos,
    Unary.Natural offDiag, Shape.C size, Class.Floating a) =>
   Banded.FlexHermitian neg zero pos offDiag size a ->
   Square offDiag offDiag size a
toBanded :: FlexHermitian neg zero pos offDiag size a
-> Square offDiag offDiag size a
toBanded = (PlainArray
   Packed
   (Hermitian neg zero pos)
   (Bands offDiag)
   (Bands offDiag)
   Shape
   Small
   Small
   size
   size
   a
 -> PlainArray
      Packed
      Arbitrary
      (Bands offDiag)
      (Bands offDiag)
      Shape
      Small
      Small
      size
      size
      a)
-> FlexHermitian neg zero pos offDiag size a
-> Square offDiag offDiag size 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
  Packed
  (Hermitian neg zero pos)
  (Bands offDiag)
  (Bands offDiag)
  Shape
  Small
  Small
  size
  size
  a
-> PlainArray
     Packed
     Arbitrary
     (Bands offDiag)
     (Bands offDiag)
     Shape
     Small
     Small
     size
     size
     a
forall offDiag size a.
(Natural offDiag, C size, Floating a) =>
BandedHermitian offDiag size a -> Square offDiag offDiag size a
Basic.toBanded


forceOrder ::
   (TBool.C neg, TBool.C zero, TBool.C pos,
    Unary.Natural offDiag, Shape.C size, Class.Floating a) =>
   Order ->
   Banded.FlexHermitian neg zero pos offDiag size a ->
   Banded.FlexHermitian neg zero pos offDiag size a
forceOrder :: Order
-> FlexHermitian neg zero pos offDiag size a
-> FlexHermitian neg zero pos offDiag size a
forceOrder = (Array (BandedHermitian offDiag size) a
 -> Array (BandedHermitian offDiag size) a)
-> FlexHermitian neg zero pos offDiag size a
-> FlexHermitian neg zero pos offDiag size 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 (BandedHermitian offDiag size) a
  -> Array (BandedHermitian offDiag size) a)
 -> FlexHermitian neg zero pos offDiag size a
 -> FlexHermitian neg zero pos offDiag size a)
-> (Order
    -> Array (BandedHermitian offDiag size) a
    -> Array (BandedHermitian offDiag size) a)
-> Order
-> FlexHermitian neg zero pos offDiag size a
-> FlexHermitian neg zero pos offDiag size a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Order
-> Array (BandedHermitian offDiag size) a
-> Array (BandedHermitian offDiag size) a
forall offDiag size a.
(Natural offDiag, C size, Floating a) =>
Order
-> BandedHermitian offDiag size a -> BandedHermitian offDiag size a
Basic.forceOrder


takeTopLeft ::
   (TBool.C neg, TBool.C zero, TBool.C pos,
    Unary.Natural offDiag, Shape.C sh0, Shape.C sh1, Class.Floating a) =>
   Banded.FlexHermitian neg zero pos offDiag (sh0 ::+ sh1) a ->
   Banded.FlexHermitian neg zero pos offDiag sh0 a
takeTopLeft :: FlexHermitian neg zero pos offDiag (sh0 ::+ sh1) a
-> FlexHermitian neg zero pos offDiag sh0 a
takeTopLeft = (PlainArray
   Packed
   (Hermitian neg zero pos)
   (Bands offDiag)
   (Bands offDiag)
   Shape
   Small
   Small
   (sh0 ::+ sh1)
   (sh0 ::+ sh1)
   a
 -> PlainArray
      Packed
      (Hermitian neg zero pos)
      (Bands offDiag)
      (Bands offDiag)
      Shape
      Small
      Small
      sh0
      sh0
      a)
-> FlexHermitian neg zero pos offDiag (sh0 ::+ sh1) a
-> FlexHermitian neg zero pos offDiag 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
  Packed
  (Hermitian neg zero pos)
  (Bands offDiag)
  (Bands offDiag)
  Shape
  Small
  Small
  (sh0 ::+ sh1)
  (sh0 ::+ sh1)
  a
-> PlainArray
     Packed
     (Hermitian neg zero pos)
     (Bands offDiag)
     (Bands offDiag)
     Shape
     Small
     Small
     sh0
     sh0
     a
forall offDiag sh0 sh1 a.
(Natural offDiag, C sh0, C sh1, Floating a) =>
BandedHermitian offDiag (sh0 ::+ sh1) a
-> BandedHermitian offDiag sh0 a
Basic.takeTopLeft

takeBottomRight ::
   (TBool.C neg, TBool.C zero, TBool.C pos,
    Unary.Natural offDiag, Shape.C sh0, Shape.C sh1, Class.Floating a) =>
   Banded.FlexHermitian neg zero pos offDiag (sh0 ::+ sh1) a ->
   Banded.FlexHermitian neg zero pos offDiag sh1 a
takeBottomRight :: FlexHermitian neg zero pos offDiag (sh0 ::+ sh1) a
-> FlexHermitian neg zero pos offDiag sh1 a
takeBottomRight = (PlainArray
   Packed
   (Hermitian neg zero pos)
   (Bands offDiag)
   (Bands offDiag)
   Shape
   Small
   Small
   (sh0 ::+ sh1)
   (sh0 ::+ sh1)
   a
 -> PlainArray
      Packed
      (Hermitian neg zero pos)
      (Bands offDiag)
      (Bands offDiag)
      Shape
      Small
      Small
      sh1
      sh1
      a)
-> FlexHermitian neg zero pos offDiag (sh0 ::+ sh1) a
-> FlexHermitian neg zero pos offDiag 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
  Packed
  (Hermitian neg zero pos)
  (Bands offDiag)
  (Bands offDiag)
  Shape
  Small
  Small
  (sh0 ::+ sh1)
  (sh0 ::+ sh1)
  a
-> PlainArray
     Packed
     (Hermitian neg zero pos)
     (Bands offDiag)
     (Bands offDiag)
     Shape
     Small
     Small
     sh1
     sh1
     a
forall offDiag sh0 sh1 a.
(Natural offDiag, C sh0, C sh1, Floating a) =>
BandedHermitian offDiag (sh0 ::+ sh1) a
-> BandedHermitian offDiag sh1 a
Basic.takeBottomRight


negate ::
   (TBool.C neg, TBool.C zero, TBool.C pos,
    Unary.Natural offDiag, Shape.C sh, Class.Floating a) =>
   Banded.FlexHermitian neg zero pos offDiag sh a ->
   Banded.FlexHermitian pos zero neg offDiag sh a
negate :: FlexHermitian neg zero pos offDiag sh a
-> FlexHermitian pos zero neg offDiag sh a
negate = (PlainArray
   Packed
   (Hermitian neg zero pos)
   (Bands offDiag)
   (Bands offDiag)
   Shape
   Small
   Small
   sh
   sh
   a
 -> PlainArray
      Packed
      (Hermitian pos zero neg)
      (Bands offDiag)
      (Bands offDiag)
      Shape
      Small
      Small
      sh
      sh
      a)
-> FlexHermitian neg zero pos offDiag sh a
-> FlexHermitian pos zero neg offDiag 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
  Packed
  (Hermitian neg zero pos)
  (Bands offDiag)
  (Bands offDiag)
  Shape
  Small
  Small
  sh
  sh
  a
-> PlainArray
     Packed
     (Hermitian pos zero neg)
     (Bands offDiag)
     (Bands offDiag)
     Shape
     Small
     Small
     sh
     sh
     a
forall sh a. (C sh, Floating a) => Vector sh a -> Vector sh a
Vector.negate


multiplyVector ::
   (TBool.C neg, TBool.C zero, TBool.C pos,
    Unary.Natural offDiag, Shape.C size, Eq size, Class.Floating a) =>
   Transposition ->
   Banded.FlexHermitian neg zero pos offDiag size a ->
   Vector size a -> Vector size a
multiplyVector :: Transposition
-> FlexHermitian neg zero pos offDiag size a
-> Vector size a
-> Vector size a
multiplyVector Transposition
transposed =
   Transposition
-> BandedHermitian offDiag size a -> Vector size a -> Vector size a
forall offDiag size a.
(Natural offDiag, C size, Eq size, Floating a) =>
Transposition
-> BandedHermitian offDiag size a -> Vector size a -> Vector size a
Basic.multiplyVector Transposition
transposed (BandedHermitian offDiag size a -> Vector size a -> Vector size a)
-> (FlexHermitian neg zero pos offDiag size a
    -> BandedHermitian offDiag size a)
-> FlexHermitian neg zero pos offDiag size a
-> Vector size a
-> Vector size a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.  FlexHermitian neg zero pos offDiag size a
-> BandedHermitian offDiag size 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

gramian ::
   (Shape.C size, Eq size, Class.Floating a,
    Unary.Natural sub, Unary.Natural super) =>
   Square sub super size a ->
   Banded.HermitianPosSemidef (sub :+: super) size a
gramian :: Square sub super size a
-> HermitianPosSemidef (sub :+: super) size a
gramian Square sub super size a
a =
   case (UnaryProxy sub -> Nat sub, UnaryProxy super -> Nat super)
-> (UnaryProxy sub, UnaryProxy super) -> (Nat sub, Nat super)
forall a c b d. (a -> c, b -> d) -> (a, b) -> (c, d)
mapPair (UnaryProxy sub -> Nat sub
forall n. Natural n => UnaryProxy n -> Nat n
natFromProxy,UnaryProxy super -> Nat super
forall n. Natural n => UnaryProxy n -> Nat n
natFromProxy) ((UnaryProxy sub, UnaryProxy super) -> (Nat sub, Nat super))
-> (UnaryProxy sub, UnaryProxy super) -> (Nat sub, Nat super)
forall a b. (a -> b) -> a -> b
$
        Omni
  Packed
  Arbitrary
  (Bands sub)
  (Bands super)
  Shape
  Small
  Small
  size
  size
-> (UnaryProxy sub, UnaryProxy super)
forall property sub super meas vert horiz height width.
Omni
  Packed
  property
  (Bands sub)
  (Bands super)
  meas
  vert
  horiz
  height
  width
-> (UnaryProxy sub, UnaryProxy super)
MatrixShape.bandedOffDiagonals (Omni
   Packed
   Arbitrary
   (Bands sub)
   (Bands super)
   Shape
   Small
   Small
   size
   size
 -> (UnaryProxy sub, UnaryProxy super))
-> Omni
     Packed
     Arbitrary
     (Bands sub)
     (Bands super)
     Shape
     Small
     Small
     size
     size
-> (UnaryProxy sub, UnaryProxy super)
forall a b. (a -> b) -> a -> b
$ Square sub super size a
-> Omni
     Packed
     Arbitrary
     (Bands sub)
     (Bands super)
     Shape
     Small
     Small
     size
     size
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 Square sub super size a
a of
      (Nat sub
sub,Nat super
super) ->
         case Nat sub -> Nat super -> Nat (sub :+: super)
forall x y. Nat x -> Nat y -> Nat (x :+: y)
Proof.addNat Nat sub
sub Nat super
super of
            Nat (sub :+: super)
Proof.Nat -> (PlainArray
   Packed
   Arbitrary
   (Bands sub)
   (Bands super)
   Shape
   Small
   Small
   size
   size
   a
 -> PlainArray
      Packed
      HermitianPositiveSemidefinite
      (Bands (sub :+: super))
      (Bands (sub :+: super))
      Shape
      Small
      Small
      size
      size
      a)
-> Square sub super size a
-> HermitianPosSemidef (sub :+: super) size 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
  Packed
  Arbitrary
  (Bands sub)
  (Bands super)
  Shape
  Small
  Small
  size
  size
  a
-> PlainArray
     Packed
     HermitianPositiveSemidefinite
     (Bands (sub :+: super))
     (Bands (sub :+: super))
     Shape
     Small
     Small
     size
     size
     a
forall size a sub super.
(C size, Eq size, Floating a, Natural sub, Natural super) =>
Square sub super size a -> BandedHermitian (sub :+: super) size a
Basic.gramian Square sub super size a
a

multiplyFull ::
   (TBool.C neg, TBool.C zero, TBool.C pos,
    Unary.Natural offDiag, Extent.Measure meas, Extent.C vert, Extent.C horiz,
    Shape.C height, Eq height, Shape.C width, Class.Floating a) =>
   Transposition ->
   Banded.FlexHermitian neg zero pos offDiag height a ->
   Full meas vert horiz height width a ->
   Full meas vert horiz height width a
multiplyFull :: Transposition
-> FlexHermitian neg zero pos offDiag height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
multiplyFull = (Array (BandedHermitian offDiag height) a
 -> Array (Full meas vert horiz height width) a
 -> Array (Full meas vert horiz height width) a)
-> FlexHermitian neg zero pos offDiag 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 ((Array (BandedHermitian offDiag height) a
  -> Array (Full meas vert horiz height width) a
  -> Array (Full meas vert horiz height width) a)
 -> FlexHermitian neg zero pos offDiag height a
 -> Full meas vert horiz height width a
 -> Full meas vert horiz height width a)
-> (Transposition
    -> Array (BandedHermitian offDiag height) a
    -> Array (Full meas vert horiz height width) a
    -> Array (Full meas vert horiz height width) a)
-> Transposition
-> FlexHermitian neg zero pos offDiag 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
. Transposition
-> Array (BandedHermitian offDiag height) a
-> Array (Full meas vert horiz height width) a
-> Array (Full meas vert horiz height width) a
forall offDiag meas vert horiz height width a.
(Natural offDiag, Measure meas, C vert, C horiz, C height,
 Eq height, C width, Floating a) =>
Transposition
-> BandedHermitian offDiag height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
Basic.multiplyFull

{- |
The list represents ragged rows of a sparse matrix.
-}
sumRank1 ::
   (Unary.Natural k, Shape.Indexed sh, Class.Floating a) =>
   Order -> sh ->
   [(RealOf a, (Shape.Index sh, Basic.StaticVector (Unary.Succ k) a))] ->
   Banded.HermitianPosSemidef k sh a
sumRank1 :: Order
-> sh
-> [(RealOf a, (Index sh, StaticVector (Succ k) a))]
-> HermitianPosSemidef k sh a
sumRank1 Order
order sh
sh = Array (BandedHermitian k sh) a -> HermitianPosSemidef k 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 (BandedHermitian k sh) a -> HermitianPosSemidef k sh a)
-> ([(RealOf a, (Index sh, StaticVector (Succ k) a))]
    -> Array (BandedHermitian k sh) a)
-> [(RealOf a, (Index sh, StaticVector (Succ k) a))]
-> HermitianPosSemidef k sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Order
-> sh
-> [(RealOf a, (Index sh, StaticVector (Succ k) a))]
-> Array (BandedHermitian k sh) a
forall k sh a.
(Natural k, Indexed sh, Floating a) =>
Order
-> sh
-> [(RealOf a, (Index sh, StaticVector (Succ k) a))]
-> BandedHermitian k sh a
Basic.sumRank1 Order
order sh
sh


eigenvalues ::
   (TBool.C neg, TBool.C zero, TBool.C pos, Unary.Natural offDiag) =>
   (ExtShape.Permutable sh, Class.Floating a) =>
   Banded.FlexHermitian neg zero pos offDiag sh a -> Vector sh (RealOf a)
eigenvalues :: FlexHermitian neg zero pos offDiag sh a -> Vector sh (RealOf a)
eigenvalues = BandedHermitian offDiag sh a -> Vector sh (RealOf a)
forall offDiag sh a.
(Natural offDiag, Permutable sh, Floating a) =>
BandedHermitian offDiag sh a -> Vector sh (RealOf a)
Eigen.values (BandedHermitian offDiag sh a -> Vector sh (RealOf a))
-> (FlexHermitian neg zero pos offDiag sh a
    -> BandedHermitian offDiag sh a)
-> FlexHermitian neg zero pos offDiag sh a
-> Vector sh (RealOf a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FlexHermitian neg zero pos offDiag sh a
-> BandedHermitian offDiag 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 ::
   (TBool.C neg, TBool.C zero, TBool.C pos, Unary.Natural offDiag) =>
   (ExtShape.Permutable sh, Class.Floating a) =>
   Banded.FlexHermitian neg zero pos offDiag sh a ->
   (ArrMatrix.Square sh a, Vector sh (RealOf a))
eigensystem :: FlexHermitian neg zero pos offDiag 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)))
-> (FlexHermitian neg zero pos offDiag sh a
    -> (Array (Full Shape Small Small sh sh) a, Vector sh (RealOf a)))
-> FlexHermitian neg zero pos offDiag sh a
-> (Square sh a, Vector sh (RealOf a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BandedHermitian offDiag sh a
-> (Array (Full Shape Small Small sh sh) a, Vector sh (RealOf a))
forall offDiag sh a.
(Natural offDiag, Permutable sh, Floating a) =>
BandedHermitian offDiag sh a -> (Square sh a, Vector sh (RealOf a))
Eigen.decompose (BandedHermitian offDiag sh a
 -> (Array (Full Shape Small Small sh sh) a, Vector sh (RealOf a)))
-> (FlexHermitian neg zero pos offDiag sh a
    -> BandedHermitian offDiag sh a)
-> FlexHermitian neg zero pos offDiag sh a
-> (Array (Full Shape Small Small sh sh) a, Vector sh (RealOf a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FlexHermitian neg zero pos offDiag sh a
-> BandedHermitian offDiag 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