From 0cde8fb6cf80f3606ece7b47981ff017eb90d00c Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 3 Jun 2024 18:07:10 +0200 Subject: Introduce PermR type synonym --- src/Data/Array/Mixed/Permutation.hs | 3 +++ src/Data/Array/Nested/Internal/Ranked.hs | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Data/Array/Mixed/Permutation.hs b/src/Data/Array/Mixed/Permutation.hs index 6ff3bdc..e1e5c44 100644 --- a/src/Data/Array/Mixed/Permutation.hs +++ b/src/Data/Array/Mixed/Permutation.hs @@ -66,6 +66,9 @@ class KnownPerm l where makePerm :: Perm l instance KnownPerm '[] where makePerm = PNil instance (KnownNat n, KnownPerm l) => KnownPerm (n : l) where makePerm = natSing `PCons` makePerm +-- | Untyped permutations for ranked arrays +type PermR = [Int] + -- ** Applying permutations diff --git a/src/Data/Array/Nested/Internal/Ranked.hs b/src/Data/Array/Nested/Internal/Ranked.hs index d5bd70f..8737733 100644 --- a/src/Data/Array/Nested/Internal/Ranked.hs +++ b/src/Data/Array/Nested/Internal/Ranked.hs @@ -39,6 +39,7 @@ import Data.Array.Mixed.XArray (XArray(..)) import Data.Array.Mixed.XArray qualified as X import Data.Array.Mixed.Internal.Arith import Data.Array.Mixed.Lemmas +import Data.Array.Mixed.Permutation import Data.Array.Mixed.Shape import Data.Array.Mixed.Types import Data.Array.Nested.Internal.Mixed @@ -257,7 +258,7 @@ rsumOuter1 :: forall n a. (NumElt a, PrimElt a) => Ranked (n + 1) a -> Ranked n a rsumOuter1 = rfromPrimitive . rsumOuter1P . rtoPrimitive -rtranspose :: forall n a. Elt a => [Int] -> Ranked n a -> Ranked n a +rtranspose :: forall n a. Elt a => PermR -> Ranked n a -> Ranked n a rtranspose perm arr | sn@SNat <- shrToSNat (rshape arr) , Dict <- lemKnownReplicate sn -- cgit v1.2.3-70-g09d2