{-# LANGUAGE GADTs #-} module Numeric.LAPACK.Matrix.Mosaic.Unpacked where import qualified Numeric.LAPACK.Matrix.Square.Basic as Square import qualified Numeric.LAPACK.Matrix.Basic as Basic import qualified Numeric.LAPACK.Matrix.Layout.Private as Layout import qualified Numeric.LAPACK.Matrix.Extent.Private as Extent import Numeric.LAPACK.Matrix.Mosaic.Private (uncheck, recheck) import Numeric.LAPACK.Matrix.Private (Square, Full) import Numeric.LAPACK.Matrix.Shape.Omni (TriDiag, DiagSingleton, charFromTriDiag) import Numeric.LAPACK.Matrix.Layout.Private (PackingSingleton(Unpacked), MirrorSingleton, Order(RowMajor,ColumnMajor), flipOrder, transposeFromOrder, sideSwapFromOrder, uploFromOrder, uploOrder) import Numeric.LAPACK.Shape.Private (Unchecked(Unchecked)) import Numeric.LAPACK.Scalar (one, zero) import Numeric.LAPACK.Private (copyBlock, conjugateToTemp) 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) import qualified Data.Stream as Stream import Data.Stream (Stream) import Data.Function.HT (powerAssociative) import Data.Tuple.HT (double) type Mosaic mirror uplo sh = Array (Layout.Mosaic Layout.Unpacked mirror uplo sh) type Triangular uplo sh = Array (Layout.TriangularP Layout.Unpacked uplo sh) fromSquare :: (Layout.UpLo uplo) => MirrorSingleton mirror -> Square sh a -> Mosaic mirror uplo sh a fromSquare :: MirrorSingleton mirror -> Square sh a -> Mosaic mirror uplo sh a fromSquare MirrorSingleton mirror mirror = (Full Shape Small Small sh sh -> Mosaic Unpacked mirror uplo sh) -> Square sh a -> Mosaic mirror uplo sh a forall sh0 sh1 a. (sh0 -> sh1) -> Array sh0 a -> Array sh1 a Array.mapShape (\(Layout.Full Order order Extent Shape Small Small sh sh extent) -> PackingSingleton Unpacked -> MirrorSingleton mirror -> UpLoSingleton uplo -> Order -> sh -> Mosaic Unpacked mirror uplo sh forall pack mirror uplo size. PackingSingleton pack -> MirrorSingleton mirror -> UpLoSingleton uplo -> Order -> size -> Mosaic pack mirror uplo size Layout.Mosaic PackingSingleton Unpacked Unpacked MirrorSingleton mirror mirror UpLoSingleton uplo forall uplo. UpLo uplo => UpLoSingleton uplo Layout.autoUplo Order order (sh -> Mosaic Unpacked mirror uplo sh) -> sh -> Mosaic Unpacked mirror uplo sh forall a b. (a -> b) -> a -> b $ Extent Shape Small Small sh sh -> sh forall shape. Square shape -> shape Extent.squareSize Extent Shape Small Small sh sh extent) toSquare :: Mosaic mirror uplo sh a -> Square sh a toSquare :: Mosaic mirror uplo sh a -> Square sh a toSquare = (Mosaic Unpacked mirror uplo sh -> Square sh) -> Mosaic mirror uplo sh a -> Square sh a forall sh0 sh1 a. (sh0 -> sh1) -> Array sh0 a -> Array sh1 a Array.mapShape (\(Layout.Mosaic PackingSingleton Unpacked Unpacked MirrorSingleton mirror _mirror UpLoSingleton uplo _uplo Order order sh size) -> Order -> sh -> Square sh forall sh. Order -> sh -> Square sh Layout.square Order order sh size) forceOrder :: (Layout.UpLo uplo, Shape.C sh, Class.Floating a) => Order -> Mosaic mirror uplo sh a -> Mosaic mirror uplo sh a forceOrder :: Order -> Mosaic mirror uplo sh a -> Mosaic mirror uplo sh a forceOrder Order newOrder Mosaic mirror uplo sh a a = MirrorSingleton mirror -> Square sh a -> Mosaic mirror uplo sh a forall uplo mirror sh a. UpLo uplo => MirrorSingleton mirror -> Square sh a -> Mosaic mirror uplo sh a fromSquare (Mosaic Unpacked mirror uplo sh -> MirrorSingleton mirror forall pack mirror uplo size. Mosaic pack mirror uplo size -> MirrorSingleton mirror Layout.mosaicMirror (Mosaic Unpacked mirror uplo sh -> MirrorSingleton mirror) -> Mosaic Unpacked mirror uplo sh -> MirrorSingleton mirror forall a b. (a -> b) -> a -> b $ Mosaic mirror uplo sh a -> Mosaic Unpacked mirror uplo sh forall sh a. Array sh a -> sh Array.shape Mosaic mirror uplo sh a a) (Square sh a -> Mosaic mirror uplo sh a) -> (Mosaic mirror uplo sh a -> Square sh a) -> Mosaic mirror uplo sh a -> Mosaic mirror uplo sh a forall b c a. (b -> c) -> (a -> b) -> a -> c . Order -> Square sh a -> Square sh a forall meas vert horiz height width a. (Measure meas, C vert, C horiz, C height, C width, Floating a) => Order -> Full meas vert horiz height width a -> Full meas vert horiz height width a Basic.forceOrder Order newOrder (Square sh a -> Square sh a) -> (Mosaic mirror uplo sh a -> Square sh a) -> Mosaic mirror uplo sh a -> Square sh a forall b c a. (b -> c) -> (a -> b) -> a -> c . Mosaic mirror uplo sh a -> Square sh a forall mirror uplo sh a. Mosaic mirror uplo sh a -> Square sh a toSquare (Mosaic mirror uplo sh a -> Mosaic mirror uplo sh a) -> Mosaic mirror uplo sh a -> Mosaic mirror uplo sh a forall a b. (a -> b) -> a -> b $ Mosaic mirror uplo sh a a square :: (TriDiag diag, Layout.UpLo uplo, Shape.C sh, Class.Floating a) => DiagSingleton diag -> Mosaic mirror uplo sh a -> Mosaic mirror uplo sh a square :: DiagSingleton diag -> Mosaic mirror uplo sh a -> Mosaic mirror uplo sh a square DiagSingleton diag diag = Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic mirror uplo sh a forall pack mirror uplo sh a. Mosaic pack mirror uplo (Unchecked sh) a -> Mosaic pack mirror uplo sh a recheck (Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic mirror uplo sh a) -> (Mosaic mirror uplo sh a -> Mosaic Unpacked mirror uplo (Unchecked sh) a) -> Mosaic mirror uplo sh a -> Mosaic mirror uplo sh a forall b c a. (b -> c) -> (a -> b) -> a -> c . (Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked sh) a) -> (Mosaic Unpacked mirror uplo (Unchecked sh) a, Mosaic Unpacked mirror uplo (Unchecked sh) a) -> Mosaic Unpacked mirror uplo (Unchecked sh) a forall a b c. (a -> b -> c) -> (a, b) -> c uncurry (DiagSingleton diag -> Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked 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 multiplyCompatible DiagSingleton diag diag) ((Mosaic Unpacked mirror uplo (Unchecked sh) a, Mosaic Unpacked mirror uplo (Unchecked sh) a) -> Mosaic Unpacked mirror uplo (Unchecked sh) a) -> (Mosaic mirror uplo sh a -> (Mosaic Unpacked mirror uplo (Unchecked sh) a, Mosaic Unpacked mirror uplo (Unchecked sh) a)) -> Mosaic mirror uplo sh a -> Mosaic Unpacked mirror uplo (Unchecked sh) a forall b c a. (b -> c) -> (a -> b) -> a -> c . Mosaic Unpacked mirror uplo (Unchecked sh) a -> (Mosaic Unpacked mirror uplo (Unchecked sh) a, Mosaic Unpacked mirror uplo (Unchecked sh) a) forall a. a -> (a, a) double (Mosaic Unpacked mirror uplo (Unchecked sh) a -> (Mosaic Unpacked mirror uplo (Unchecked sh) a, Mosaic Unpacked mirror uplo (Unchecked sh) a)) -> (Mosaic mirror uplo sh a -> Mosaic Unpacked mirror uplo (Unchecked sh) a) -> Mosaic mirror uplo sh a -> (Mosaic Unpacked mirror uplo (Unchecked sh) a, Mosaic Unpacked mirror uplo (Unchecked sh) a) forall b c a. (b -> c) -> (a -> b) -> a -> c . Mosaic mirror uplo sh a -> Mosaic Unpacked mirror uplo (Unchecked sh) a forall pack mirror uplo sh a. Mosaic pack mirror uplo sh a -> Mosaic pack mirror uplo (Unchecked sh) a uncheck power :: (Layout.UpLo uplo, TriDiag diag, Shape.C sh, Class.Floating a) => DiagSingleton diag -> Integer -> Mosaic mirror uplo sh a -> Mosaic mirror uplo sh a power :: DiagSingleton diag -> Integer -> Mosaic mirror uplo sh a -> Mosaic mirror uplo sh a power DiagSingleton diag diag Integer n a :: Mosaic mirror uplo sh a a@(Array (Layout.Mosaic PackingSingleton Unpacked Layout.Unpacked MirrorSingleton mirror mirror UpLoSingleton uplo _uplo Order order sh sh) ForeignPtr a _) = Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic mirror uplo sh a forall pack mirror uplo sh a. Mosaic pack mirror uplo (Unchecked sh) a -> Mosaic pack mirror uplo sh a recheck (Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic mirror uplo sh a) -> Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic mirror uplo sh a forall a b. (a -> b) -> a -> b $ (Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked sh) a) -> Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked sh) a -> Integer -> Mosaic Unpacked mirror uplo (Unchecked sh) a forall a. (a -> a -> a) -> a -> a -> Integer -> a powerAssociative (DiagSingleton diag -> Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked 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 multiplyCompatible DiagSingleton diag diag) (MirrorSingleton mirror -> Square (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked sh) a forall uplo mirror sh a. UpLo uplo => MirrorSingleton mirror -> Square sh a -> Mosaic mirror uplo sh a fromSquare MirrorSingleton mirror mirror (Square (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked sh) a) -> Square (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked sh) a forall a b. (a -> b) -> a -> b $ Order -> Unchecked sh -> Square (Unchecked sh) a forall sh a. (C sh, Floating a) => Order -> sh -> Square sh a Square.identityOrder Order order (Unchecked sh -> Square (Unchecked sh) a) -> Unchecked sh -> Square (Unchecked sh) a forall a b. (a -> b) -> a -> b $ sh -> Unchecked sh forall sh. sh -> Unchecked sh Unchecked sh sh) (Mosaic mirror uplo sh a -> Mosaic Unpacked mirror uplo (Unchecked sh) a forall pack mirror uplo sh a. Mosaic pack mirror uplo sh a -> Mosaic pack mirror uplo (Unchecked sh) a uncheck Mosaic mirror uplo sh a a) Integer n powers1 :: (Layout.UpLo uplo, TriDiag diag, Shape.C sh, Class.Floating a) => DiagSingleton diag -> Mosaic mirror uplo sh a -> Stream (Mosaic mirror uplo sh a) powers1 :: DiagSingleton diag -> Mosaic mirror uplo sh a -> Stream (Mosaic mirror uplo sh a) powers1 DiagSingleton diag diag Mosaic mirror uplo sh a a = (Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic mirror uplo sh a) -> Stream (Mosaic Unpacked mirror uplo (Unchecked sh) a) -> Stream (Mosaic mirror uplo sh a) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic mirror uplo sh a forall pack mirror uplo sh a. Mosaic pack mirror uplo (Unchecked sh) a -> Mosaic pack mirror uplo sh a recheck (Stream (Mosaic Unpacked mirror uplo (Unchecked sh) a) -> Stream (Mosaic mirror uplo sh a)) -> Stream (Mosaic Unpacked mirror uplo (Unchecked sh) a) -> Stream (Mosaic mirror uplo sh a) forall a b. (a -> b) -> a -> b $ let au :: Mosaic Unpacked mirror uplo (Unchecked sh) a au = Mosaic mirror uplo sh a -> Mosaic Unpacked mirror uplo (Unchecked sh) a forall pack mirror uplo sh a. Mosaic pack mirror uplo sh a -> Mosaic pack mirror uplo (Unchecked sh) a uncheck Mosaic mirror uplo sh a a in (Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked sh) a) -> Mosaic Unpacked mirror uplo (Unchecked sh) a -> Stream (Mosaic Unpacked mirror uplo (Unchecked sh) a) forall a. (a -> a) -> a -> Stream a Stream.iterate ((Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked sh) a) -> Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked sh) a forall a b c. (a -> b -> c) -> b -> a -> c flip (DiagSingleton diag -> Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked sh) a -> Mosaic Unpacked mirror uplo (Unchecked 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 multiplyCompatible DiagSingleton diag diag) Mosaic Unpacked mirror uplo (Unchecked sh) a au) Mosaic Unpacked mirror uplo (Unchecked sh) a au multiplyCompatible :: (Layout.UpLo uplo, TriDiag diag, Shape.C sh, Eq sh, Class.Floating a) => DiagSingleton diag -> Mosaic mirror uplo sh a -> Mosaic mirror uplo sh a -> Mosaic mirror uplo sh a multiplyCompatible :: DiagSingleton diag -> Mosaic mirror uplo sh a -> Mosaic mirror uplo sh a -> Mosaic mirror uplo sh a multiplyCompatible DiagSingleton diag diag Mosaic mirror uplo sh a a Mosaic mirror uplo sh a b = MirrorSingleton mirror -> Square sh a -> Mosaic mirror uplo sh a forall uplo mirror sh a. UpLo uplo => MirrorSingleton mirror -> Square sh a -> Mosaic mirror uplo sh a fromSquare (Mosaic Unpacked mirror uplo sh -> MirrorSingleton mirror forall pack mirror uplo size. Mosaic pack mirror uplo size -> MirrorSingleton mirror Layout.mosaicMirror (Mosaic Unpacked mirror uplo sh -> MirrorSingleton mirror) -> Mosaic Unpacked mirror uplo sh -> MirrorSingleton mirror forall a b. (a -> b) -> a -> b $ Mosaic mirror uplo sh a -> Mosaic Unpacked mirror uplo sh forall sh a. Array sh a -> sh Array.shape Mosaic mirror uplo sh a b) (Square sh a -> Mosaic mirror uplo sh a) -> Square sh a -> Mosaic mirror uplo sh a forall a b. (a -> b) -> a -> b $ DiagSingleton diag -> Mosaic mirror uplo sh a -> Square sh a -> Square sh 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 multiplyFull DiagSingleton diag diag Mosaic mirror uplo sh a a (Square sh a -> Square sh a) -> Square sh a -> Square sh a forall a b. (a -> b) -> a -> b $ Mosaic mirror uplo sh a -> Square sh a forall mirror uplo sh a. Mosaic mirror uplo sh a -> Square sh a toSquare Mosaic mirror 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 -> Mosaic mirror uplo height a -> Full meas vert horiz height width a -> Full meas vert horiz height width a multiplyFull :: DiagSingleton diag -> Mosaic mirror uplo height a -> Full meas vert horiz height width a -> Full meas vert horiz height width a multiplyFull DiagSingleton diag diag (Array (Layout.Mosaic PackingSingleton Unpacked Layout.Unpacked MirrorSingleton mirror mirror UpLoSingleton uplo uploA Order orderA height shA) ForeignPtr a a) (Array shapeB :: Full meas vert horiz height width shapeB@(Layout.Full Order orderB Extent meas vert horiz height width extentB) ForeignPtr a b) = Full meas vert horiz height width -> (Int -> Ptr a -> IO ()) -> Full meas vert horiz height width a forall sh a. (C sh, Storable a) => sh -> (Int -> Ptr a -> IO ()) -> Array sh a Array.unsafeCreateWithSize Full meas vert horiz height width shapeB ((Int -> Ptr a -> IO ()) -> Full meas vert horiz height width a) -> (Int -> Ptr a -> IO ()) -> Full meas vert horiz height width a forall a b. (a -> b) -> a -> b $ \Int size Ptr a cPtr -> do let (height height,width width) = Extent meas vert horiz 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 horiz height width extentB String -> Bool -> IO () Call.assert (MirrorSingleton mirror -> String forall a. Show a => a -> String show MirrorSingleton mirror mirror String -> String -> String forall a. [a] -> [a] -> [a] ++ String ".multiplyFull: shapes mismatch") (height shA height -> height -> Bool forall a. Eq a => a -> a -> Bool == height height) let m0 :: Int m0 = height -> Int forall sh. C sh => sh -> Int Shape.size height height let n0 :: Int n0 = width -> Int forall sh. C sh => sh -> Int Shape.size width width let realOrderA :: Order realOrderA = UpLoSingleton uplo -> Order -> Order forall uplo. UpLoSingleton uplo -> Order -> Order uploOrder UpLoSingleton uplo uploA Order orderA 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 let (Char side,(Int m,Int n)) = Order -> (Int, Int) -> (Char, (Int, Int)) forall a. Order -> (a, a) -> (Char, (a, a)) sideSwapFromOrder Order orderB (Int m0,Int n0) Ptr CChar sidePtr <- Char -> FortranIO () (Ptr CChar) forall r. Char -> FortranIO r (Ptr CChar) Call.char Char side 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 realOrderA Ptr CInt mPtr <- Int -> FortranIO () (Ptr CInt) forall r. Int -> FortranIO r (Ptr CInt) Call.cint Int m Ptr CInt nPtr <- Int -> FortranIO () (Ptr CInt) forall r. Int -> FortranIO r (Ptr CInt) Call.cint Int n Ptr a alphaPtr <- a -> FortranIO () (Ptr a) forall a r. Floating a => a -> FortranIO r (Ptr a) Call.number a forall a. Floating a => a one Ptr CInt ldaPtr <- Int -> FortranIO () (Ptr CInt) forall r. Int -> FortranIO r (Ptr CInt) Call.leadingDim Int m0 Ptr a bPtr <- ((Ptr a -> IO ()) -> IO ()) -> FortranIO () (Ptr a) forall k (r :: k) (m :: k -> *) a. ((a -> m r) -> m r) -> ContT r m a ContT (ForeignPtr a -> (Ptr a -> IO ()) -> IO () forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b withForeignPtr ForeignPtr a b) FortranIO () (Ptr a) -> FortranIO () (Ptr a) -> FortranIO () (Ptr a) forall a. a -> a -> a `asTypeOf` Ptr a -> FortranIO () (Ptr a) forall (m :: * -> *) a. Monad m => a -> m a return Ptr a alphaPtr Ptr CInt ldbPtr <- Int -> FortranIO () (Ptr CInt) forall r. Int -> FortranIO r (Ptr CInt) Call.leadingDim Int m case MirrorSingleton mirror mirror of MirrorSingleton mirror Layout.NoMirror -> do 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 -> Char) -> Order -> Char forall a b. (a -> b) -> a -> b $ case Order orderB of Order ColumnMajor -> Order orderA Order RowMajor -> Order -> Order flipOrder Order orderA 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 a aPtr <- ((Ptr a -> IO ()) -> IO ()) -> FortranIO () (Ptr a) forall k (r :: k) (m :: k -> *) a. ((a -> m r) -> m r) -> ContT r m a ContT (((Ptr a -> IO ()) -> IO ()) -> FortranIO () (Ptr a)) -> ((Ptr a -> IO ()) -> IO ()) -> FortranIO () (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 IO () -> ContT () IO () forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO () -> ContT () IO ()) -> IO () -> ContT () IO () forall a b. (a -> b) -> a -> b $ do Int -> Ptr a -> Ptr a -> IO () forall a. Floating a => Int -> Ptr a -> Ptr a -> IO () copyBlock Int size Ptr a bPtr Ptr a cPtr Ptr CChar -> Ptr CChar -> Ptr CChar -> Ptr CChar -> Ptr CInt -> Ptr CInt -> Ptr a -> Ptr a -> Ptr CInt -> Ptr a -> Ptr CInt -> IO () forall a. Floating a => Ptr CChar -> Ptr CChar -> Ptr CChar -> Ptr CChar -> Ptr CInt -> Ptr CInt -> Ptr a -> Ptr a -> Ptr CInt -> Ptr a -> Ptr CInt -> IO () BlasGen.trmm Ptr CChar sidePtr Ptr CChar uploPtr Ptr CChar transPtr Ptr CChar diagPtr Ptr CInt mPtr Ptr CInt nPtr Ptr a alphaPtr Ptr a aPtr Ptr CInt ldaPtr Ptr a cPtr Ptr CInt ldbPtr MirrorSingleton mirror Layout.SimpleMirror -> do Ptr a betaPtr <- a -> FortranIO () (Ptr a) forall a r. Floating a => a -> FortranIO r (Ptr a) Call.number a forall a. Floating a => a zero Ptr a aPtr <- ((Ptr a -> IO ()) -> IO ()) -> FortranIO () (Ptr a) forall k (r :: k) (m :: k -> *) a. ((a -> m r) -> m r) -> ContT r m a ContT (((Ptr a -> IO ()) -> IO ()) -> FortranIO () (Ptr a)) -> ((Ptr a -> IO ()) -> IO ()) -> FortranIO () (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 IO () -> ContT () IO () forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO () -> ContT () IO ()) -> IO () -> ContT () IO () forall a b. (a -> b) -> a -> b $ Ptr CChar -> Ptr CChar -> Ptr CInt -> Ptr CInt -> Ptr a -> Ptr a -> Ptr CInt -> Ptr a -> Ptr CInt -> Ptr a -> Ptr a -> Ptr CInt -> IO () forall a. Floating a => Ptr CChar -> Ptr CChar -> Ptr CInt -> Ptr CInt -> Ptr a -> Ptr a -> Ptr CInt -> Ptr a -> Ptr CInt -> Ptr a -> Ptr a -> Ptr CInt -> IO () BlasGen.symm Ptr CChar sidePtr Ptr CChar uploPtr Ptr CInt mPtr Ptr CInt nPtr Ptr a alphaPtr Ptr a aPtr Ptr CInt ldaPtr Ptr a bPtr Ptr CInt ldbPtr Ptr a betaPtr Ptr a cPtr Ptr CInt ldbPtr MirrorSingleton mirror Layout.ConjugateMirror -> do Ptr a aPtr <- if Order orderA Order -> Order -> Bool forall a. Eq a => a -> a -> Bool == Order orderB then ((Ptr a -> IO ()) -> IO ()) -> FortranIO () (Ptr a) forall k (r :: k) (m :: k -> *) a. ((a -> m r) -> m r) -> ContT r m a ContT (((Ptr a -> IO ()) -> IO ()) -> FortranIO () (Ptr a)) -> ((Ptr a -> IO ()) -> IO ()) -> FortranIO () (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 else Int -> ForeignPtr a -> FortranIO () (Ptr a) forall a r. Floating a => Int -> ForeignPtr a -> ContT r IO (Ptr a) conjugateToTemp (Int m0Int -> Int -> Int forall a. Num a => a -> a -> a *Int m0) ForeignPtr a a Ptr a betaPtr <- a -> FortranIO () (Ptr a) forall a r. Floating a => a -> FortranIO r (Ptr a) Call.number a forall a. Floating a => a zero IO () -> ContT () IO () forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO () -> ContT () IO ()) -> IO () -> ContT () IO () forall a b. (a -> b) -> a -> b $ Ptr CChar -> Ptr CChar -> Ptr CInt -> Ptr CInt -> Ptr a -> Ptr a -> Ptr CInt -> Ptr a -> Ptr CInt -> Ptr a -> Ptr a -> Ptr CInt -> IO () forall a. Floating a => Ptr CChar -> Ptr CChar -> Ptr CInt -> Ptr CInt -> Ptr a -> Ptr a -> Ptr CInt -> Ptr a -> Ptr CInt -> Ptr a -> Ptr a -> Ptr CInt -> IO () BlasGen.hemm Ptr CChar sidePtr Ptr CChar uploPtr Ptr CInt mPtr Ptr CInt nPtr Ptr a alphaPtr Ptr a aPtr Ptr CInt ldaPtr Ptr a bPtr Ptr CInt ldbPtr Ptr a betaPtr Ptr a cPtr Ptr CInt ldbPtr