Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- ntt :: forall p. KnownNat p => Vector (GF p) -> Vector (GF p)
- intt :: forall p. KnownNat p => Vector (GF p) -> Vector (GF p)
- convolute :: forall p. KnownNat p => Vector (GF p) -> Vector (GF p) -> Vector (GF p)
- data NTTRunner p = NTTRunner {}
- nttRunner :: forall p. KnownNat p => NTTRunner p
- butterfly :: (KnownNat p, PrimMonad m) => MVector (PrimState m) (GF p) -> m ()
- invButterfly :: forall p m. (KnownNat p, PrimMonad m) => MVector (PrimState m) (GF p) -> m ()
- growToPowerOfTwo :: (Num a, Unbox a) => Vector a -> Vector a
- extendToPowerOfTwo :: Int -> Int
- primitiveRoot :: Int -> Int
Documentation
ntt :: forall p. KnownNat p => Vector (GF p) -> Vector (GF p) Source #
Number Theoretic Transform p: prime (c * 2 ^ k + 1)
n = 2 ^ i, n < 2 ^ k
O(n log n)
>>>
ntt @998244353 [1,1,1,1]
[4,0,0,0]>>>
ntt @469762049 [123,0,0,0]
[123,123,123,123]
convolute :: forall p. KnownNat p => Vector (GF p) -> Vector (GF p) -> Vector (GF p) Source #
>>>
convolute @998244353 [1,1,1,0] [1,1,1,0]
[1,2,3,2,1,0,0]>>>
convolute @998244353 [1,1,1] [1,1,1,0]
[1,2,3,2,1,0]
invButterfly :: forall p m. (KnownNat p, PrimMonad m) => MVector (PrimState m) (GF p) -> m () Source #
growToPowerOfTwo :: (Num a, Unbox a) => Vector a -> Vector a Source #
>>>
growToPowerOfTwo (U.fromListN 3 [1::Int,2,3])
[1,2,3,0]
extendToPowerOfTwo :: Int -> Int Source #
>>>
extendToPowerOfTwo 0
1