{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GADTs #-}
module Numeric.LAPACK.Matrix.Triangular.Basic (
   Triangular, TriangularP,
   Layout.UpLo,
   Upper,
   Lower,

   toSquare,
   takeLower,
   takeUpper,

   fromLowerRowMajor, toLowerRowMajor,
   fromUpperRowMajor, toUpperRowMajor,
   forceOrder,

   multiplyVector,
   multiply,
   multiplyFull,
   ) where

import qualified Numeric.LAPACK.Matrix.Mosaic.Unpacked as Unpacked
import qualified Numeric.LAPACK.Matrix.Mosaic.Private as Mos
import qualified Numeric.LAPACK.Matrix.Layout.Private as Layout
import qualified Numeric.LAPACK.Matrix.Extent.Private as Extent
import Numeric.LAPACK.Matrix.Mosaic.Private
         (Triangular, Lower, Upper,
          withPacking, noLabel, applyFuncPair, triArg)
import Numeric.LAPACK.Matrix.Mosaic.Packed (forceOrder)
import Numeric.LAPACK.Matrix.Mosaic.Generic (unpackDirty, repack)
import Numeric.LAPACK.Matrix.Shape.Omni (TriDiag, DiagSingleton, charFromTriDiag)
import Numeric.LAPACK.Matrix.Layout.Private
         (Order(RowMajor,ColumnMajor),
          transposeFromOrder, uploFromOrder, uploOrder)
import Numeric.LAPACK.Matrix.Private (Full, Square)
import Numeric.LAPACK.Vector (Vector)
import Numeric.LAPACK.Private (copyBlock)

import qualified Numeric.BLAS.FFI.Generic as BlasGen
import qualified Numeric.Netlib.Utility as Call
import qualified Numeric.Netlib.Class as Class

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

import Foreign.ForeignPtr (withForeignPtr)

import Control.Monad.Trans.Cont (ContT(ContT), evalContT)
import Control.Monad.IO.Class (liftIO)


type TriangularP pack uplo sh = Array (Layout.TriangularP pack uplo sh)


toSquare ::
   (Layout.UpLo uplo, Shape.C sh, Class.Floating a) =>
   Triangular uplo sh a -> Square sh a
toSquare :: forall uplo sh a.
(UpLo uplo, C sh, Floating a) =>
Triangular uplo sh a -> Square sh a
toSquare
   (Array
      (Layout.Mosaic PackingSingleton Packed
Layout.Packed MirrorSingleton NoMirror
Layout.NoMirror UpLoSingleton uplo
uplo Order
order sh
sh)
      ForeignPtr a
a) =
   Square sh -> (Ptr a -> IO ()) -> Array (Square sh) a
forall sh a.
(C sh, Storable a) =>
sh -> (Ptr a -> IO ()) -> Array sh a
Array.unsafeCreate (Order -> sh -> Square sh
forall sh. Order -> sh -> Square sh
Layout.square Order
order sh
sh) ((Ptr a -> IO ()) -> Array (Square sh) a)
-> (Ptr a -> IO ()) -> Array (Square sh) a
forall a b. (a -> b) -> a -> b
$ \Ptr a
bPtr ->
      ForeignPtr a -> (Ptr a -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr a
a ((Ptr a -> IO ()) -> IO ()) -> (Ptr a -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr a
aPtr ->
         Order -> Int -> Ptr a -> Ptr a -> IO ()
forall a. Floating a => Order -> Int -> Ptr a -> Ptr a -> IO ()
Mos.unpackZero (UpLoSingleton uplo -> Order -> Order
forall uplo. UpLoSingleton uplo -> Order -> Order
uploOrder UpLoSingleton uplo
uplo Order
order) (sh -> Int
forall sh. C sh => sh -> Int
Shape.size sh
sh) Ptr a
aPtr Ptr a
bPtr

unpack ::
   (Layout.UpLo uplo, Shape.C sh, Class.Floating a) =>
   Triangular uplo sh a -> Unpacked.Triangular uplo sh a
unpack :: forall uplo sh a.
(UpLo uplo, C sh, Floating a) =>
Triangular uplo sh a -> Triangular uplo sh a
unpack (Array (Layout.Mosaic PackingSingleton Packed
Layout.Packed MirrorSingleton NoMirror
mirror UpLoSingleton uplo
uplo Order
order sh
sh) ForeignPtr a
a) =
   TriangularP Unpacked uplo sh
-> (Ptr a -> IO ()) -> Array (TriangularP Unpacked uplo sh) a
forall sh a.
(C sh, Storable a) =>
sh -> (Ptr a -> IO ()) -> Array sh a
Array.unsafeCreate
      (PackingSingleton Unpacked
-> MirrorSingleton NoMirror
-> UpLoSingleton uplo
-> Order
-> sh
-> TriangularP Unpacked uplo sh
forall pack mirror uplo size.
PackingSingleton pack
-> MirrorSingleton mirror
-> UpLoSingleton uplo
-> Order
-> size
-> Mosaic pack mirror uplo size
Layout.Mosaic PackingSingleton Unpacked
Layout.Unpacked MirrorSingleton NoMirror
mirror UpLoSingleton uplo
uplo Order
order sh
sh) ((Ptr a -> IO ()) -> Array (TriangularP Unpacked uplo sh) a)
-> (Ptr a -> IO ()) -> Array (TriangularP Unpacked uplo sh) a
forall a b. (a -> b) -> a -> b
$
   \Ptr a
bPtr ->
      ForeignPtr a -> (Ptr a -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr a
a ((Ptr a -> IO ()) -> IO ()) -> (Ptr a -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr a
aPtr ->
         Order -> Int -> Ptr a -> Ptr a -> IO ()
forall a. Floating a => Order -> Int -> Ptr a -> Ptr a -> IO ()
Mos.unpackZero (UpLoSingleton uplo -> Order -> Order
forall uplo. UpLoSingleton uplo -> Order -> Order
uploOrder UpLoSingleton uplo
uplo Order
order) (sh -> Int
forall sh. C sh => sh -> Int
Shape.size sh
sh) Ptr a
aPtr Ptr a
bPtr

unpackGen ::
   (Layout.UpLo uplo, Shape.C sh, Class.Floating a) =>
   TriangularP pack uplo sh a -> Unpacked.Triangular uplo sh a
unpackGen :: forall uplo sh a pack.
(UpLo uplo, C sh, Floating a) =>
TriangularP pack uplo sh a -> Triangular uplo sh a
unpackGen TriangularP pack uplo sh a
a =
   case Mosaic pack NoMirror uplo sh -> PackingSingleton pack
forall pack mirror uplo size.
Mosaic pack mirror uplo size -> PackingSingleton pack
Layout.mosaicPack (Mosaic pack NoMirror uplo sh -> PackingSingleton pack)
-> Mosaic pack NoMirror uplo sh -> PackingSingleton pack
forall a b. (a -> b) -> a -> b
$ TriangularP pack uplo sh a -> Mosaic pack NoMirror uplo sh
forall sh a. Array sh a -> sh
Array.shape TriangularP pack uplo sh a
a of
      PackingSingleton pack
Layout.Unpacked -> TriangularP pack uplo sh a
Triangular uplo sh a
a
      PackingSingleton pack
Layout.Packed -> Triangular uplo sh a -> Triangular uplo sh a
forall uplo sh a.
(UpLo uplo, C sh, Floating a) =>
Triangular uplo sh a -> Triangular uplo sh a
unpack TriangularP pack uplo sh a
Triangular uplo sh a
a


takeLower ::
   (Extent.Measure meas, Extent.C horiz,
    Shape.C height, Shape.C width, Class.Floating a) =>
   Full meas Extent.Small horiz height width a -> Lower height a
takeLower :: forall meas horiz height width a.
(Measure meas, C horiz, C height, C width, Floating a) =>
Full meas Small horiz height width a -> Lower height a
takeLower = (Order -> Int -> Ptr a -> IO ())
-> MirrorSingleton NoMirror
-> Full meas Small horiz height width a
-> MosaicLower NoMirror height a
forall meas horiz height width a mirror.
(Measure meas, C horiz, C height, C width, Floating a) =>
(Order -> Int -> Ptr a -> IO ())
-> MirrorSingleton mirror
-> Full meas Small horiz height width a
-> MosaicLower mirror height a
Mos.fromLowerPart Order -> Int -> Ptr a -> IO ()
forall a. Order -> Int -> Ptr a -> IO ()
Mos.leaveDiagonal MirrorSingleton NoMirror
Layout.NoMirror

takeUpper ::
   (Extent.Measure meas, Extent.C vert,
    Shape.C height, Shape.C width, Class.Floating a) =>
   Full meas vert Extent.Small height width a -> Upper width a
takeUpper :: forall meas vert height width a.
(Measure meas, C vert, C height, C width, Floating a) =>
Full meas vert Small height width a -> Upper width a
takeUpper (Array (Layout.Full Order
order Extent meas vert Small height width
extent) ForeignPtr a
a) =
   let (height
height,width
width) = Extent meas vert Small height width -> (height, width)
forall meas vert horiz height width.
(Measure meas, C vert, C horiz) =>
Extent meas vert horiz height width -> (height, width)
Extent.dimensions Extent meas vert Small height width
extent
       m :: Int
m = height -> Int
forall sh. C sh => sh -> Int
Shape.size height
height
       n :: Int
n = width -> Int
forall sh. C sh => sh -> Int
Shape.size width
width
       k :: Int
k = case Order
order of Order
RowMajor -> Int
n; Order
ColumnMajor -> Int
m
   in Triangular Upper width
-> (Ptr a -> IO ()) -> Array (Triangular Upper width) a
forall sh a.
(C sh, Storable a) =>
sh -> (Ptr a -> IO ()) -> Array sh a
Array.unsafeCreate
         (PackingSingleton Packed
-> MirrorSingleton NoMirror
-> UpLoSingleton Upper
-> Order
-> width
-> Triangular Upper width
forall pack mirror uplo size.
PackingSingleton pack
-> MirrorSingleton mirror
-> UpLoSingleton uplo
-> Order
-> size
-> Mosaic pack mirror uplo size
Layout.Mosaic PackingSingleton Packed
Layout.Packed
            MirrorSingleton NoMirror
Layout.NoMirror UpLoSingleton Upper
Layout.Upper Order
order width
width) ((Ptr a -> IO ()) -> Array (Triangular Upper width) a)
-> (Ptr a -> IO ()) -> Array (Triangular Upper width) a
forall a b. (a -> b) -> a -> b
$ \Ptr a
bPtr ->
      ForeignPtr a -> (Ptr a -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr a
a ((Ptr a -> IO ()) -> IO ()) -> (Ptr a -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr a
aPtr -> Order -> Int -> Int -> Ptr a -> Ptr a -> IO ()
forall a.
Floating a =>
Order -> Int -> Int -> Ptr a -> Ptr a -> IO ()
Mos.packRect Order
order Int
n Int
k Ptr a
aPtr Ptr a
bPtr


fromLowerRowMajor ::
   (Shape.C sh, Class.Floating a) =>
   Array (Shape.Triangular Shape.Lower sh) a -> Lower sh a
fromLowerRowMajor :: forall sh a.
(C sh, Floating a) =>
Array (Triangular Lower sh) a -> Lower sh a
fromLowerRowMajor =
   (Triangular Lower sh -> Triangular Lower sh)
-> Array (Triangular Lower sh) a -> Array (Triangular Lower sh) a
forall sh0 sh1 a. (sh0 -> sh1) -> Array sh0 a -> Array sh1 a
Array.mapShape (Order -> sh -> Triangular Lower sh
forall size. Order -> size -> LowerTriangular size
Layout.lowerTriangular Order
RowMajor (sh -> Triangular Lower sh)
-> (Triangular Lower sh -> sh)
-> Triangular Lower sh
-> Triangular Lower sh
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Triangular Lower sh -> sh
forall part size. Triangular part size -> size
Shape.triangularSize)

fromUpperRowMajor ::
   (Shape.C sh, Class.Floating a) =>
   Array (Shape.Triangular Shape.Upper sh) a -> Upper sh a
fromUpperRowMajor :: forall sh a.
(C sh, Floating a) =>
Array (Triangular Upper sh) a -> Upper sh a
fromUpperRowMajor =
   (Triangular Upper sh -> Triangular Upper sh)
-> Array (Triangular Upper sh) a -> Array (Triangular Upper sh) a
forall sh0 sh1 a. (sh0 -> sh1) -> Array sh0 a -> Array sh1 a
Array.mapShape (Order -> sh -> Triangular Upper sh
forall size. Order -> size -> UpperTriangular size
Layout.upperTriangular Order
RowMajor (sh -> Triangular Upper sh)
-> (Triangular Upper sh -> sh)
-> Triangular Upper sh
-> Triangular Upper sh
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Triangular Upper sh -> sh
forall part size. Triangular part size -> size
Shape.triangularSize)

toLowerRowMajor ::
   (Shape.C sh, Class.Floating a) =>
   Lower sh a -> Array (Shape.Triangular Shape.Lower sh) a
toLowerRowMajor :: forall sh a.
(C sh, Floating a) =>
Lower sh a -> Array (Triangular Lower sh) a
toLowerRowMajor =
   (Mosaic Packed NoMirror Lower sh -> Triangular Lower sh)
-> Array (Mosaic Packed NoMirror Lower sh) a
-> Array (Triangular Lower sh) a
forall sh0 sh1 a. (sh0 -> sh1) -> Array sh0 a -> Array sh1 a
Array.mapShape (Lower -> sh -> Triangular Lower sh
forall part size. part -> size -> Triangular part size
Shape.Triangular Lower
Shape.Lower (sh -> Triangular Lower sh)
-> (Mosaic Packed NoMirror Lower sh -> sh)
-> Mosaic Packed NoMirror Lower sh
-> Triangular Lower sh
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Mosaic Packed NoMirror Lower sh -> sh
forall pack mirror uplo size. Mosaic pack mirror uplo size -> size
Layout.mosaicSize)
   (Array (Mosaic Packed NoMirror Lower sh) a
 -> Array (Triangular Lower sh) a)
-> (Array (Mosaic Packed NoMirror Lower sh) a
    -> Array (Mosaic Packed NoMirror Lower sh) a)
-> Array (Mosaic Packed NoMirror Lower sh) a
-> Array (Triangular Lower sh) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
   Order
-> Array (Mosaic Packed NoMirror Lower sh) a
-> Array (Mosaic Packed NoMirror Lower sh) a
forall uplo sh a mirror.
(UpLo uplo, C sh, Floating a) =>
Order -> Mosaic mirror uplo sh a -> Mosaic mirror uplo sh a
forceOrder Order
Layout.RowMajor

toUpperRowMajor ::
   (Shape.C sh, Class.Floating a) =>
   Upper sh a -> Array (Shape.Triangular Shape.Upper sh) a
toUpperRowMajor :: forall sh a.
(C sh, Floating a) =>
Upper sh a -> Array (Triangular Upper sh) a
toUpperRowMajor =
   (Mosaic Packed NoMirror Upper sh -> Triangular Upper sh)
-> Array (Mosaic Packed NoMirror Upper sh) a
-> Array (Triangular Upper sh) a
forall sh0 sh1 a. (sh0 -> sh1) -> Array sh0 a -> Array sh1 a
Array.mapShape (Upper -> sh -> Triangular Upper sh
forall part size. part -> size -> Triangular part size
Shape.Triangular Upper
Shape.Upper (sh -> Triangular Upper sh)
-> (Mosaic Packed NoMirror Upper sh -> sh)
-> Mosaic Packed NoMirror Upper sh
-> Triangular Upper sh
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Mosaic Packed NoMirror Upper sh -> sh
forall pack mirror uplo size. Mosaic pack mirror uplo size -> size
Layout.mosaicSize)
   (Array (Mosaic Packed NoMirror Upper sh) a
 -> Array (Triangular Upper sh) a)
-> (Array (Mosaic Packed NoMirror Upper sh) a
    -> Array (Mosaic Packed NoMirror Upper sh) a)
-> Array (Mosaic Packed NoMirror Upper sh) a
-> Array (Triangular Upper sh) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
   Order
-> Array (Mosaic Packed NoMirror Upper sh) a
-> Array (Mosaic Packed NoMirror 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
forceOrder Order
Layout.RowMajor


multiplyVector ::
   (Layout.UpLo uplo, TriDiag diag,
    Shape.C sh, Eq sh, Class.Floating a) =>
   DiagSingleton diag ->
   TriangularP pack uplo sh a -> Vector sh a -> Vector sh a
multiplyVector :: forall uplo diag sh a pack.
(UpLo uplo, TriDiag diag, C sh, Eq sh, Floating a) =>
DiagSingleton diag
-> TriangularP pack uplo sh a -> Vector sh a -> Vector sh a
multiplyVector DiagSingleton diag
diag
   (Array (Layout.Mosaic PackingSingleton pack
pack_ MirrorSingleton NoMirror
Layout.NoMirror UpLoSingleton uplo
uplo Order
order sh
shA) ForeignPtr a
a)
   (Array sh
shX ForeignPtr a
x) =
      sh -> (Ptr a -> IO ()) -> Array sh a
forall sh a.
(C sh, Storable a) =>
sh -> (Ptr a -> IO ()) -> Array sh a
Array.unsafeCreate sh
shX ((Ptr a -> IO ()) -> Array sh a) -> (Ptr a -> IO ()) -> Array sh a
forall a b. (a -> b) -> a -> b
$ \Ptr a
yPtr -> do
   String -> Bool -> IO ()
Call.assert String
"Triangular.multiplyVector: width shapes mismatch" (sh
shA sh -> sh -> Bool
forall a. Eq a => a -> a -> Bool
== sh
shX)
   let n :: Int
n = sh -> Int
forall sh. C sh => sh -> Int
Shape.size sh
shA
   ContT () IO () -> IO ()
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT () IO () -> IO ()) -> ContT () IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
      Ptr CChar
uploPtr <- Char -> FortranIO () (Ptr CChar)
forall r. Char -> FortranIO r (Ptr CChar)
Call.char (Char -> FortranIO () (Ptr CChar))
-> Char -> FortranIO () (Ptr CChar)
forall a b. (a -> b) -> a -> b
$ Order -> Char
uploFromOrder (Order -> Char) -> Order -> Char
forall a b. (a -> b) -> a -> b
$ UpLoSingleton uplo -> Order -> Order
forall uplo. UpLoSingleton uplo -> Order -> Order
uploOrder UpLoSingleton uplo
uplo Order
order
      Ptr CChar
transPtr <- Char -> FortranIO () (Ptr CChar)
forall r. Char -> FortranIO r (Ptr CChar)
Call.char (Char -> FortranIO () (Ptr CChar))
-> Char -> FortranIO () (Ptr CChar)
forall a b. (a -> b) -> a -> b
$ Order -> Char
transposeFromOrder Order
order
      Ptr CChar
diagPtr <- Char -> FortranIO () (Ptr CChar)
forall r. Char -> FortranIO r (Ptr CChar)
Call.char (Char -> FortranIO () (Ptr CChar))
-> Char -> FortranIO () (Ptr CChar)
forall a b. (a -> b) -> a -> b
$ DiagSingleton diag -> Char
forall diag. TriDiag diag => DiagSingleton diag -> Char
charFromTriDiag DiagSingleton diag
diag
      Ptr CInt
nPtr <- Int -> FortranIO () (Ptr CInt)
forall r. Int -> FortranIO r (Ptr CInt)
Call.cint Int
n
      Ptr a
aPtr <- ((Ptr a -> IO ()) -> IO ()) -> ContT () IO (Ptr a)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr a -> IO ()) -> IO ()) -> ContT () IO (Ptr a))
-> ((Ptr a -> IO ()) -> IO ()) -> ContT () IO (Ptr a)
forall a b. (a -> b) -> a -> b
$ ForeignPtr a -> (Ptr a -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr a
a
      Ptr a
xPtr <- ((Ptr a -> IO ()) -> IO ()) -> ContT () IO (Ptr a)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr a -> IO ()) -> IO ()) -> ContT () IO (Ptr a))
-> ((Ptr a -> IO ()) -> IO ()) -> ContT () IO (Ptr a)
forall a b. (a -> b) -> a -> b
$ ForeignPtr a -> (Ptr a -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr a
x
      Ptr CInt
incyPtr <- Int -> FortranIO () (Ptr CInt)
forall r. Int -> FortranIO r (Ptr CInt)
Call.cint Int
1
      IO () -> ContT () IO ()
forall a. IO a -> ContT () IO a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ Int -> Ptr a -> Ptr a -> IO ()
forall a. Floating a => Int -> Ptr a -> Ptr a -> IO ()
copyBlock Int
n Ptr a
xPtr Ptr a
yPtr
      PackingSingleton pack
-> Labelled2 () () (IO ()) (IO ()) -> ContT () IO ()
forall pack r.
PackingSingleton pack
-> Labelled2 r () (IO ()) (IO ()) -> ContT r IO ()
withPacking PackingSingleton pack
pack_ (Labelled2 () () (IO ()) (IO ()) -> ContT () IO ())
-> Labelled2 () () (IO ()) (IO ()) -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$
         Labelled
  (FuncCont
     (Ptr CChar
      -> Ptr CChar
      -> Ptr CChar
      -> Ptr CInt
      -> TriArg a
      -> Ptr a
      -> Ptr CInt
      -> Labelled2 () () (IO ()) (IO ())))
  ()
  (FuncPacked
     (Ptr CChar
      -> Ptr CChar
      -> Ptr CChar
      -> Ptr CInt
      -> TriArg a
      -> Ptr a
      -> Ptr CInt
      -> Labelled2 () () (IO ()) (IO ())))
-> Labelled
     (FuncCont
        (Ptr CChar
         -> Ptr CChar
         -> Ptr CChar
         -> Ptr CInt
         -> TriArg a
         -> Ptr a
         -> Ptr CInt
         -> Labelled2 () () (IO ()) (IO ())))
     ()
     (FuncUnpacked
        (Ptr CChar
         -> Ptr CChar
         -> Ptr CChar
         -> Ptr CInt
         -> TriArg a
         -> Ptr a
         -> Ptr CInt
         -> Labelled2 () () (IO ()) (IO ())))
-> Ptr CChar
-> Ptr CChar
-> Ptr CChar
-> Ptr CInt
-> TriArg a
-> Ptr a
-> Ptr CInt
-> Labelled2 () () (IO ()) (IO ())
forall (m :: * -> *) f.
(m ~ Labelled (FuncCont f) (FuncLabel f), FunctionPair f) =>
m (FuncPacked f) -> m (FuncUnpacked f) -> f
applyFuncPair ((Ptr CChar
 -> Ptr CChar
 -> Ptr CChar
 -> Ptr CInt
 -> Ptr a
 -> Ptr a
 -> Ptr CInt
 -> IO ())
-> Labelled
     (FuncCont
        (Ptr CChar
         -> Ptr CChar
         -> Ptr CChar
         -> Ptr CInt
         -> TriArg a
         -> Ptr a
         -> Ptr CInt
         -> Labelled2 () () (IO ()) (IO ())))
     ()
     (Ptr CChar
      -> Ptr CChar
      -> Ptr CChar
      -> Ptr CInt
      -> Ptr a
      -> Ptr a
      -> Ptr CInt
      -> IO ())
forall a r. a -> Labelled r () a
noLabel Ptr CChar
-> Ptr CChar
-> Ptr CChar
-> Ptr CInt
-> Ptr a
-> Ptr a
-> Ptr CInt
-> IO ()
forall a.
Floating a =>
Ptr CChar
-> Ptr CChar
-> Ptr CChar
-> Ptr CInt
-> Ptr a
-> Ptr a
-> Ptr CInt
-> IO ()
BlasGen.tpmv) ((Ptr CChar
 -> Ptr CChar
 -> Ptr CChar
 -> Ptr CInt
 -> Ptr a
 -> Ptr CInt
 -> Ptr a
 -> Ptr CInt
 -> IO ())
-> Labelled
     (FuncCont
        (Ptr CChar
         -> Ptr CChar
         -> Ptr CChar
         -> Ptr CInt
         -> TriArg a
         -> Ptr a
         -> Ptr CInt
         -> Labelled2 () () (IO ()) (IO ())))
     ()
     (Ptr CChar
      -> Ptr CChar
      -> Ptr CChar
      -> Ptr CInt
      -> Ptr a
      -> Ptr CInt
      -> Ptr a
      -> Ptr CInt
      -> IO ())
forall a r. a -> Labelled r () a
noLabel Ptr CChar
-> Ptr CChar
-> Ptr CChar
-> Ptr CInt
-> Ptr a
-> Ptr CInt
-> Ptr a
-> Ptr CInt
-> IO ()
forall a.
Floating a =>
Ptr CChar
-> Ptr CChar
-> Ptr CChar
-> Ptr CInt
-> Ptr a
-> Ptr CInt
-> Ptr a
-> Ptr CInt
-> IO ()
BlasGen.trmv)
            Ptr CChar
uploPtr Ptr CChar
transPtr Ptr CChar
diagPtr Ptr CInt
nPtr (Ptr a -> Int -> TriArg a
forall a. Ptr a -> Int -> TriArg a
triArg Ptr a
aPtr Int
n) Ptr a
yPtr Ptr CInt
incyPtr


multiply ::
   (Layout.Packing pack, Layout.UpLo uplo, TriDiag diag,
    Shape.C sh, Eq sh, Class.Floating a) =>
   DiagSingleton diag ->
   TriangularP pack uplo sh a ->
   TriangularP pack uplo sh a ->
   TriangularP pack uplo sh a
multiply :: forall pack uplo diag sh a.
(Packing pack, UpLo uplo, TriDiag diag, C sh, Eq sh, Floating a) =>
DiagSingleton diag
-> TriangularP pack uplo sh a
-> TriangularP pack uplo sh a
-> TriangularP pack uplo sh a
multiply DiagSingleton diag
diag TriangularP pack uplo sh a
a TriangularP pack uplo sh a
b =
   MosaicUnpacked NoMirror uplo sh a -> TriangularP pack uplo sh a
forall pack uplo sh a mirror.
(Packing pack, UpLo uplo, C sh, Floating a) =>
MosaicUnpacked mirror uplo sh a -> Mosaic pack mirror uplo sh a
repack (MosaicUnpacked NoMirror uplo sh a -> TriangularP pack uplo sh a)
-> MosaicUnpacked NoMirror uplo sh a -> TriangularP pack uplo sh a
forall a b. (a -> b) -> a -> b
$ DiagSingleton diag
-> MosaicUnpacked NoMirror uplo sh a
-> MosaicUnpacked NoMirror uplo sh a
-> MosaicUnpacked NoMirror uplo sh a
forall uplo diag sh a mirror.
(UpLo uplo, TriDiag diag, C sh, Eq sh, Floating a) =>
DiagSingleton diag
-> Mosaic mirror uplo sh a
-> Mosaic mirror uplo sh a
-> Mosaic mirror uplo sh a
Unpacked.multiplyCompatible DiagSingleton diag
diag (TriangularP pack uplo sh a -> MosaicUnpacked NoMirror uplo sh a
forall uplo sh a pack mirror.
(UpLo uplo, C sh, Floating a) =>
Mosaic pack mirror uplo sh a -> MosaicUnpacked mirror uplo sh a
unpackDirty TriangularP pack uplo sh a
a) (TriangularP pack uplo sh a -> MosaicUnpacked NoMirror uplo sh a
forall uplo sh a pack.
(UpLo uplo, C sh, Floating a) =>
TriangularP pack uplo sh a -> Triangular uplo sh a
unpackGen TriangularP pack uplo sh a
b)

multiplyFull ::
   (Layout.UpLo uplo, TriDiag diag,
    Extent.Measure meas, Extent.C vert, Extent.C horiz,
    Shape.C height, Eq height, Shape.C width,
    Class.Floating a) =>
   DiagSingleton diag ->
   TriangularP pack uplo height a ->
   Full meas vert horiz height width a ->
   Full meas vert horiz height width a
multiplyFull :: forall uplo diag meas vert horiz height width a pack.
(UpLo uplo, TriDiag diag, Measure meas, C vert, C horiz, C height,
 Eq height, C width, Floating a) =>
DiagSingleton diag
-> TriangularP pack uplo height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
multiplyFull DiagSingleton diag
diag = DiagSingleton diag
-> Mosaic NoMirror uplo height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
forall uplo diag meas vert horiz height width a mirror.
(UpLo uplo, TriDiag diag, Measure meas, C vert, C horiz, C height,
 Eq height, C width, Floating a) =>
DiagSingleton diag
-> Mosaic mirror uplo height a
-> Full meas vert horiz height width a
-> Full meas vert horiz height width a
Unpacked.multiplyFull DiagSingleton diag
diag (Mosaic NoMirror uplo height a
 -> Full meas vert horiz height width a
 -> Full meas vert horiz height width a)
-> (TriangularP pack uplo height a
    -> Mosaic NoMirror uplo height a)
-> TriangularP pack uplo 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
. TriangularP pack uplo height a -> Mosaic NoMirror uplo 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
unpackDirty