Skip to content

Commit

Permalink
permuteVariables & swapVariables for constant spray
Browse files Browse the repository at this point in the history
  • Loading branch information
stla committed Apr 25, 2024
1 parent 809ad73 commit 51ea6a1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Math/Algebra/Hspray.hs
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,9 @@ instance (AlgRing.C a, Eq a) => HasVariables (Spray a) where
then spray'
else error "permuteVariables: invalid permutation."
where
spray' = if isConstant spray
then spray
else HM.fromList (zip powers' coeffs)
n = numberOfVariables spray
n' = maximum permutation
isPermutation pmtn = minimum pmtn == 1 && length (nub pmtn) == n'
Expand All @@ -962,14 +965,16 @@ instance (AlgRing.C a, Eq a) => HasVariables (Spray a) where
expnts = map exponents powers
expnts' = map (permuteSeq . growSequence' n') expnts
powers' = map (\exps -> simplifyPowers (Powers exps n')) expnts'
spray' = HM.fromList (zip powers' coeffs)
--
swapVariables :: (Int, Int) -> Spray a -> Spray a
swapVariables (i, j) spray =
if i>=1 && j>=1
then spray'
else error "swapVariables: invalid indices."
where
spray' = if isConstant spray
then spray
else HM.fromList (zip powers' coeffs)
n = maximum [numberOfVariables spray, i, j]
f k | k == i = j
| k == j = i
Expand All @@ -981,7 +986,6 @@ instance (AlgRing.C a, Eq a) => HasVariables (Spray a) where
expnts = map exponents powers
expnts' = map (permuteSeq . growSequence' n) expnts
powers' = map (\exps -> simplifyPowers (Powers exps n)) expnts'
spray' = HM.fromList (zip powers' coeffs)
--
derivative :: Int -> Spray a -> Spray a
derivative i p = if i >= 1
Expand Down

0 comments on commit 51ea6a1

Please sign in to comment.