module Data.Vector.Dense.Class.Internal.Base (
BaseVector(..),
withVectorPtr,
dim,
stride,
isConj,
conjVector
) where
import Foreign
import BLAS.Tensor.Base
class (BaseTensor x Int) => BaseVector x where
vectorViewArray :: ForeignPtr e -> Ptr e -> Int -> Int -> Bool -> x n e
arrayFromVector :: x n e -> (ForeignPtr e, Ptr e, Int, Int, Bool)
conjVector :: (BaseVector x) => x n e -> x n e
conjVector x = let (f,o,n,s,c) = arrayFromVector x
in vectorViewArray f o n s (not c)
withVectorPtr :: (BaseVector x) =>
x n e -> (Ptr e -> IO a) -> IO a
withVectorPtr x f =
let (fp,p,_,_,_) = arrayFromVector x
in do
a <- f p
touchForeignPtr fp
return a
dim :: (BaseVector x) => x n e -> Int
dim x = let (_,_,n,_,_) = arrayFromVector x in n
stride :: (BaseVector x) => x n e -> Int
stride x = let (_,_,_,s,_) = arrayFromVector x in s
isConj :: (BaseVector x) => x n e -> Bool
isConj x = let (_,_,_,_,c) = arrayFromVector x in c