Skip to content

Commit 4b44d45

Browse files
committed
add one method to integer-valued polynomials
1 parent 0c390a0 commit 4b44d45

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

src/sage/rings/polynomial/integer_valued_polynomials.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def from_polynomial(self, p):
188188
"""
189189
Convert a polynomial into the ring of integer-valued polynomials.
190190
191-
This raises a ``ValueError`` if this is not possible.
191+
This raises a :class:`ValueError` if this is not possible.
192192
193193
INPUT:
194194
@@ -1174,6 +1174,41 @@ def _poly(self, i):
11741174
return binomial(x, i)
11751175

11761176
class Element(CombinatorialFreeModule.Element):
1177-
pass
1177+
def variable_shift(self, k=1):
1178+
r"""
1179+
Return the image by the shift of variables.
1180+
1181+
On polynomials, the action is the shift
1182+
on variables `x \mapsto x + k`.
1183+
1184+
INPUT:
1185+
1186+
- `k` -- integer (default: 1)
1187+
1188+
EXAMPLES::
1189+
1190+
sage: A = IntegerValuedPolynomialRing(ZZ).B()
1191+
sage: B = A.basis()
1192+
sage: B[5].variable_shift()
1193+
B[4] + B[5]
1194+
sage: B[5].variable_shift(-1)
1195+
-B[0] + B[1] - B[2] + B[3] - B[4] + B[5]
1196+
1197+
TESTS::
1198+
1199+
sage: B[5].variable_shift(0)
1200+
B[5]
1201+
sage: B[5].variable_shift().variable_shift(-1)
1202+
B[5]
1203+
"""
1204+
if k == 0:
1205+
return self
1206+
A = self.parent()
1207+
1208+
def on_basis(n):
1209+
return A._from_dict({A._indices(j): binomial(k, n - j)
1210+
for j in range(n + 1)})
1211+
1212+
return A.module_morphism(on_basis, codomain=A)(self)
11781213

11791214
B = Binomial

0 commit comments

Comments
 (0)