Skip to content

Commit

Permalink
[sector2array] fix undesired cancellation of terms
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Jahn committed Dec 11, 2017
1 parent 01d6ee5 commit 17e3dc9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pySecDec/decomposition/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ def _sector2array(sector):
# process `cast`
for index,prod in enumerate(sector.cast):
# symmetries may be hidden by the factorization --> undo it
factors_as_polynomials = [Polynomial(factor.expolist, factor.coeffs, factor.polysymbols, copy=False) for factor in prod.factors]
multiplied_prod = factors_as_polynomials[0] * factors_as_polynomials[1]
multiplied_prod = prod.factors[1].copy()
multiplied_prod.expolist += prod.factors[0].expolist[0]
multiplied_prod.coeffs *= prod.factors[0].coeffs[0]
combined_expolists.extend(multiplied_prod.expolist)
# must distinguish between the individual polynomials and between `Polynomial` and `ExponentiatedPolynomial`
if type(prod.factors[0]) is ExponentiatedPolynomial:
Expand Down
31 changes: 29 additions & 2 deletions pySecDec/decomposition/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_sector2array(self):
target_combined_expolists = np.array([
(1,0), # Jacobian
(0,1),(1,3), # p0
(3,1),(3,2), # p1 --> note the reordering
(3,2),(3,1), # p1
(2,0),(0,1),(1,1) # p2
])
target_combined_coeffs = np.array([
Expand All @@ -129,7 +129,7 @@ def test_sector2array(self):
self.a*SecDecInternalCast(0),self.b*SecDecInternalCast(0),

# p1
self.d*SecDecInternalCast(1),self.c*SecDecInternalCast(1),
self.c*SecDecInternalCast(1),self.d*SecDecInternalCast(1),

# p2
self.e*SecDecInternalOther(0),self.f*SecDecInternalOther(0),self.g*SecDecInternalOther(0)
Expand All @@ -138,6 +138,33 @@ def test_sector2array(self):
np.testing.assert_array_equal(combined_expolists, target_combined_expolists)
np.testing.assert_array_equal(combined_coeffs, target_combined_coeffs)

#@attr('active')
def test_sector2array_cancelling(self):
SecDecInternalCast = sp.symbols('SecDecInternalCast')
a = sp.symbols('a')

mono = Polynomial([(0,1)],[1])
poly = Polynomial([(1,0),(1,0)],[a,-a])
sector = Sector([ Product(mono,poly) ])

combined_expolists, combined_coeffs = _sector2array(sector)

target_combined_expolists = np.array([
(0,0), # Jacobian
(1,1),(1,1) # poly
])
target_combined_coeffs = np.array([
# Jacobian coefficient is ignored (replaced by a dummy)
1,

# poly
a * SecDecInternalCast(0),
-a * SecDecInternalCast(0)
])

np.testing.assert_array_equal(combined_expolists, target_combined_expolists)
np.testing.assert_array_equal(combined_coeffs, target_combined_coeffs)

#@attr('active')
def test_sector2array_other_exponent(self):

Expand Down

0 comments on commit 17e3dc9

Please sign in to comment.