Commits

Aleksey Khudyakov committed 33eecab

Add basis to ContVec

Comments (0)

Files changed (2)

 --
 basis :: forall v a. (Vector v a, Num a) => Int -> v a
 {-# INLINE basis #-}
-basis n = create $ Cont
-        $ basisF n
+basis = C.vector . C.basis
 
-newtype T_basis n = T_basis Int
-
-basisF :: forall n a b. (Num a, Arity n) => Int -> Fun n a b -> b
-basisF n0 (Fun f)
-  = apply (\(T_basis n) -> ((if n == 0 then 1 else 0) :: a, T_basis (n - 1)))
-          (T_basis n0 :: T_basis n)
-          f
 
 
 ----------------------------------------------------------------

Data/Vector/Fixed/Cont.hs

   , replicateM
   , generate
   , generateM
+  , basis
     -- ** Constructors
   , mk1
   , mk2
 
 newtype T_generate n = T_generate Int
 
+newtype T_basis n = T_basis Int
+
+basis :: forall r m n a. (Num a, Arity n) => Int -> ContVecT r m n a
+{-# INLINE basis #-}
+basis n0 = ContVecT $ \(Fun fun) ->
+  apply (\(T_basis n) -> ((if n == 0 then 1 else 0) :: a, T_basis (n - 1)))
+        (T_basis n0 :: T_basis n)
+        fun
+
 
 mk1 :: a -> ContVecT r m N1 a
 mk1 a1 = ContVecT $ \(Fun f) -> f a1