def mono_total_next_grevlex ( m, n, x ):

#*****************************************************************************80
#
## MONO_TOTAL_NEXT_GREVLEX: grevlex next monomial, total degree equal to N.
#
#  Discussion:
#
#    We consider all monomials in an M-dimensional space, with total
#    degree N.
#
#    For example:
#
#    M = 3
#    N = 3
#
#    #  X(1)  X(2)  X(3)  Degree
#      +------------------------
#    1 |  0     0     3        3
#    2 |  0     1     2        3
#    3 |  1     0     2        3
#    4 |  0     2     1        3
#    5 |  1     1     1        3
#    6 |  2     0     1        3
#    7 |  0     3     0        3
#    8 |  1     2     0        3
#    9 |  2     1     0        3
#   10 |  3     0     0        3
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    24 October 2014
#
#  Author:
#
#    John Burkardt
#
#  Parameters:
#
#    Input, integer M, the spatial dimension.
#
#    Input, integer N, the total degree.
#    0 <= N1 <= N2.
#
#    Input, integer X[M], the current monomial.
#    The first element is X = [ 0, 0, ..., 0, N ].
#    The last is [ N, 0, ..., 0, 0 ].
#
#    Output, integer X[M], the next monomial.
#
  from i4vec_sum import i4vec_sum
  from mono_next_grevlex import mono_next_grevlex

  if ( n < 0 ):
    print ''
    print 'MONO_TOTAL_NEXT_GREVLEX - Fatal error!'
    print '  N < 0.'
    sys.exit ( 'MONO_TOTAL_NEXT_GREVLEX - Fatal error!' )

  if ( i4vec_sum ( m, x ) != n ):
    print ''
    print 'MONO_TOTAL_NEXT_GREVLEX - Fatal error!'
    print '  Input X sums is not N.'
    sys.exit ( 'MONO_TOTAL_NEXT_GREVLEX - Fatal error!' )

  if ( n == 0 ):
    return x

  if ( x[0] == n ):
    x[0] = 0
    x[m-1] = n
  else:
    x = mono_next_grevlex ( m, x )

  return x
def mono_upto_next_grevlex ( m, n, x ):

#*****************************************************************************80
#
## MONO_UPTO_NEXT_GREVLEX: grevlex next monomial, total degree up to N.
#
#  Discussion:
#
#    We consider all monomials in an M-dimensional space, with total
#    degree N.
#
#    For example:
#
#    M = 3
#    N = 3
#
#    #  X(1)  X(2)  X(3)  Degree
#      +------------------------
#    1 |  0     0     0        0
#      |
#    2 |  0     0     1        1
#    3 |  0     1     0        1
#    4 |  1     0     0        1
#      |
#    5 |  0     0     2        2
#    6 |  0     1     1        2
#    7 |  1     0     1        2
#    8 |  0     2     0        2
#    9 |  1     1     0        2
#   10 |  2     0     0        2
#      |
#   11 |  0     0     3        3
#   12 |  0     1     2        3
#   13 |  1     0     2        3
#   14 |  0     2     1        3
#   15 |  1     1     1        3
#   16 |  2     0     1        3
#   17 |  0     3     0        3
#   18 |  1     2     0        3
#   19 |  2     1     0        3
#   20 |  3     0     0        3
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    24 October 2014
#
#  Author:
#
#    John Burkardt
#
#  Parameters:
#
#    Input, integer M, the spatial dimension.
#
#    Input, integer N, the total degree.
#    0 <= N.
#
#    Input, integer X[M], the current monomial.
#    The first element is X = [ 0, 0, ..., 0, 0 ].
#    The last is [ N, 0, ..., 0, 0 ].
#
#    Output, integer X[M], the next monomial.
#
  from i4vec_sum import i4vec_sum
  from mono_next_grevlex import mono_next_grevlex

  if ( n < 0 ):
    print ''
    print 'MONO_UPTO_NEXT_GREVLEX - Fatal error!'
    print '  N < 0.'
    sys.exit ( 'MONO_UPTO_NEXT_GREVLEX - Fatal error!' )

  if ( i4vec_sum ( m, x ) < 0 ):
    print ''
    print 'MONO_UPTO_NEXT_GREVLEX - Fatal error!'
    print '  Input X sum is less than 0.'
    sys.exit ( 'MONO_UPTO_NEXT_GREVLEX - Fatal error!' )

  if ( n < i4vec_sum ( m, x ) ):
    print ''
    print 'MONO_UPTO_NEXT_GREVLEX - Fatal error!'
    print '  Input X sum is more than N.'
    sys.exit ( 'MONO_UPTO_NEXT_GREVLEX - Fatal error!' )

  if ( n == 0 ):
    return x

  if ( x[0] == n ):
    x[0] = 0
  else:
    x = mono_next_grevlex ( m, x )

  return x
