module Numeric.LAPACK.Vector.Private where import qualified Numeric.LAPACK.Shape.Private as ShapePriv import qualified Numeric.LAPACK.FFI.Complex as LapackComplex import qualified Numeric.BLAS.FFI.Generic as BlasGen import qualified Numeric.Netlib.Utility as Call import qualified Numeric.Netlib.Class as Class import Foreign.ForeignPtr (withForeignPtr) import Foreign.Ptr (Ptr) import Foreign.C.Types (CInt) import Control.Monad.Trans.Cont (ContT(ContT), evalContT) import Control.Monad.IO.Class (liftIO) 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)) mac :: (Shape.C sh, Class.Floating a) => a -> Array sh a -> Array sh a -> Array sh a mac :: a -> Array sh a -> Array sh a -> Array sh a mac a alpha (Array sh shX ForeignPtr a x) (Array sh _shY ForeignPtr a y) = sh -> (Int -> Ptr a -> IO ()) -> Array sh a forall sh a. (C sh, Storable a) => sh -> (Int -> Ptr a -> IO ()) -> Array sh a Array.unsafeCreateWithSize sh shX ((Int -> Ptr a -> IO ()) -> Array sh a) -> (Int -> Ptr a -> IO ()) -> Array sh a forall a b. (a -> b) -> a -> b $ \Int n Ptr a szPtr -> 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 CInt nPtr <- Int -> FortranIO () (Ptr CInt) forall r. Int -> FortranIO r (Ptr CInt) Call.cint Int n Ptr a saPtr <- a -> FortranIO () (Ptr a) forall a r. Floating a => a -> FortranIO r (Ptr a) Call.number a alpha Ptr a sxPtr <- ((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 x Ptr CInt incxPtr <- Int -> FortranIO () (Ptr CInt) forall r. Int -> FortranIO r (Ptr CInt) Call.cint Int 1 Ptr a syPtr <- ((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 y Ptr CInt incyPtr <- Int -> FortranIO () (Ptr CInt) forall r. Int -> FortranIO r (Ptr CInt) Call.cint Int 1 Ptr CInt inczPtr <- Int -> FortranIO () (Ptr CInt) forall r. Int -> FortranIO r (Ptr CInt) Call.cint Int 1 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 CInt -> Ptr a -> Ptr CInt -> Ptr a -> Ptr CInt -> IO () forall a. Floating a => Ptr CInt -> Ptr a -> Ptr CInt -> Ptr a -> Ptr CInt -> IO () BlasGen.copy Ptr CInt nPtr Ptr a syPtr Ptr CInt incyPtr Ptr a szPtr Ptr CInt inczPtr 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 CInt -> Ptr a -> Ptr a -> Ptr CInt -> Ptr a -> Ptr CInt -> IO () forall a. Floating a => Ptr CInt -> Ptr a -> Ptr a -> Ptr CInt -> Ptr a -> Ptr CInt -> IO () BlasGen.axpy Ptr CInt nPtr Ptr a saPtr Ptr a sxPtr Ptr CInt incxPtr Ptr a szPtr Ptr CInt inczPtr newtype ArgMaximum a = ArgMaximum {ArgMaximum a -> Ptr CInt -> Ptr a -> Ptr CInt -> IO CInt runArgMaximum :: Ptr CInt -> Ptr a -> Ptr CInt -> IO CInt} absMax :: Class.Floating a => Ptr CInt -> Ptr a -> Ptr CInt -> IO CInt absMax :: Ptr CInt -> Ptr a -> Ptr CInt -> IO CInt absMax = ArgMaximum a -> Ptr CInt -> Ptr a -> Ptr CInt -> IO CInt forall a. ArgMaximum a -> Ptr CInt -> Ptr a -> Ptr CInt -> IO CInt runArgMaximum (ArgMaximum a -> Ptr CInt -> Ptr a -> Ptr CInt -> IO CInt) -> ArgMaximum a -> Ptr CInt -> Ptr a -> Ptr CInt -> IO CInt forall a b. (a -> b) -> a -> b $ ArgMaximum Float -> ArgMaximum Double -> ArgMaximum (Complex Float) -> ArgMaximum (Complex Double) -> ArgMaximum a forall a (f :: * -> *). Floating a => f Float -> f Double -> f (Complex Float) -> f (Complex Double) -> f a Class.switchFloating ((Ptr CInt -> Ptr Float -> Ptr CInt -> IO CInt) -> ArgMaximum Float forall a. (Ptr CInt -> Ptr a -> Ptr CInt -> IO CInt) -> ArgMaximum a ArgMaximum Ptr CInt -> Ptr Float -> Ptr CInt -> IO CInt forall a. Floating a => Ptr CInt -> Ptr a -> Ptr CInt -> IO CInt BlasGen.iamax) ((Ptr CInt -> Ptr Double -> Ptr CInt -> IO CInt) -> ArgMaximum Double forall a. (Ptr CInt -> Ptr a -> Ptr CInt -> IO CInt) -> ArgMaximum a ArgMaximum Ptr CInt -> Ptr Double -> Ptr CInt -> IO CInt forall a. Floating a => Ptr CInt -> Ptr a -> Ptr CInt -> IO CInt BlasGen.iamax) ((Ptr CInt -> Ptr (Complex Float) -> Ptr CInt -> IO CInt) -> ArgMaximum (Complex Float) forall a. (Ptr CInt -> Ptr a -> Ptr CInt -> IO CInt) -> ArgMaximum a ArgMaximum Ptr CInt -> Ptr (Complex Float) -> Ptr CInt -> IO CInt forall a. Real a => Ptr CInt -> Ptr (Complex a) -> Ptr CInt -> IO CInt LapackComplex.imax1) ((Ptr CInt -> Ptr (Complex Double) -> Ptr CInt -> IO CInt) -> ArgMaximum (Complex Double) forall a. (Ptr CInt -> Ptr a -> Ptr CInt -> IO CInt) -> ArgMaximum a ArgMaximum Ptr CInt -> Ptr (Complex Double) -> Ptr CInt -> IO CInt forall a. Real a => Ptr CInt -> Ptr (Complex a) -> Ptr CInt -> IO CInt LapackComplex.imax1) uncheck :: Array sh a -> Array (ShapePriv.Unchecked sh) a uncheck :: Array sh a -> Array (Unchecked sh) a uncheck = (sh -> Unchecked sh) -> Array sh a -> Array (Unchecked sh) a forall sh0 sh1 a. (sh0 -> sh1) -> Array sh0 a -> Array sh1 a Array.mapShape sh -> Unchecked sh forall sh. sh -> Unchecked sh ShapePriv.Unchecked recheck :: Array (ShapePriv.Unchecked sh) a -> Array sh a recheck :: Array (Unchecked sh) a -> Array sh a recheck = (Unchecked sh -> sh) -> Array (Unchecked sh) a -> Array sh a forall sh0 sh1 a. (sh0 -> sh1) -> Array sh0 a -> Array sh1 a Array.mapShape Unchecked sh -> sh forall sh. Unchecked sh -> sh ShapePriv.deconsUnchecked