| Copyright | (C) 2025 Alexey Tochin |
|---|---|
| License | BSD3 (see the file LICENSE) |
| Maintainer | Alexey Tochin <Alexey.Tochin@gmail.com> |
| Safe Haskell | None |
| Language | Haskell2010 |
Numeric.InfBackprop.Utils.SizedVector
Description
Utility functions for working with sized vector.
Documentation
boxedVectorBasis :: forall (v :: Type -> Type) a (n :: Nat). (Vector v a, KnownNat n) => Finite n -> a -> a -> Vector v n a Source #
Creates a sized vector of size n with all elements set to x :: a
except for the one at index k, which is set to y :: a.
Examples
>>>import GHC.Base (Int, String)>>>import qualified Data.Vector as DV>>>import qualified Data.Vector.Generic.Sized as DVGS
>>>boxedVectorBasis 2 0 1 :: DVGS.Vector DV.Vector 4 IntVector [0,0,1,0]
>>>boxedVectorBasis 1 "zero" "one" :: DVGS.Vector DV.Vector 5 StringVector ["zero","one","zero","zero","zero"]
boxedVectorSum :: forall a (n :: Nat). Additive a => Vector Vector n a -> a Source #
Sums all elements of a sized array.
Examples
>>>import GHC.Base (Int)>>>import qualified Data.Vector as DV>>>import qualified Data.Vector.Generic.Sized as DVGS
>>>boxedVectorSum (DVGS.fromTuple (1, 2, 3) :: DVGS.Vector DV.Vector 3 Int)6