def mono_upto_next_grevlex(m, n, x):

    #*****************************************************************************80
    #
    ## MONO_UPTO_NEXT_GREVLEX: grevlex next monomial, total degree up to N.
    #
    #  Discussion:
    #
    #    We consider all monomials in an M-dimensional space, with total
    #    degree N.
    #
    #    For example:
    #
    #    M = 3
    #    N = 3
    #
    #    #  X(1)  X(2)  X(3)  Degree
    #      +------------------------
    #    1 |  0     0     0        0
    #      |
    #    2 |  0     0     1        1
    #    3 |  0     1     0        1
    #    4 |  1     0     0        1
    #      |
    #    5 |  0     0     2        2
    #    6 |  0     1     1        2
    #    7 |  1     0     1        2
    #    8 |  0     2     0        2
    #    9 |  1     1     0        2
    #   10 |  2     0     0        2
    #      |
    #   11 |  0     0     3        3
    #   12 |  0     1     2        3
    #   13 |  1     0     2        3
    #   14 |  0     2     1        3
    #   15 |  1     1     1        3
    #   16 |  2     0     1        3
    #   17 |  0     3     0        3
    #   18 |  1     2     0        3
    #   19 |  2     1     0        3
    #   20 |  3     0     0        3
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    24 October 2014
    #
    #  Author:
    #
    #    John Burkardt
    #
    #  Parameters:
    #
    #    Input, integer M, the spatial dimension.
    #
    #    Input, integer N, the total degree.
    #    0 <= N.
    #
    #    Input, integer X[M], the current monomial.
    #    The first element is X = [ 0, 0, ..., 0, 0 ].
    #    The last is [ N, 0, ..., 0, 0 ].
    #
    #    Output, integer X[M], the next monomial.
    #
    from i4vec_sum import i4vec_sum
    from mono_next_grevlex import mono_next_grevlex

    if (n < 0):
        print ''
        print 'MONO_UPTO_NEXT_GREVLEX - Fatal error!'
        print '  N < 0.'
        sys.exit('MONO_UPTO_NEXT_GREVLEX - Fatal error!')

    if (i4vec_sum(m, x) < 0):
        print ''
        print 'MONO_UPTO_NEXT_GREVLEX - Fatal error!'
        print '  Input X sum is less than 0.'
        sys.exit('MONO_UPTO_NEXT_GREVLEX - Fatal error!')

    if (n < i4vec_sum(m, x)):
        print ''
        print 'MONO_UPTO_NEXT_GREVLEX - Fatal error!'
        print '  Input X sum is more than N.'
        sys.exit('MONO_UPTO_NEXT_GREVLEX - Fatal error!')

    if (n == 0):
        return x

    if (x[0] == n):
        x[0] = 0
    else:
        x = mono_next_grevlex(m, x)

    return x
Пример #4
0
def mono_between_next_grevlex(m, n1, n2, x):

    #*****************************************************************************80
    #
    ## MONO_BETWEEN_NEXT_GREVLEX: grevlex next monomial, degree between N1 and N2.
    #
    #  Discussion:
    #
    #    We consider all monomials in an M-dimensional space, with total
    #    degree N between N1 and N2, inclusive.
    #
    #    For example:
    #
    #    M = 3
    #    N1 = 2
    #    N2 = 3
    #
    #    #  X(1)  X(2)  X(3)  Degree
    #      +------------------------
    #    1 |  0     0     2        2
    #    2 |  0     1     1        2
    #    3 |  1     0     1        2
    #    4 |  0     2     0        2
    #    5 |  1     1     0        2
    #    6 |  2     0     0        2
    #      |
    #    7 |  0     0     3        3
    #    8 |  0     1     2        3
    #    9 |  1     0     2        3
    #   10 |  0     2     1        3
    #   11 |  1     1     1        3
    #   12 |  2     0     1        3
    #   13 |  0     3     0        3
    #   14 |  1     2     0        3
    #   15 |  2     1     0        3
    #   16 |  3     0     0        3
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    24 October 2014
    #
    #  Author:
    #
    #    John Burkardt
    #
    #  Parameters:
    #
    #    Input, integer M, the spatial dimension.
    #
    #    Input, integer N1, N2, the minimum and maximum degrees.
    #    0 <= N1 <= N2.
    #
    #    Input, integer X[M], the current monomial.
    #    The first element is X = [ 0, 0, ..., 0, N1 ].
    #    The last is [ N2, 0, ..., 0, 0 ].
    #
    #    Output, integer X[M], the next monomial.
    #
    from i4vec_sum import i4vec_sum
    from mono_next_grevlex import mono_next_grevlex

    if (n1 < 0):
        print ''
        print 'MONO_BETWEEN_NEXT_GREVLEX - Fatal error!'
        print '  N1 < 0.'
        sys.exit('MONO_BETWEEN_NEXT_GREVLEX - Fatal error!')

    if (n2 < n1):
        print ''
        print 'MONO_BETWEEN_NEXT_GREVLEX - Fatal error!'
        print '  N2 < N1.'
        sys.exit('MONO_BETWEEN_NEXT_GREVLEX - Fatal error!')

    if (i4vec_sum(m, x) < n1):
        print ''
        print 'MONO_BETWEEN_NEXT_GREVLEX - Fatal error!'
        print '  Input X sums to less than N1.'
        sys.exit('MONO_BETWEEN_NEXT_GREVLEX - Fatal error!')

    if (n2 < i4vec_sum(m, x)):
        print ''
        print 'MONO_BETWEEN_NEXT_GREVLEX - Fatal error!'
        print '  Input X sums to more than N2.'
        sys.exit('MONO_BETWEEN_NEXT_GREVLEX - Fatal error!')

    if (n2 == 0):
        return x

    if (x[0] == n2):
        x[0] = 0
        x[m - 1] = n1
    else:
        x = mono_next_grevlex(m, x)

    return x
