module Data.Vector.Dense (
Vector,
module BLAS.Vector,
module BLAS.Tensor.Base,
module BLAS.Tensor.Dense.Immutable,
module BLAS.Tensor.Immutable,
module BLAS.Tensor.Scalable,
vector,
listVector,
basis,
subvector,
subvectorWithStride,
sumAbs,
norm2,
whichMaxAbs,
(<.>),
shift,
scale,
invScale,
toList,
fromList,
coerceVector,
unsafeVector,
unsafeSubvector,
unsafeSubvectorWithStride,
) where
import System.IO.Unsafe
import Data.Vector.Dense.Internal
import Data.Vector.Dense.Operations
import BLAS.Access
import BLAS.Elem ( BLAS1, BLAS2 )
import BLAS.Vector hiding ( Vector )
import BLAS.Tensor.Base
import BLAS.Tensor.Dense.Immutable
import BLAS.Tensor.Immutable
import BLAS.Tensor.Scalable
vector :: (BLAS1 e) => Int -> [(Int, e)] -> Vector n e
vector n ies = unsafeFreeze $ unsafePerformIO $ newVector n ies
unsafeVector :: (BLAS1 e) => Int -> [(Int, e)] -> Vector n e
unsafeVector n ies = unsafeFreeze $ unsafePerformIO $ unsafeNewVector n ies
listVector :: (BLAS1 e) => Int -> [e] -> Vector n e
listVector n es = unsafePerformIO $ newListVector n es
basis :: (BLAS1 e) => Int -> Int -> Vector n e
basis n i = unsafeFreeze $ unsafePerformIO $ newBasis n i
toList :: (BLAS1 e) => Vector n e -> [e]
toList = elems
fromList :: (BLAS1 e) => [e] -> Vector n e
fromList es = listVector (length es) es
instance (BLAS1 e) => Scalable (DVector Imm n) e where
(*>) = scale
instance (BLAS2 e) => Num (DVector Imm n e) where
(+) = plus
() = minus
(*) = times
negate = (*>) (1)
abs = amap abs
signum = amap signum
fromInteger = (constant 1) . fromInteger
instance (BLAS2 e) => Fractional (DVector Imm n e) where
(/) = divide
recip = amap recip
fromRational = (constant 1) . fromRational
instance (BLAS2 e, Floating e) => Floating (DVector Imm n e) where
pi = constant 1 pi
exp = amap exp
sqrt = amap sqrt
log = amap log
(**) = azipWith (**)
sin = amap sin
cos = amap cos
tan = amap tan
asin = amap asin
acos = amap acos
atan = amap atan
sinh = amap sinh
cosh = amap cosh
tanh = amap tanh
asinh = amap asinh
acosh = amap acosh
atanh = amap atanh