{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeOperators #-}
module Numeric.LAPACK.Matrix.Triangular (
   Triangular, MatrixShape.UpLo,
   Diagonal, FlexDiagonal,
   Upper, FlexUpper, UnitUpper,
   Lower, FlexLower, UnitLower,
   Symmetric, FlexSymmetric,
   size,
   fromList, autoFromList,
   diagonalFromList, autoDiagonalFromList,
   lowerFromList, autoLowerFromList,
   upperFromList, autoUpperFromList,
   symmetricFromList, autoSymmetricFromList,
   asDiagonal, asLower, asUpper, asSymmetric,
   requireUnitDiagonal, requireNonUnitDiagonal,
   relaxUnitDiagonal, strictNonUnitDiagonal,
   identity,
   diagonal,
   takeDiagonal,
   transpose,
   adjoint,

   stackDiagonal, (%%%),
   stackLower, (#%%%),
   stackUpper, (%%%#),
   stackSymmetric, (#%%%#),
   splitDiagonal,
   splitLower,
   splitUpper,
   splitSymmetric,
   takeTopLeft,
   takeTopRight,
   takeBottomLeft,
   takeBottomRight,

   toSquare,
   takeLower,
   takeUpper,

   fromLowerRowMajor, toLowerRowMajor,
   fromUpperRowMajor, toUpperRowMajor,
   forceOrder, adaptOrder,

   add, sub,

   Tri.PowerDiag,
   Tri.PowerContentDiag,
   multiplyVector,
   square,
   multiply,
   multiplyFull,

   solve,
   inverse,
   determinant,

   eigenvalues,
   eigensystem,
   ) where

import qualified Numeric.LAPACK.Matrix.Triangular.Eigen as Eigen
import qualified Numeric.LAPACK.Matrix.Triangular.Linear as Linear
import qualified Numeric.LAPACK.Matrix.Triangular.Basic as Basic
import qualified Numeric.LAPACK.Matrix.Triangular.Private as Tri

import qualified Numeric.LAPACK.Matrix.Array as ArrMatrix
import qualified Numeric.LAPACK.Matrix.Shape.Private as MatrixShape
import qualified Numeric.LAPACK.Matrix.Extent as Extent
import Numeric.LAPACK.Matrix.Array.Triangular (
   Triangular,
   Diagonal,  FlexDiagonal,
   Lower,     FlexLower,     UnitLower,
   Upper,     FlexUpper,     UnitUpper,
   Symmetric, FlexSymmetric,
   )
import Numeric.LAPACK.Matrix.Array (Full, General, Square)
import Numeric.LAPACK.Matrix.Shape.Private (NonUnit, Unit, Order)
import Numeric.LAPACK.Matrix.Private (ShapeInt)
import Numeric.LAPACK.Vector (Vector)

import qualified Numeric.Netlib.Class as Class

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

import Foreign.Storable (Storable)

import Data.Tuple.HT (mapTriple)


size :: Triangular lo diag up sh a -> sh
size :: Triangular lo diag up sh a -> sh
size = Triangular lo diag up sh -> sh
forall lo diag up size. Triangular lo diag up size -> size
MatrixShape.triangularSize (Triangular lo diag up sh -> sh)
-> (Triangular lo diag up sh a -> Triangular lo diag up sh)
-> Triangular lo diag up sh a
-> sh
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Triangular lo diag up sh a -> Triangular lo diag up sh
forall sh a. ArrayMatrix sh a -> sh
ArrMatrix.shape

transpose ::
   (MatrixShape.Content lo, MatrixShape.Content up,
    MatrixShape.TriDiag diag) =>
   Triangular lo diag up sh a -> Triangular up diag lo sh a
transpose :: Triangular lo diag up sh a -> Triangular up diag lo sh a
transpose = (Array (Triangular lo diag up sh) a
 -> Array (Triangular up diag lo sh) a)
-> Triangular lo diag up sh a -> Triangular up diag lo sh a
forall shA a shB b.
(Array shA a -> Array shB b)
-> ArrayMatrix shA a -> ArrayMatrix shB b
ArrMatrix.lift1 Array (Triangular lo diag up sh) a
-> Array (Triangular up diag lo sh) a
forall lo up diag sh a.
(Content lo, Content up, TriDiag diag) =>
Triangular lo diag up sh a -> Triangular up diag lo sh a
Basic.transpose

adjoint ::
   (MatrixShape.Content lo, MatrixShape.Content up,
    MatrixShape.TriDiag diag, Shape.C sh, Class.Floating a) =>
   Triangular lo diag up sh a -> Triangular up diag lo sh a
adjoint :: Triangular lo diag up sh a -> Triangular up diag lo sh a
adjoint = (Array (Triangular lo diag up sh) a
 -> Array (Triangular up diag lo sh) a)
-> Triangular lo diag up sh a -> Triangular up diag lo sh a
forall shA a shB b.
(Array shA a -> Array shB b)
-> ArrayMatrix shA a -> ArrayMatrix shB b
ArrMatrix.lift1 Array (Triangular lo diag up sh) a
-> Array (Triangular up diag lo sh) a
forall lo up diag sh a.
(Content lo, Content up, TriDiag diag, C sh, Floating a) =>
Triangular lo diag up sh a -> Triangular up diag lo sh a
Basic.adjoint

fromList ::
   (MatrixShape.Content lo, MatrixShape.Content up, Shape.C sh, Storable a) =>
   Order -> sh -> [a] -> Triangular lo NonUnit up sh a
fromList :: Order -> sh -> [a] -> Triangular lo NonUnit up sh a
fromList Order
order sh
sh = Array (Triangular lo NonUnit up sh) a
-> Triangular lo NonUnit up sh a
forall shA a. Array shA a -> ArrayMatrix shA a
ArrMatrix.lift0 (Array (Triangular lo NonUnit up sh) a
 -> Triangular lo NonUnit up sh a)
-> ([a] -> Array (Triangular lo NonUnit up sh) a)
-> [a]
-> Triangular lo NonUnit up sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Order -> sh -> [a] -> Array (Triangular lo NonUnit up sh) a
forall lo up sh a.
(Content lo, Content up, C sh, Storable a) =>
Order -> sh -> [a] -> Triangular lo NonUnit up sh a
Basic.fromList Order
order sh
sh

lowerFromList :: (Shape.C sh, Storable a) => Order -> sh -> [a] -> Lower sh a
lowerFromList :: Order -> sh -> [a] -> Lower sh a
lowerFromList = Order -> sh -> [a] -> Lower sh a
forall lo up sh a.
(Content lo, Content up, C sh, Storable a) =>
Order -> sh -> [a] -> Triangular lo NonUnit up sh a
fromList

upperFromList :: (Shape.C sh, Storable a) => Order -> sh -> [a] -> Upper sh a
upperFromList :: Order -> sh -> [a] -> Upper sh a
upperFromList = Order -> sh -> [a] -> Upper sh a
forall lo up sh a.
(Content lo, Content up, C sh, Storable a) =>
Order -> sh -> [a] -> Triangular lo NonUnit up sh a
fromList

symmetricFromList ::
   (Shape.C sh, Storable a) => Order -> sh -> [a] -> Symmetric sh a
symmetricFromList :: Order -> sh -> [a] -> Symmetric sh a
symmetricFromList = Order -> sh -> [a] -> Symmetric sh a
forall lo up sh a.
(Content lo, Content up, C sh, Storable a) =>
Order -> sh -> [a] -> Triangular lo NonUnit up sh a
fromList

diagonalFromList ::
   (Shape.C sh, Storable a) => Order -> sh -> [a] -> Diagonal sh a
diagonalFromList :: Order -> sh -> [a] -> Diagonal sh a
diagonalFromList = Order -> sh -> [a] -> Diagonal sh a
forall lo up sh a.
(Content lo, Content up, C sh, Storable a) =>
Order -> sh -> [a] -> Triangular lo NonUnit up sh a
fromList


autoFromList ::
   (MatrixShape.Content lo, MatrixShape.Content up, Storable a) =>
   Order -> [a] -> Triangular lo NonUnit up ShapeInt a
autoFromList :: Order -> [a] -> Triangular lo NonUnit up ShapeInt a
autoFromList Order
order = Array (Triangular lo NonUnit up ShapeInt) a
-> Triangular lo NonUnit up ShapeInt a
forall shA a. Array shA a -> ArrayMatrix shA a
ArrMatrix.lift0 (Array (Triangular lo NonUnit up ShapeInt) a
 -> Triangular lo NonUnit up ShapeInt a)
-> ([a] -> Array (Triangular lo NonUnit up ShapeInt) a)
-> [a]
-> Triangular lo NonUnit up ShapeInt a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Order -> [a] -> Array (Triangular lo NonUnit up ShapeInt) a
forall lo up a.
(Content lo, Content up, Storable a) =>
Order -> [a] -> Triangular lo NonUnit up ShapeInt a
Basic.autoFromList Order
order

autoLowerFromList :: (Storable a) => Order -> [a] -> Lower ShapeInt a
autoLowerFromList :: Order -> [a] -> Lower ShapeInt a
autoLowerFromList = Order -> [a] -> Lower ShapeInt a
forall lo up a.
(Content lo, Content up, Storable a) =>
Order -> [a] -> Triangular lo NonUnit up ShapeInt a
autoFromList

autoUpperFromList :: (Storable a) => Order -> [a] -> Upper ShapeInt a
autoUpperFromList :: Order -> [a] -> Upper ShapeInt a
autoUpperFromList = Order -> [a] -> Upper ShapeInt a
forall lo up a.
(Content lo, Content up, Storable a) =>
Order -> [a] -> Triangular lo NonUnit up ShapeInt a
autoFromList

autoSymmetricFromList :: (Storable a) => Order -> [a] -> Symmetric ShapeInt a
autoSymmetricFromList :: Order -> [a] -> Symmetric ShapeInt a
autoSymmetricFromList = Order -> [a] -> Symmetric ShapeInt a
forall lo up a.
(Content lo, Content up, Storable a) =>
Order -> [a] -> Triangular lo NonUnit up ShapeInt a
autoFromList

autoDiagonalFromList :: (Storable a) => Order -> [a] -> Diagonal ShapeInt a
autoDiagonalFromList :: Order -> [a] -> Diagonal ShapeInt a
autoDiagonalFromList = Order -> [a] -> Diagonal ShapeInt a
forall lo up a.
(Content lo, Content up, Storable a) =>
Order -> [a] -> Triangular lo NonUnit up ShapeInt a
autoFromList


asDiagonal :: FlexDiagonal diag sh a -> FlexDiagonal diag sh a
asDiagonal :: FlexDiagonal diag sh a -> FlexDiagonal diag sh a
asDiagonal = FlexDiagonal diag sh a -> FlexDiagonal diag sh a
forall a. a -> a
id

asLower :: FlexLower diag sh a -> FlexLower diag sh a
asLower :: FlexLower diag sh a -> FlexLower diag sh a
asLower = FlexLower diag sh a -> FlexLower diag sh a
forall a. a -> a
id

asUpper :: FlexUpper diag sh a -> FlexUpper diag sh a
asUpper :: FlexUpper diag sh a -> FlexUpper diag sh a
asUpper = FlexUpper diag sh a -> FlexUpper diag sh a
forall a. a -> a
id

asSymmetric :: FlexSymmetric diag sh a -> FlexSymmetric diag sh a
asSymmetric :: FlexSymmetric diag sh a -> FlexSymmetric diag sh a
asSymmetric = FlexSymmetric diag sh a -> FlexSymmetric diag sh a
forall a. a -> a
id

requireUnitDiagonal :: Triangular lo Unit up sh a -> Triangular lo Unit up sh a
requireUnitDiagonal :: Triangular lo Unit up sh a -> Triangular lo Unit up sh a
requireUnitDiagonal = Triangular lo Unit up sh a -> Triangular lo Unit up sh a
forall a. a -> a
id

requireNonUnitDiagonal ::
   Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a
requireNonUnitDiagonal :: Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a
requireNonUnitDiagonal = Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a
forall a. a -> a
id


toSquare ::
   (MatrixShape.Content lo, MatrixShape.Content up,
    Shape.C sh, Class.Floating a) =>
   Triangular lo diag up sh a -> Square sh a
toSquare :: Triangular lo diag up sh a -> Square sh a
toSquare = (Array (Triangular lo diag up sh) a -> Array (Square sh) a)
-> Triangular lo diag up sh a -> Square sh a
forall shA a shB b.
(Array shA a -> Array shB b)
-> ArrayMatrix shA a -> ArrayMatrix shB b
ArrMatrix.lift1 Array (Triangular lo diag up sh) a -> Array (Square sh) a
forall lo up sh a diag.
(Content lo, Content up, C sh, Floating a) =>
Triangular lo diag up sh a -> Square sh a
Basic.toSquare

takeLower ::
   (Extent.C horiz, Shape.C height, Shape.C width, Class.Floating a) =>
   Full Extent.Small horiz height width a -> Lower height a
takeLower :: Full Small horiz height width a -> Lower height a
takeLower = (Array (Full Small horiz height width) a
 -> Array (LowerTriangular NonUnit height) a)
-> Full Small horiz height width a -> Lower height a
forall shA a shB b.
(Array shA a -> Array shB b)
-> ArrayMatrix shA a -> ArrayMatrix shB b
ArrMatrix.lift1 Array (Full Small horiz height width) a
-> Array (LowerTriangular NonUnit height) a
forall horiz height width a.
(C horiz, C height, C width, Floating a) =>
Full Small horiz height width a -> Lower height a
Basic.takeLower

takeUpper ::
   (Extent.C vert, Shape.C height, Shape.C width, Class.Floating a) =>
   Full vert Extent.Small height width a -> Upper width a
takeUpper :: Full vert Small height width a -> Upper width a
takeUpper = (Array (Full vert Small height width) a
 -> Array (UpperTriangular NonUnit width) a)
-> Full vert Small height width a -> Upper width a
forall shA a shB b.
(Array shA a -> Array shB b)
-> ArrayMatrix shA a -> ArrayMatrix shB b
ArrMatrix.lift1 Array (Full vert Small height width) a
-> Array (UpperTriangular NonUnit width) a
forall vert height width a.
(C vert, C height, C width, Floating a) =>
Full vert Small height width a -> Upper width a
Basic.takeUpper

fromLowerRowMajor ::
   (Shape.C sh, Class.Floating a) =>
   Array (Shape.Triangular Shape.Lower sh) a -> Lower sh a
fromLowerRowMajor :: Array (Triangular Lower sh) a -> Lower sh a
fromLowerRowMajor = Array (LowerTriangular NonUnit sh) a -> Lower sh a
forall shA a. Array shA a -> ArrayMatrix shA a
ArrMatrix.lift0 (Array (LowerTriangular NonUnit sh) a -> Lower sh a)
-> (Array (Triangular Lower sh) a
    -> Array (LowerTriangular NonUnit sh) a)
-> Array (Triangular Lower sh) a
-> Lower sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array (Triangular Lower sh) a
-> Array (LowerTriangular NonUnit sh) a
forall sh a.
(C sh, Floating a) =>
Array (Triangular Lower sh) a -> Lower sh a
Basic.fromLowerRowMajor

fromUpperRowMajor ::
   (Shape.C sh, Class.Floating a) =>
   Array (Shape.Triangular Shape.Upper sh) a -> Upper sh a
fromUpperRowMajor :: Array (Triangular Upper sh) a -> Upper sh a
fromUpperRowMajor = Array (UpperTriangular NonUnit sh) a -> Upper sh a
forall shA a. Array shA a -> ArrayMatrix shA a
ArrMatrix.lift0 (Array (UpperTriangular NonUnit sh) a -> Upper sh a)
-> (Array (Triangular Upper sh) a
    -> Array (UpperTriangular NonUnit sh) a)
-> Array (Triangular Upper sh) a
-> Upper sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array (Triangular Upper sh) a
-> Array (UpperTriangular NonUnit sh) a
forall sh a.
(C sh, Floating a) =>
Array (Triangular Upper sh) a -> Upper sh a
Basic.fromUpperRowMajor

toLowerRowMajor ::
   (Shape.C sh, Class.Floating a) =>
   Lower sh a -> Array (Shape.Triangular Shape.Lower sh) a
toLowerRowMajor :: Lower sh a -> Array (Triangular Lower sh) a
toLowerRowMajor = Lower sh a -> Array (Triangular Lower sh) a
forall sh a.
(C sh, Floating a) =>
Lower sh a -> Array (Triangular Lower sh) a
Basic.toLowerRowMajor (Lower sh a -> Array (Triangular Lower sh) a)
-> (Lower sh a -> Lower sh a)
-> Lower sh a
-> Array (Triangular Lower sh) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lower sh a -> Lower sh a
forall sh a. ArrayMatrix sh a -> Array sh a
ArrMatrix.toVector

toUpperRowMajor ::
   (Shape.C sh, Class.Floating a) =>
   Upper sh a -> Array (Shape.Triangular Shape.Upper sh) a
toUpperRowMajor :: Upper sh a -> Array (Triangular Upper sh) a
toUpperRowMajor = Upper sh a -> Array (Triangular Upper sh) a
forall sh a.
(C sh, Floating a) =>
Upper sh a -> Array (Triangular Upper sh) a
Basic.toUpperRowMajor (Upper sh a -> Array (Triangular Upper sh) a)
-> (Upper sh a -> Upper sh a)
-> Upper sh a
-> Array (Triangular Upper sh) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Upper sh a -> Upper sh a
forall sh a. ArrayMatrix sh a -> Array sh a
ArrMatrix.toVector

forceOrder ::
   (MatrixShape.Content lo, MatrixShape.Content up, MatrixShape.TriDiag diag,
    Shape.C sh, Class.Floating a) =>
   Order -> Triangular lo diag up sh a -> Triangular lo diag up sh a
forceOrder :: Order -> Triangular lo diag up sh a -> Triangular lo diag up sh a
forceOrder = (Array (Triangular lo diag up sh) a
 -> Array (Triangular lo diag up sh) a)
-> Triangular lo diag up sh a -> Triangular lo diag up sh a
forall shA a shB b.
(Array shA a -> Array shB b)
-> ArrayMatrix shA a -> ArrayMatrix shB b
ArrMatrix.lift1 ((Array (Triangular lo diag up sh) a
  -> Array (Triangular lo diag up sh) a)
 -> Triangular lo diag up sh a -> Triangular lo diag up sh a)
-> (Order
    -> Array (Triangular lo diag up sh) a
    -> Array (Triangular lo diag up sh) a)
-> Order
-> Triangular lo diag up sh a
-> Triangular lo diag up sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Order
-> Array (Triangular lo diag up sh) a
-> Array (Triangular lo diag up sh) a
forall lo up diag sh a.
(Content lo, Content up, TriDiag diag, C sh, Floating a) =>
Order -> Triangular lo diag up sh a -> Triangular lo diag up sh a
Basic.forceOrder

{- |
@adaptOrder x y@ contains the data of @y@ with the layout of @x@.
-}
adaptOrder ::
   (MatrixShape.Content lo, MatrixShape.Content up, MatrixShape.TriDiag diag,
    Shape.C sh, Class.Floating a) =>
   Triangular lo diag up sh a ->
   Triangular lo diag up sh a ->
   Triangular lo diag up sh a
adaptOrder :: Triangular lo diag up sh a
-> Triangular lo diag up sh a -> Triangular lo diag up sh a
adaptOrder = (Array (Triangular lo diag up sh) a
 -> Array (Triangular lo diag up sh) a
 -> Array (Triangular lo diag up sh) a)
-> Triangular lo diag up sh a
-> Triangular lo diag up sh a
-> Triangular lo diag up sh a
forall shA a shB b shC c.
(Array shA a -> Array shB b -> Array shC c)
-> ArrayMatrix shA a -> ArrayMatrix shB b -> ArrayMatrix shC c
ArrMatrix.lift2 Array (Triangular lo diag up sh) a
-> Array (Triangular lo diag up sh) a
-> Array (Triangular lo diag up sh) a
forall lo up diag sh a.
(Content lo, Content up, TriDiag diag, C sh, Floating a) =>
Triangular lo diag up sh a
-> Triangular lo diag up sh a -> Triangular lo diag up sh a
Basic.adaptOrder

add, sub ::
   (MatrixShape.Content lo, MatrixShape.Content up,
    Eq lo, Eq up, Eq sh, Shape.C sh, Class.Floating a) =>
   Triangular lo NonUnit up sh a ->
   Triangular lo NonUnit up sh a ->
   Triangular lo NonUnit up sh a
add :: Triangular lo NonUnit up sh a
-> Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a
add = (Array (Triangular lo NonUnit up sh) a
 -> Array (Triangular lo NonUnit up sh) a
 -> Array (Triangular lo NonUnit up sh) a)
-> Triangular lo NonUnit up sh a
-> Triangular lo NonUnit up sh a
-> Triangular lo NonUnit up sh a
forall shA a shB b shC c.
(Array shA a -> Array shB b -> Array shC c)
-> ArrayMatrix shA a -> ArrayMatrix shB b -> ArrayMatrix shC c
ArrMatrix.lift2 Array (Triangular lo NonUnit up sh) a
-> Array (Triangular lo NonUnit up sh) a
-> Array (Triangular lo NonUnit up sh) a
forall lo up sh a.
(Content lo, Content up, Eq lo, Eq up, Eq sh, C sh, Floating a) =>
Triangular lo NonUnit up sh a
-> Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a
Basic.add
sub :: Triangular lo NonUnit up sh a
-> Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a
sub = (Array (Triangular lo NonUnit up sh) a
 -> Array (Triangular lo NonUnit up sh) a
 -> Array (Triangular lo NonUnit up sh) a)
-> Triangular lo NonUnit up sh a
-> Triangular lo NonUnit up sh a
-> Triangular lo NonUnit up sh a
forall shA a shB b shC c.
(Array shA a -> Array shB b -> Array shC c)
-> ArrayMatrix shA a -> ArrayMatrix shB b -> ArrayMatrix shC c
ArrMatrix.lift2 Array (Triangular lo NonUnit up sh) a
-> Array (Triangular lo NonUnit up sh) a
-> Array (Triangular lo NonUnit up sh) a
forall lo up sh a.
(Content lo, Content up, Eq lo, Eq up, Eq sh, C sh, Floating a) =>
Triangular lo NonUnit up sh a
-> Triangular lo NonUnit up sh a -> Triangular lo NonUnit up sh a
Basic.sub


identity ::
   (MatrixShape.Content lo, MatrixShape.Content up,
    Shape.C sh, Class.Floating a) =>
   Order -> sh -> Triangular lo Unit up sh a
identity :: Order -> sh -> Triangular lo Unit up sh a
identity Order
order = Array (Triangular lo Unit up sh) a -> Triangular lo Unit up sh a
forall shA a. Array shA a -> ArrayMatrix shA a
ArrMatrix.lift0 (Array (Triangular lo Unit up sh) a -> Triangular lo Unit up sh a)
-> (sh -> Array (Triangular lo Unit up sh) a)
-> sh
-> Triangular lo Unit up sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Order -> sh -> Array (Triangular lo Unit up sh) a
forall lo up sh a.
(Content lo, Content up, C sh, Floating a) =>
Order -> sh -> Triangular lo Unit up sh a
Basic.identity Order
order

diagonal ::
   (MatrixShape.Content lo, MatrixShape.Content up,
    Shape.C sh, Class.Floating a) =>
   Order -> Vector sh a -> Triangular lo NonUnit up sh a
diagonal :: Order -> Vector sh a -> Triangular lo NonUnit up sh a
diagonal Order
order = Array (Triangular lo NonUnit up sh) a
-> Triangular lo NonUnit up sh a
forall shA a. Array shA a -> ArrayMatrix shA a
ArrMatrix.lift0 (Array (Triangular lo NonUnit up sh) a
 -> Triangular lo NonUnit up sh a)
-> (Vector sh a -> Array (Triangular lo NonUnit up sh) a)
-> Vector sh a
-> Triangular lo NonUnit up sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Order -> Vector sh a -> Array (Triangular lo NonUnit up sh) a
forall lo up sh a.
(Content lo, Content up, C sh, Floating a) =>
Order -> Vector sh a -> Triangular lo NonUnit up sh a
Basic.diagonal Order
order

takeDiagonal ::
   (MatrixShape.Content lo, MatrixShape.Content up,
    Shape.C sh, Class.Floating a) =>
   Triangular lo diag up sh a -> Vector sh a
takeDiagonal :: Triangular lo diag up sh a -> Vector sh a
takeDiagonal = Triangular lo diag up sh a -> Vector sh a
forall lo up sh a diag.
(Content lo, Content up, C sh, Floating a) =>
Triangular lo diag up sh a -> Vector sh a
Basic.takeDiagonal (Triangular lo diag up sh a -> Vector sh a)
-> (Triangular lo diag up sh a -> Triangular lo diag up sh a)
-> Triangular lo diag up sh a
-> Vector sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Triangular lo diag up sh a -> Triangular lo diag up sh a
forall sh a. ArrayMatrix sh a -> Array sh a
ArrMatrix.toVector

relaxUnitDiagonal ::
   (MatrixShape.TriDiag diag) =>
   Triangular lo Unit up sh a -> Triangular lo diag up sh a
relaxUnitDiagonal :: Triangular lo Unit up sh a -> Triangular lo diag up sh a
relaxUnitDiagonal = (Array (Triangular lo Unit up sh) a
 -> Array (Triangular lo diag up sh) a)
-> Triangular lo Unit up sh a -> Triangular lo diag up sh a
forall shA a shB b.
(Array shA a -> Array shB b)
-> ArrayMatrix shA a -> ArrayMatrix shB b
ArrMatrix.lift1 Array (Triangular lo Unit up sh) a
-> Array (Triangular lo diag up sh) a
forall diag lo up sh a.
TriDiag diag =>
Triangular lo Unit up sh a -> Triangular lo diag up sh a
Basic.relaxUnitDiagonal

strictNonUnitDiagonal ::
   (MatrixShape.TriDiag diag) =>
   Triangular lo diag up sh a -> Triangular lo NonUnit up sh a
strictNonUnitDiagonal :: Triangular lo diag up sh a -> Triangular lo NonUnit up sh a
strictNonUnitDiagonal = (Array (Triangular lo diag up sh) a
 -> Array (Triangular lo NonUnit up sh) a)
-> Triangular lo diag up sh a -> Triangular lo NonUnit up sh a
forall shA a shB b.
(Array shA a -> Array shB b)
-> ArrayMatrix shA a -> ArrayMatrix shB b
ArrMatrix.lift1 Array (Triangular lo diag up sh) a
-> Array (Triangular lo NonUnit up sh) a
forall diag lo up sh a.
TriDiag diag =>
Triangular lo diag up sh a -> Triangular lo NonUnit up sh a
Basic.strictNonUnitDiagonal


infixr 2 %%%, %%%#, #%%%#
infixl 2 #%%%

stackDiagonal, (%%%) ::
   (MatrixShape.TriDiag diag, Shape.C sh0, Shape.C sh1, Class.Floating a) =>
   FlexDiagonal diag sh0 a ->
   FlexDiagonal diag sh1 a ->
   FlexDiagonal diag (sh0:+:sh1) a
stackDiagonal :: FlexDiagonal diag sh0 a
-> FlexDiagonal diag sh1 a -> FlexDiagonal diag (sh0 :+: sh1) a
stackDiagonal = (Array (Triangular Empty diag Empty sh0) a
 -> Array (Triangular Empty diag Empty sh1) a
 -> Array (Triangular Empty diag Empty (sh0 :+: sh1)) a)
-> FlexDiagonal diag sh0 a
-> FlexDiagonal diag sh1 a
-> FlexDiagonal diag (sh0 :+: sh1) a
forall shA a shB b shC c.
(Array shA a -> Array shB b -> Array shC c)
-> ArrayMatrix shA a -> ArrayMatrix shB b -> ArrayMatrix shC c
ArrMatrix.lift2 Array (Triangular Empty diag Empty sh0) a
-> Array (Triangular Empty diag Empty sh1) a
-> Array (Triangular Empty diag Empty (sh0 :+: sh1)) a
forall diag sh0 sh1 a.
(TriDiag diag, C sh0, C sh1, Floating a) =>
FlexDiagonal diag sh0 a
-> FlexDiagonal diag sh1 a -> FlexDiagonal diag (sh0 :+: sh1) a
Basic.stackDiagonal
%%% :: FlexDiagonal diag sh0 a
-> FlexDiagonal diag sh1 a -> FlexDiagonal diag (sh0 :+: sh1) a
(%%%) = FlexDiagonal diag sh0 a
-> FlexDiagonal diag sh1 a -> FlexDiagonal diag (sh0 :+: sh1) a
forall diag sh0 sh1 a.
(TriDiag diag, C sh0, C sh1, Floating a) =>
FlexDiagonal diag sh0 a
-> FlexDiagonal diag sh1 a -> FlexDiagonal diag (sh0 :+: sh1) a
stackDiagonal

stackLower ::
   (MatrixShape.TriDiag diag,
    Shape.C sh0, Eq sh0, Shape.C sh1, Eq sh1, Class.Floating a) =>
   FlexLower diag sh0 a ->
   General sh1 sh0 a ->
   FlexLower diag sh1 a ->
   FlexLower diag (sh0:+:sh1) a
stackLower :: FlexLower diag sh0 a
-> General sh1 sh0 a
-> FlexLower diag sh1 a
-> FlexLower diag (sh0 :+: sh1) a
stackLower = (Array (LowerTriangular diag sh0) a
 -> Array (General sh1 sh0) a
 -> Array (LowerTriangular diag sh1) a
 -> Array (LowerTriangular diag (sh0 :+: sh1)) a)
-> FlexLower diag sh0 a
-> General sh1 sh0 a
-> FlexLower diag sh1 a
-> FlexLower diag (sh0 :+: sh1) a
forall shA a shB b shC c shD d.
(Array shA a -> Array shB b -> Array shC c -> Array shD d)
-> ArrayMatrix shA a
-> ArrayMatrix shB b
-> ArrayMatrix shC c
-> ArrayMatrix shD d
ArrMatrix.lift3 Array (LowerTriangular diag sh0) a
-> Array (General sh1 sh0) a
-> Array (LowerTriangular diag sh1) a
-> Array (LowerTriangular diag (sh0 :+: sh1)) a
forall diag sh0 sh1 a.
(TriDiag diag, C sh0, Eq sh0, C sh1, Eq sh1, Floating a) =>
FlexLower diag sh0 a
-> General sh1 sh0 a
-> FlexLower diag sh1 a
-> FlexLower diag (sh0 :+: sh1) a
Basic.stackLower

(#%%%) ::
   (MatrixShape.TriDiag diag,
    Shape.C sh0, Eq sh0, Shape.C sh1, Eq sh1, Class.Floating a) =>
   FlexLower diag sh0 a ->
   (General sh1 sh0 a, FlexLower diag sh1 a) ->
   FlexLower diag (sh0:+:sh1) a
#%%% :: FlexLower diag sh0 a
-> (General sh1 sh0 a, FlexLower diag sh1 a)
-> FlexLower diag (sh0 :+: sh1) a
(#%%%) = (General sh1 sh0 a
 -> FlexLower diag sh1 a -> FlexLower diag (sh0 :+: sh1) a)
-> (General sh1 sh0 a, FlexLower diag sh1 a)
-> FlexLower diag (sh0 :+: sh1) a
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry ((General sh1 sh0 a
  -> FlexLower diag sh1 a -> FlexLower diag (sh0 :+: sh1) a)
 -> (General sh1 sh0 a, FlexLower diag sh1 a)
 -> FlexLower diag (sh0 :+: sh1) a)
-> (FlexLower diag sh0 a
    -> General sh1 sh0 a
    -> FlexLower diag sh1 a
    -> FlexLower diag (sh0 :+: sh1) a)
-> FlexLower diag sh0 a
-> (General sh1 sh0 a, FlexLower diag sh1 a)
-> FlexLower diag (sh0 :+: sh1) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FlexLower diag sh0 a
-> General sh1 sh0 a
-> FlexLower diag sh1 a
-> FlexLower diag (sh0 :+: sh1) a
forall diag sh0 sh1 a.
(TriDiag diag, C sh0, Eq sh0, C sh1, Eq sh1, Floating a) =>
FlexLower diag sh0 a
-> General sh1 sh0 a
-> FlexLower diag sh1 a
-> FlexLower diag (sh0 :+: sh1) a
stackLower

stackUpper ::
   (MatrixShape.TriDiag diag,
    Shape.C sh0, Eq sh0, Shape.C sh1, Eq sh1, Class.Floating a) =>
   FlexUpper diag sh0 a ->
   General sh0 sh1 a ->
   FlexUpper diag sh1 a ->
   FlexUpper diag (sh0:+:sh1) a
stackUpper :: FlexUpper diag sh0 a
-> General sh0 sh1 a
-> FlexUpper diag sh1 a
-> FlexUpper diag (sh0 :+: sh1) a
stackUpper = (Array (UpperTriangular diag sh0) a
 -> Array (General sh0 sh1) a
 -> Array (UpperTriangular diag sh1) a
 -> Array (UpperTriangular diag (sh0 :+: sh1)) a)
-> FlexUpper diag sh0 a
-> General sh0 sh1 a
-> FlexUpper diag sh1 a
-> FlexUpper diag (sh0 :+: sh1) a
forall shA a shB b shC c shD d.
(Array shA a -> Array shB b -> Array shC c -> Array shD d)
-> ArrayMatrix shA a
-> ArrayMatrix shB b
-> ArrayMatrix shC c
-> ArrayMatrix shD d
ArrMatrix.lift3 Array (UpperTriangular diag sh0) a
-> Array (General sh0 sh1) a
-> Array (UpperTriangular diag sh1) a
-> Array (UpperTriangular diag (sh0 :+: sh1)) a
forall diag sh0 sh1 a.
(TriDiag diag, C sh0, Eq sh0, C sh1, Eq sh1, Floating a) =>
FlexUpper diag sh0 a
-> General sh0 sh1 a
-> FlexUpper diag sh1 a
-> FlexUpper diag (sh0 :+: sh1) a
Basic.stackUpper

(%%%#) ::
   (MatrixShape.TriDiag diag,
    Shape.C sh0, Eq sh0, Shape.C sh1, Eq sh1, Class.Floating a) =>
   (FlexUpper diag sh0 a, General sh0 sh1 a) ->
   FlexUpper diag sh1 a ->
   FlexUpper diag (sh0:+:sh1) a
%%%# :: (FlexUpper diag sh0 a, General sh0 sh1 a)
-> FlexUpper diag sh1 a -> FlexUpper diag (sh0 :+: sh1) a
(%%%#) = (FlexUpper diag sh0 a
 -> General sh0 sh1 a
 -> FlexUpper diag sh1 a
 -> FlexUpper diag (sh0 :+: sh1) a)
-> (FlexUpper diag sh0 a, General sh0 sh1 a)
-> FlexUpper diag sh1 a
-> FlexUpper diag (sh0 :+: sh1) a
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry FlexUpper diag sh0 a
-> General sh0 sh1 a
-> FlexUpper diag sh1 a
-> FlexUpper diag (sh0 :+: sh1) a
forall diag sh0 sh1 a.
(TriDiag diag, C sh0, Eq sh0, C sh1, Eq sh1, Floating a) =>
FlexUpper diag sh0 a
-> General sh0 sh1 a
-> FlexUpper diag sh1 a
-> FlexUpper diag (sh0 :+: sh1) a
stackUpper

stackSymmetric ::
   (MatrixShape.TriDiag diag,
    Shape.C sh0, Eq sh0, Shape.C sh1, Eq sh1, Class.Floating a) =>
   FlexSymmetric diag sh0 a ->
   General sh0 sh1 a ->
   FlexSymmetric diag sh1 a ->
   FlexSymmetric diag (sh0:+:sh1) a
stackSymmetric :: FlexSymmetric diag sh0 a
-> General sh0 sh1 a
-> FlexSymmetric diag sh1 a
-> FlexSymmetric diag (sh0 :+: sh1) a
stackSymmetric = (Array (FlexSymmetric diag sh0) a
 -> Array (General sh0 sh1) a
 -> Array (FlexSymmetric diag sh1) a
 -> Array (FlexSymmetric diag (sh0 :+: sh1)) a)
-> FlexSymmetric diag sh0 a
-> General sh0 sh1 a
-> FlexSymmetric diag sh1 a
-> FlexSymmetric diag (sh0 :+: sh1) a
forall shA a shB b shC c shD d.
(Array shA a -> Array shB b -> Array shC c -> Array shD d)
-> ArrayMatrix shA a
-> ArrayMatrix shB b
-> ArrayMatrix shC c
-> ArrayMatrix shD d
ArrMatrix.lift3 Array (FlexSymmetric diag sh0) a
-> Array (General sh0 sh1) a
-> Array (FlexSymmetric diag sh1) a
-> Array (FlexSymmetric diag (sh0 :+: sh1)) a
forall diag sh0 sh1 a.
(TriDiag diag, C sh0, Eq sh0, C sh1, Eq sh1, Floating a) =>
FlexSymmetric diag sh0 a
-> General sh0 sh1 a
-> FlexSymmetric diag sh1 a
-> FlexSymmetric diag (sh0 :+: sh1) a
Basic.stackSymmetric

(#%%%#) ::
   (MatrixShape.TriDiag diag,
    Shape.C sh0, Eq sh0, Shape.C sh1, Eq sh1, Class.Floating a) =>
   (FlexSymmetric diag sh0 a, General sh0 sh1 a) ->
   FlexSymmetric diag sh1 a ->
   FlexSymmetric diag (sh0:+:sh1) a
#%%%# :: (FlexSymmetric diag sh0 a, General sh0 sh1 a)
-> FlexSymmetric diag sh1 a -> FlexSymmetric diag (sh0 :+: sh1) a
(#%%%#) = (FlexSymmetric diag sh0 a
 -> General sh0 sh1 a
 -> FlexSymmetric diag sh1 a
 -> FlexSymmetric diag (sh0 :+: sh1) a)
-> (FlexSymmetric diag sh0 a, General sh0 sh1 a)
-> FlexSymmetric diag sh1 a
-> FlexSymmetric diag (sh0 :+: sh1) a
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry FlexSymmetric diag sh0 a
-> General sh0 sh1 a
-> FlexSymmetric diag sh1 a
-> FlexSymmetric diag (sh0 :+: sh1) a
forall diag sh0 sh1 a.
(TriDiag diag, C sh0, Eq sh0, C sh1, Eq sh1, Floating a) =>
FlexSymmetric diag sh0 a
-> General sh0 sh1 a
-> FlexSymmetric diag sh1 a
-> FlexSymmetric diag (sh0 :+: sh1) a
stackSymmetric


splitDiagonal ::
   (MatrixShape.TriDiag diag, Shape.C sh0, Shape.C sh1, Class.Floating a) =>
   FlexDiagonal diag (sh0:+:sh1) a ->
   (FlexDiagonal diag sh0 a, FlexDiagonal diag sh1 a)
splitDiagonal :: FlexDiagonal diag (sh0 :+: sh1) a
-> (FlexDiagonal diag sh0 a, FlexDiagonal diag sh1 a)
splitDiagonal FlexDiagonal diag (sh0 :+: sh1) a
a = (FlexDiagonal diag (sh0 :+: sh1) a -> FlexDiagonal diag sh0 a
forall lo diag up sh0 sh1 a.
(Content lo, TriDiag diag, Content up, C sh0, C sh1, Floating a) =>
Triangular lo diag up (sh0 :+: sh1) a
-> Triangular lo diag up sh0 a
takeTopLeft FlexDiagonal diag (sh0 :+: sh1) a
a, FlexDiagonal diag (sh0 :+: sh1) a -> FlexDiagonal diag sh1 a
forall lo diag up sh0 sh1 a.
(Content lo, TriDiag diag, Content up, C sh0, C sh1, Floating a) =>
Triangular lo diag up (sh0 :+: sh1) a
-> Triangular lo diag up sh1 a
takeBottomRight FlexDiagonal diag (sh0 :+: sh1) a
a)

splitLower ::
   (MatrixShape.TriDiag diag,
    Shape.C sh0, Eq sh0, Shape.C sh1, Eq sh1, Class.Floating a) =>
   FlexLower diag (sh0:+:sh1) a ->
   (FlexLower diag sh0 a, General sh1 sh0 a, FlexLower diag sh1 a)
splitLower :: FlexLower diag (sh0 :+: sh1) a
-> (FlexLower diag sh0 a, General sh1 sh0 a, FlexLower diag sh1 a)
splitLower FlexLower diag (sh0 :+: sh1) a
a = (FlexLower diag (sh0 :+: sh1) a -> FlexLower diag sh0 a
forall lo diag up sh0 sh1 a.
(Content lo, TriDiag diag, Content up, C sh0, C sh1, Floating a) =>
Triangular lo diag up (sh0 :+: sh1) a
-> Triangular lo diag up sh0 a
takeTopLeft FlexLower diag (sh0 :+: sh1) a
a, FlexLower diag (sh0 :+: sh1) a -> General sh1 sh0 a
forall diag up sh0 sh1 a.
(TriDiag diag, Content up, C sh0, C sh1, Floating a) =>
Triangular Filled diag up (sh0 :+: sh1) a -> General sh1 sh0 a
takeBottomLeft FlexLower diag (sh0 :+: sh1) a
a, FlexLower diag (sh0 :+: sh1) a -> FlexLower diag sh1 a
forall lo diag up sh0 sh1 a.
(Content lo, TriDiag diag, Content up, C sh0, C sh1, Floating a) =>
Triangular lo diag up (sh0 :+: sh1) a
-> Triangular lo diag up sh1 a
takeBottomRight FlexLower diag (sh0 :+: sh1) a
a)

splitUpper ::
   (MatrixShape.TriDiag diag,
    Shape.C sh0, Eq sh0, Shape.C sh1, Eq sh1, Class.Floating a) =>
   FlexUpper diag (sh0:+:sh1) a ->
   (FlexUpper diag sh0 a, General sh0 sh1 a, FlexUpper diag sh1 a)
splitUpper :: FlexUpper diag (sh0 :+: sh1) a
-> (FlexUpper diag sh0 a, General sh0 sh1 a, FlexUpper diag sh1 a)
splitUpper FlexUpper diag (sh0 :+: sh1) a
a = (FlexUpper diag (sh0 :+: sh1) a -> FlexUpper diag sh0 a
forall lo diag up sh0 sh1 a.
(Content lo, TriDiag diag, Content up, C sh0, C sh1, Floating a) =>
Triangular lo diag up (sh0 :+: sh1) a
-> Triangular lo diag up sh0 a
takeTopLeft FlexUpper diag (sh0 :+: sh1) a
a, FlexUpper diag (sh0 :+: sh1) a -> General sh0 sh1 a
forall lo diag sh0 sh1 a.
(Content lo, TriDiag diag, C sh0, C sh1, Floating a) =>
Triangular lo diag Filled (sh0 :+: sh1) a -> General sh0 sh1 a
takeTopRight FlexUpper diag (sh0 :+: sh1) a
a, FlexUpper diag (sh0 :+: sh1) a -> FlexUpper diag sh1 a
forall lo diag up sh0 sh1 a.
(Content lo, TriDiag diag, Content up, C sh0, C sh1, Floating a) =>
Triangular lo diag up (sh0 :+: sh1) a
-> Triangular lo diag up sh1 a
takeBottomRight FlexUpper diag (sh0 :+: sh1) a
a)

splitSymmetric ::
   (MatrixShape.TriDiag diag,
    Shape.C sh0, Eq sh0, Shape.C sh1, Eq sh1, Class.Floating a) =>
   FlexSymmetric diag (sh0:+:sh1) a ->
   (FlexSymmetric diag sh0 a, General sh0 sh1 a, FlexSymmetric diag sh1 a)
splitSymmetric :: FlexSymmetric diag (sh0 :+: sh1) a
-> (FlexSymmetric diag sh0 a, General sh0 sh1 a,
    FlexSymmetric diag sh1 a)
splitSymmetric FlexSymmetric diag (sh0 :+: sh1) a
a = (FlexSymmetric diag (sh0 :+: sh1) a -> FlexSymmetric diag sh0 a
forall lo diag up sh0 sh1 a.
(Content lo, TriDiag diag, Content up, C sh0, C sh1, Floating a) =>
Triangular lo diag up (sh0 :+: sh1) a
-> Triangular lo diag up sh0 a
takeTopLeft FlexSymmetric diag (sh0 :+: sh1) a
a, FlexSymmetric diag (sh0 :+: sh1) a -> General sh0 sh1 a
forall lo diag sh0 sh1 a.
(Content lo, TriDiag diag, C sh0, C sh1, Floating a) =>
Triangular lo diag Filled (sh0 :+: sh1) a -> General sh0 sh1 a
takeTopRight FlexSymmetric diag (sh0 :+: sh1) a
a, FlexSymmetric diag (sh0 :+: sh1) a -> FlexSymmetric diag sh1 a
forall lo diag up sh0 sh1 a.
(Content lo, TriDiag diag, Content up, C sh0, C sh1, Floating a) =>
Triangular lo diag up (sh0 :+: sh1) a
-> Triangular lo diag up sh1 a
takeBottomRight FlexSymmetric diag (sh0 :+: sh1) a
a)


takeTopLeft ::
   (MatrixShape.Content lo, MatrixShape.TriDiag diag, MatrixShape.Content up,
    Shape.C sh0, Shape.C sh1, Class.Floating a) =>
   Triangular lo diag up (sh0:+:sh1) a ->
   Triangular lo diag up sh0 a
takeTopLeft :: Triangular lo diag up (sh0 :+: sh1) a
-> Triangular lo diag up sh0 a
takeTopLeft = (Array (Triangular lo diag up (sh0 :+: sh1)) a
 -> Array (Triangular lo diag up sh0) a)
-> Triangular lo diag up (sh0 :+: sh1) a
-> Triangular lo diag up sh0 a
forall shA a shB b.
(Array shA a -> Array shB b)
-> ArrayMatrix shA a -> ArrayMatrix shB b
ArrMatrix.lift1 Array (Triangular lo diag up (sh0 :+: sh1)) a
-> Array (Triangular lo diag up sh0) a
forall lo diag up sh0 sh1 a.
(Content lo, TriDiag diag, Content up, C sh0, C sh1, Floating a) =>
Triangular lo diag up (sh0 :+: sh1) a
-> Triangular lo diag up sh0 a
Basic.takeTopLeft

takeBottomLeft ::
   (MatrixShape.TriDiag diag, MatrixShape.Content up,
    Shape.C sh0, Shape.C sh1, Class.Floating a) =>
   Triangular MatrixShape.Filled diag up (sh0:+:sh1) a ->
   General sh1 sh0 a
takeBottomLeft :: Triangular Filled diag up (sh0 :+: sh1) a -> General sh1 sh0 a
takeBottomLeft = (Array (Triangular Filled diag up (sh0 :+: sh1)) a
 -> Array (General sh1 sh0) a)
-> Triangular Filled diag up (sh0 :+: sh1) a -> General sh1 sh0 a
forall shA a shB b.
(Array shA a -> Array shB b)
-> ArrayMatrix shA a -> ArrayMatrix shB b
ArrMatrix.lift1 Array (Triangular Filled diag up (sh0 :+: sh1)) a
-> Array (General sh1 sh0) a
forall diag up sh0 sh1 a.
(TriDiag diag, Content up, C sh0, C sh1, Floating a) =>
Triangular Filled diag up (sh0 :+: sh1) a -> General sh1 sh0 a
Basic.takeBottomLeft

takeTopRight ::
   (MatrixShape.Content lo, MatrixShape.TriDiag diag,
    Shape.C sh0, Shape.C sh1, Class.Floating a) =>
   Triangular lo diag MatrixShape.Filled (sh0:+:sh1) a ->
   General sh0 sh1 a
takeTopRight :: Triangular lo diag Filled (sh0 :+: sh1) a -> General sh0 sh1 a
takeTopRight = (Array (Triangular lo diag Filled (sh0 :+: sh1)) a
 -> Array (General sh0 sh1) a)
-> Triangular lo diag Filled (sh0 :+: sh1) a -> General sh0 sh1 a
forall shA a shB b.
(Array shA a -> Array shB b)
-> ArrayMatrix shA a -> ArrayMatrix shB b
ArrMatrix.lift1 Array (Triangular lo diag Filled (sh0 :+: sh1)) a
-> Array (General sh0 sh1) a
forall lo diag sh0 sh1 a.
(Content lo, TriDiag diag, C sh0, C sh1, Floating a) =>
Triangular lo diag Filled (sh0 :+: sh1) a -> General sh0 sh1 a
Basic.takeTopRight

takeBottomRight ::
   (MatrixShape.Content lo, MatrixShape.TriDiag diag, MatrixShape.Content up,
    Shape.C sh0, Shape.C sh1, Class.Floating a) =>
   Triangular lo diag up (sh0:+:sh1) a ->
   Triangular lo diag up sh1 a
takeBottomRight :: Triangular lo diag up (sh0 :+: sh1) a
-> Triangular lo diag up sh1 a
takeBottomRight = (Array (Triangular lo diag up (sh0 :+: sh1)) a
 -> Array (Triangular lo diag up sh1) a)
-> Triangular lo diag up (sh0 :+: sh1) a
-> Triangular lo diag up sh1 a
forall shA a shB b.
(Array shA a -> Array shB b)
-> ArrayMatrix shA a -> ArrayMatrix shB b
ArrMatrix.lift1 Array (Triangular lo diag up (sh0 :+: sh1)) a
-> Array (Triangular lo diag up sh1) a
forall lo diag up sh0 sh1 a.
(Content lo, TriDiag diag, Content up, C sh0, C sh1, Floating a) =>
Triangular lo diag up (sh0 :+: sh1) a
-> Triangular lo diag up sh1 a
Basic.takeBottomRight


multiplyVector ::
   (MatrixShape.Content lo, MatrixShape.Content up, MatrixShape.TriDiag diag,
    Shape.C sh, Eq sh, Class.Floating a) =>
   Triangular lo diag up sh a -> Vector sh a -> Vector sh a
multiplyVector :: Triangular lo diag up sh a -> Vector sh a -> Vector sh a
multiplyVector = Triangular lo diag up sh a -> Vector sh a -> Vector sh a
forall lo up diag sh a.
(Content lo, Content up, TriDiag diag, C sh, Eq sh, Floating a) =>
Triangular lo diag up sh a -> Vector sh a -> Vector sh a
Basic.multiplyVector (Triangular lo diag up sh a -> Vector sh a -> Vector sh a)
-> (Triangular lo diag up sh a -> Triangular lo diag up sh a)
-> Triangular lo diag up sh a
-> Vector sh a
-> Vector sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Triangular lo diag up sh a -> Triangular lo diag up sh a
forall sh a. ArrayMatrix sh a -> Array sh a
ArrMatrix.toVector

{- |
Include symmetric matrices.
However, symmetric matrices do not preserve unit diagonals.
-}
square ::
   (MatrixShape.Content lo, MatrixShape.Content up, MatrixShape.TriDiag diag,
    Shape.C sh, Eq sh, Class.Floating a) =>
   Triangular lo diag up sh a ->
   Triangular lo (Tri.PowerDiag lo up diag) up sh a
square :: Triangular lo diag up sh a
-> Triangular lo (PowerDiag lo up diag) up sh a
square = (Array (Triangular lo diag up sh) a
 -> Array (Triangular lo (PowerDiag lo up diag) up sh) a)
-> Triangular lo diag up sh a
-> Triangular lo (PowerDiag lo up diag) up sh a
forall shA a shB b.
(Array shA a -> Array shB b)
-> ArrayMatrix shA a -> ArrayMatrix shB b
ArrMatrix.lift1 Array (Triangular lo diag up sh) a
-> Array (Triangular lo (PowerDiag lo up diag) up sh) a
forall lo up diag sh a.
(Content lo, Content up, TriDiag diag, C sh, Floating a) =>
Triangular lo diag up sh a
-> Triangular lo (PowerDiag lo up diag) up sh a
Basic.square

multiply ::
   (MatrixShape.DiagUpLo lo up, MatrixShape.TriDiag diag,
    Shape.C sh, Eq sh, Class.Floating a) =>
   Triangular lo diag up sh a -> Triangular lo diag up sh a ->
   Triangular lo diag up sh a
multiply :: Triangular lo diag up sh a
-> Triangular lo diag up sh a -> Triangular lo diag up sh a
multiply = (Array (Triangular lo diag up sh) a
 -> Array (Triangular lo diag up sh) a
 -> Array (Triangular lo diag up sh) a)
-> Triangular lo diag up sh a
-> Triangular lo diag up sh a
-> Triangular lo diag up sh a
forall shA a shB b shC c.
(Array shA a -> Array shB b -> Array shC c)
-> ArrayMatrix shA a -> ArrayMatrix shB b -> ArrayMatrix shC c
ArrMatrix.lift2 Array (Triangular lo diag up sh) a
-> Array (Triangular lo diag up sh) a
-> Array (Triangular lo diag up sh) a
forall lo up diag sh a.
(DiagUpLo lo up, TriDiag diag, C sh, Eq sh, Floating a) =>
Triangular lo diag up sh a
-> Triangular lo diag up sh a -> Triangular lo diag up sh a
Basic.multiply

multiplyFull ::
   (MatrixShape.Content lo, MatrixShape.Content up, MatrixShape.TriDiag diag,
    Extent.C vert, Extent.C horiz,
    Shape.C height, Eq height, Shape.C width,
    Class.Floating a) =>
   Triangular lo diag up height a ->
   Full vert horiz height width a ->
   Full vert horiz height width a
multiplyFull :: Triangular lo diag up height a
-> Full vert horiz height width a -> Full vert horiz height width a
multiplyFull = (Array (Triangular lo diag up height) a
 -> Array (Full vert horiz height width) a
 -> Array (Full vert horiz height width) a)
-> Triangular lo diag up height a
-> Full vert horiz height width a
-> Full vert horiz height width a
forall shA a shB b shC c.
(Array shA a -> Array shB b -> Array shC c)
-> ArrayMatrix shA a -> ArrayMatrix shB b -> ArrayMatrix shC c
ArrMatrix.lift2 Array (Triangular lo diag up height) a
-> Array (Full vert horiz height width) a
-> Array (Full vert horiz height width) a
forall lo up diag vert horiz height width a.
(Content lo, Content up, TriDiag diag, C vert, C horiz, C height,
 Eq height, C width, Floating a) =>
Triangular lo diag up height a
-> Full vert horiz height width a -> Full vert horiz height width a
Basic.multiplyFull



solve ::
   (MatrixShape.Content lo, MatrixShape.Content up, MatrixShape.TriDiag diag,
    Extent.C vert, Extent.C horiz,
    Shape.C sh, Eq sh, Shape.C nrhs, Class.Floating a) =>
   Triangular lo diag up sh a ->
   Full vert horiz sh nrhs a -> Full vert horiz sh nrhs a
solve :: Triangular lo diag up sh a
-> Full vert horiz sh nrhs a -> Full vert horiz sh nrhs a
solve = (Array (Triangular lo diag up sh) a
 -> Array (Full vert horiz sh nrhs) a
 -> Array (Full vert horiz sh nrhs) a)
-> Triangular lo diag up sh a
-> Full vert horiz sh nrhs a
-> Full vert horiz sh nrhs a
forall shA a shB b shC c.
(Array shA a -> Array shB b -> Array shC c)
-> ArrayMatrix shA a -> ArrayMatrix shB b -> ArrayMatrix shC c
ArrMatrix.lift2 Array (Triangular lo diag up sh) a
-> Array (Full vert horiz sh nrhs) a
-> Array (Full vert horiz sh nrhs) a
forall lo up diag vert horiz height width a.
(Content lo, Content up, TriDiag diag, C vert, C horiz, C height,
 Eq height, C width, Floating a) =>
Triangular lo diag up height a
-> Full vert horiz height width a -> Full vert horiz height width a
Linear.solve

inverse ::
   (MatrixShape.Content lo, MatrixShape.Content up, MatrixShape.TriDiag diag,
    Shape.C sh, Class.Floating a) =>
   Triangular lo diag up sh a ->
   Triangular lo (Basic.PowerDiag lo up diag) up sh a
inverse :: Triangular lo diag up sh a
-> Triangular lo (PowerDiag lo up diag) up sh a
inverse = (Array (Triangular lo diag up sh) a
 -> Array (Triangular lo (PowerDiag lo up diag) up sh) a)
-> Triangular lo diag up sh a
-> Triangular lo (PowerDiag lo up diag) up sh a
forall shA a shB b.
(Array shA a -> Array shB b)
-> ArrayMatrix shA a -> ArrayMatrix shB b
ArrMatrix.lift1 Array (Triangular lo diag up sh) a
-> Array (Triangular lo (PowerDiag lo up diag) up sh) a
forall lo up diag sh a.
(Content lo, Content up, TriDiag diag, C sh, Floating a) =>
Triangular lo diag up sh a
-> Triangular lo (PowerDiag lo up diag) up sh a
Linear.inverse

determinant ::
   (MatrixShape.Content lo, MatrixShape.Content up, MatrixShape.TriDiag diag,
    Shape.C sh, Class.Floating a) =>
   Triangular lo diag up sh a -> a
determinant :: Triangular lo diag up sh a -> a
determinant = Triangular lo diag up sh a -> a
forall lo up diag sh a.
(Content lo, Content up, TriDiag diag, C sh, Floating a) =>
Triangular lo diag up sh a -> a
Linear.determinant (Triangular lo diag up sh a -> a)
-> (Triangular lo diag up sh a -> Triangular lo diag up sh a)
-> Triangular lo diag up sh a
-> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Triangular lo diag up sh a -> Triangular lo diag up sh a
forall sh a. ArrayMatrix sh a -> Array sh a
ArrMatrix.toVector



eigenvalues ::
   (MatrixShape.DiagUpLo lo up, Shape.C sh, Class.Floating a) =>
   Triangular lo diag up sh a -> Vector sh a
eigenvalues :: Triangular lo diag up sh a -> Vector sh a
eigenvalues = Triangular lo diag up sh a -> Vector sh a
forall lo up sh a diag.
(DiagUpLo lo up, C sh, Floating a) =>
Triangular lo diag up sh a -> Vector sh a
Eigen.values (Triangular lo diag up sh a -> Vector sh a)
-> (Triangular lo diag up sh a -> Triangular lo diag up sh a)
-> Triangular lo diag up sh a
-> Vector sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Triangular lo diag up sh a -> Triangular lo diag up sh a
forall sh a. ArrayMatrix sh a -> Array sh a
ArrMatrix.toVector

{- |
@(vr,d,vlAdj) = eigensystem a@

Counterintuitively, @vr@ contains the right eigenvectors as columns
and @vlAdj@ contains the left conjugated eigenvectors as rows.
The idea is to provide a decomposition of @a@.
If @a@ is diagonalizable, then @vr@ and @vlAdj@
are almost inverse to each other.
More precisely, @vlAdj \<\> vr@ is a diagonal matrix,
but not necessarily an identity matrix.
This is because all eigenvectors are normalized
such that 'Numeric.LAPACK.Vector.normInf1' is 1.
With the following scaling, the decomposition becomes perfect:

> let scal = takeDiagonal $ vlAdj <> vr
> a == vr <> diagonal (Vector.divide d scal) <> vlAdj

If @a@ is non-diagonalizable
then some columns of @vr@ and corresponding rows of @vlAdj@ are left zero
and the above property does not hold.
-}
eigensystem ::
   (MatrixShape.DiagUpLo lo up, Shape.C sh, Class.Floating a) =>
   Triangular lo NonUnit up sh a ->
   (Triangular lo NonUnit up sh a, Vector sh a, Triangular lo NonUnit up sh a)
eigensystem :: Triangular lo NonUnit up sh a
-> (Triangular lo NonUnit up sh a, Vector sh a,
    Triangular lo NonUnit up sh a)
eigensystem =
   (Array (Triangular lo NonUnit up sh) a
 -> Triangular lo NonUnit up sh a,
 Vector sh a -> Vector sh a,
 Array (Triangular lo NonUnit up sh) a
 -> Triangular lo NonUnit up sh a)
-> (Array (Triangular lo NonUnit up sh) a, Vector sh a,
    Array (Triangular lo NonUnit up sh) a)
-> (Triangular lo NonUnit up sh a, Vector sh a,
    Triangular lo NonUnit up sh a)
forall a d b e c f.
(a -> d, b -> e, c -> f) -> (a, b, c) -> (d, e, f)
mapTriple (Array (Triangular lo NonUnit up sh) a
-> Triangular lo NonUnit up sh a
forall shA a. Array shA a -> ArrayMatrix shA a
ArrMatrix.lift0, Vector sh a -> Vector sh a
forall a. a -> a
id, Array (Triangular lo NonUnit up sh) a
-> Triangular lo NonUnit up sh a
forall shA a. Array shA a -> ArrayMatrix shA a
ArrMatrix.lift0) ((Array (Triangular lo NonUnit up sh) a, Vector sh a,
  Array (Triangular lo NonUnit up sh) a)
 -> (Triangular lo NonUnit up sh a, Vector sh a,
     Triangular lo NonUnit up sh a))
-> (Triangular lo NonUnit up sh a
    -> (Array (Triangular lo NonUnit up sh) a, Vector sh a,
        Array (Triangular lo NonUnit up sh) a))
-> Triangular lo NonUnit up sh a
-> (Triangular lo NonUnit up sh a, Vector sh a,
    Triangular lo NonUnit up sh a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
   Array (Triangular lo NonUnit up sh) a
-> (Array (Triangular lo NonUnit up sh) a, Vector sh a,
    Array (Triangular lo NonUnit up sh) a)
forall lo up sh a.
(DiagUpLo lo up, C sh, Floating a) =>
Triangular lo NonUnit up sh a
-> (Triangular lo NonUnit up sh a, Vector sh a,
    Triangular lo NonUnit up sh a)
Eigen.decompose (Array (Triangular lo NonUnit up sh) a
 -> (Array (Triangular lo NonUnit up sh) a, Vector sh a,
     Array (Triangular lo NonUnit up sh) a))
-> (Triangular lo NonUnit up sh a
    -> Array (Triangular lo NonUnit up sh) a)
-> Triangular lo NonUnit up sh a
-> (Array (Triangular lo NonUnit up sh) a, Vector sh a,
    Array (Triangular lo NonUnit up sh) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Triangular lo NonUnit up sh a
-> Array (Triangular lo NonUnit up sh) a
forall sh a. ArrayMatrix sh a -> Array sh a
ArrMatrix.toVector