def mono_between_next_grevlex ( m, n1, n2, x ):

#*****************************************************************************80
#
## MONO_BETWEEN_NEXT_GREVLEX: grevlex next monomial, degree between N1 and N2.
#
#  Discussion:
#
#    We consider all monomials in an M-dimensional space, with total
#    degree N between N1 and N2, inclusive.
#
#    For example:
#
#    M = 3
#    N1 = 2
#    N2 = 3
#
#    #  X(1)  X(2)  X(3)  Degree
#      +------------------------
#    1 |  0     0     2        2
#    2 |  0     1     1        2
#    3 |  1     0     1        2
#    4 |  0     2     0        2
#    5 |  1     1     0        2
#    6 |  2     0     0        2
#      |
#    7 |  0     0     3        3
#    8 |  0     1     2        3
#    9 |  1     0     2        3
#   10 |  0     2     1        3
#   11 |  1     1     1        3
#   12 |  2     0     1        3
#   13 |  0     3     0        3
#   14 |  1     2     0        3
#   15 |  2     1     0        3
#   16 |  3     0     0        3
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    24 October 2014
#
#  Author:
#
#    John Burkardt
#
#  Parameters:
#
#    Input, integer M, the spatial dimension.
#
#    Input, integer N1, N2, the minimum and maximum degrees.
#    0 <= N1 <= N2.
#
#    Input, integer X[M], the current monomial.
#    The first element is X = [ 0, 0, ..., 0, N1 ].
#    The last is [ N2, 0, ..., 0, 0 ].
#
#    Output, integer X[M], the next monomial.
#
  from i4vec_sum import i4vec_sum
  from mono_next_grevlex import mono_next_grevlex

  if ( n1 < 0 ):
    print ''
    print 'MONO_BETWEEN_NEXT_GREVLEX - Fatal error!'
    print '  N1 < 0.'
    sys.exit ( 'MONO_BETWEEN_NEXT_GREVLEX - Fatal error!' )

  if ( n2 < n1 ):
    print ''
    print 'MONO_BETWEEN_NEXT_GREVLEX - Fatal error!'
    print '  N2 < N1.'
    sys.exit ( 'MONO_BETWEEN_NEXT_GREVLEX - Fatal error!' )

  if ( i4vec_sum ( m, x ) < n1 ):
    print ''
    print 'MONO_BETWEEN_NEXT_GREVLEX - Fatal error!'
    print '  Input X sums to less than N1.'
    sys.exit ( 'MONO_BETWEEN_NEXT_GREVLEX - Fatal error!' )

  if ( n2 < i4vec_sum ( m, x ) ):
    print ''
    print 'MONO_BETWEEN_NEXT_GREVLEX - Fatal error!'
    print '  Input X sums to more than N2.'
    sys.exit ( 'MONO_BETWEEN_NEXT_GREVLEX - Fatal error!' )

  if ( n2 == 0 ):
    return x

  if ( x[0] == n2 ):
    x[0] = 0
    x[m-1] = n1
  else:
    x = mono_next_grevlex ( m, x )

  return x