From 16e52d87e9955628a016946c10515c39ce4ef1d0 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 20 May 2024 16:42:25 +0200 Subject: constant -> replicate --- src/Data/Array/Nested/Internal.hs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/Data/Array/Nested') diff --git a/src/Data/Array/Nested/Internal.hs b/src/Data/Array/Nested/Internal.hs index 3863556..99c4a46 100644 --- a/src/Data/Array/Nested/Internal.hs +++ b/src/Data/Array/Nested/Internal.hs @@ -900,12 +900,12 @@ mtoList = map munScalar . mtoList1 munScalar :: Elt a => Mixed '[] a -> a munScalar arr = mindex arr ZIX -mconstantP :: forall sh a. Storable a => IShX sh -> a -> Mixed sh (Primitive a) -mconstantP sh x = M_Primitive sh (X.constant sh x) +mreplicateP :: forall sh a. Storable a => IShX sh -> a -> Mixed sh (Primitive a) +mreplicateP sh x = M_Primitive sh (X.replicate sh x) -mconstant :: forall sh a. (Storable a, PrimElt a) +mreplicate :: forall sh a. (Storable a, PrimElt a) => IShX sh -> a -> Mixed sh a -mconstant sh x = fromPrimitive (mconstantP sh x) +mreplicate sh x = fromPrimitive (mreplicateP sh x) mslice :: Elt a => SNat i -> SNat n -> Mixed (Just (i + n + k) : sh) a -> Mixed (Just n : sh) a mslice i n arr = @@ -954,7 +954,7 @@ instance (Storable a, Num a, PrimElt a) => Num (Mixed sh a) where negate = mliftPrim negate abs = mliftPrim abs signum = mliftPrim signum - fromInteger _ = error "Data.Array.Nested.fromIntegral: No singletons available, use explicit mconstant" + fromInteger _ = error "Data.Array.Nested.fromIntegral: No singletons available, use explicit mreplicate" mtoRanked :: forall sh a. Elt a => Mixed sh a -> Ranked (X.Rank sh) a mtoRanked arr @@ -1238,7 +1238,7 @@ instance (Storable a, Num a, PrimElt a) => Num (Ranked n a) where negate = arithPromoteRanked negate abs = arithPromoteRanked abs signum = arithPromoteRanked signum - fromInteger _ = error "Data.Array.Nested.fromIntegral: No singletons available, use explicit mconstant" + fromInteger _ = error "Data.Array.Nested.fromIntegral: No singletons available, use explicit mreplicate" zeroIxR :: SNat n -> IIxR n zeroIxR SZ = ZIR @@ -1389,14 +1389,14 @@ rtoList1 = map runScalar . rtoList runScalar :: Elt a => Ranked 0 a -> a runScalar arr = rindex arr ZIR -rconstantP :: forall n a. Storable a => IShR n -> a -> Ranked n (Primitive a) -rconstantP sh x +rreplicateP :: forall n a. Storable a => IShR n -> a -> Ranked n (Primitive a) +rreplicateP sh x | Dict <- lemKnownReplicate (snatFromShR sh) - = Ranked (mconstantP (shCvtRX sh) x) + = Ranked (mreplicateP (shCvtRX sh) x) -rconstant :: forall n a. (Storable a, PrimElt a) +rreplicate :: forall n a. (Storable a, PrimElt a) => IShR n -> a -> Ranked n a -rconstant sh x = coerce fromPrimitive (rconstantP sh x) +rreplicate sh x = coerce fromPrimitive (rreplicateP sh x) rslice :: forall n a. Elt a => Int -> Int -> Ranked (n + 1) a -> Ranked (n + 1) a rslice i n arr @@ -1458,7 +1458,7 @@ instance (Storable a, Num a, PrimElt a) => Num (Shaped sh a) where negate = arithPromoteShaped negate abs = arithPromoteShaped abs signum = arithPromoteShaped signum - fromInteger _ = error "Data.Array.Nested.fromIntegral: No singletons available, use explicit mconstant" + fromInteger _ = error "Data.Array.Nested.fromIntegral: No singletons available, use explicit mreplicate" zeroIxS :: ShS sh -> IIxS sh zeroIxS ZSS = ZIS @@ -1619,11 +1619,11 @@ stoList1 = map sunScalar . stoList sunScalar :: Elt a => Shaped '[] a -> a sunScalar arr = sindex arr ZIS -sconstantP :: forall sh a. Storable a => ShS sh -> a -> Shaped sh (Primitive a) -sconstantP sh x = Shaped (mconstantP (shCvtSX sh) x) +sreplicateP :: forall sh a. Storable a => ShS sh -> a -> Shaped sh (Primitive a) +sreplicateP sh x = Shaped (mreplicateP (shCvtSX sh) x) -sconstant :: (Storable a, PrimElt a) => ShS sh -> a -> Shaped sh a -sconstant sh x = coerce fromPrimitive (sconstantP sh x) +sreplicate :: (Storable a, PrimElt a) => ShS sh -> a -> Shaped sh a +sreplicate sh x = coerce fromPrimitive (sreplicateP sh x) sslice :: Elt a => SNat i -> SNat n -> Shaped (i + n + k : sh) a -> Shaped (n : sh) a sslice i n@SNat arr = -- cgit v1.2.3-70-g09d2