Skip to content

Commit

Permalink
Trac #21060: wrong parent for q_catalan numbers
Browse files Browse the repository at this point in the history
shoud be the polynomial ring, not fraction field

URL: https://trac.sagemath.org/21060
Reported by: chapoton
Ticket author(s): Frédéric Chapoton
Reviewer(s): Jori Mäntysalo
  • Loading branch information
Release Manager authored and vbraun committed Jul 21, 2016
2 parents 03415e7 + f0d8991 commit 8218404
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/sage/combinat/q_analogues.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,10 @@ def q_multinomial(seq, q=None, binomial_algorithm='auto'):

gaussian_multinomial = q_multinomial


def q_catalan_number(n, q=None):
"""
Returns the `q`-Catalan number of index `n`.
Return the `q`-Catalan number of index `n`.
If `q` is unspecified, then it defaults to using the generator `q` for
a univariate polynomial ring over the integers.
Expand All @@ -431,11 +432,18 @@ def q_catalan_number(n, q=None):
Traceback (most recent call last):
...
ValueError: Argument (-2) must be a nonnegative integer.
TESTS::
sage: q_catalan_number(3).parent()
Univariate Polynomial Ring in q over Integer Ring
"""
if n in ZZ and n >= 0:
return prod(q_int(j, q) for j in range(n+2, 2*n+1)) / prod(q_int(j, q) for j in range(2,n+1))
return (prod(q_int(j, q) for j in range(n + 2, 2 * n + 1)) //
prod(q_int(j, q) for j in range(2, n + 1)))
else:
raise ValueError("Argument (%s) must be a nonnegative integer." %n)
raise ValueError("Argument (%s) must be a nonnegative integer." % n)


def qt_catalan_number(n):
"""
Expand Down

0 comments on commit 8218404

Please sign in to comment.