m2r (version 1.0.2)

gb: Compute a Grobner basis with Macaulay2

Description

Compute a Grobner basis with Macaulay2

Usage

gb(..., control = list(), raw_chars = FALSE, code = FALSE)

gb.(..., control = list(), raw_chars = FALSE, code = FALSE)

gb_(x, control = list(), raw_chars = FALSE, code = FALSE, ...)

gb_.(x, control = list(), raw_chars = FALSE, code = FALSE, ...)

Arguments

...

...

control

a list of options, see examples

raw_chars

if TRUE, the character vector will not be parsed by mp(), saving time (default: FALSE). the down-side is that the strings must be formated for M2 use directly, as opposed to for mp(). (e.g. "x*y+3" instead of "x y + 3")

code

return only the M2 code? (default: FALSE)

x

a character vector of polynomials to be parsed by mp(), a mpolyList object, an ideal() or pointer to an ideal

Value

an mpolyList object of class m2_grobner_basis or a m2_grobner_basis_pointer pointing to the same. See mpolyList().

Details

gb uses nonstandard evaluation; gb_ is the standard evaluation equivalent.

See Also

mp(), use_ring()

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
 requires Macaulay2


##### basic usage
########################################

# the last ring evaluated is the one used in the computation
ring("t","x","y","z", coefring = "QQ")
gb("t^4 - x", "t^3 - y", "t^2 - z")

# here's the code it's running in M2
gb("t^4 - x", "t^3 - y", "t^2 - z", code = TRUE)



##### different versions of gb
########################################

# standard evaluation version
poly_chars <- c("t^4 - x", "t^3 - y", "t^2 - z")
gb_(poly_chars)

# reference nonstandard evaluation version
gb.("t^4 - x", "t^3 - y", "t^2 - z")

# reference standard evaluation version
gb_.(poly_chars)



##### different inputs to gb
########################################

# ideals can be passed to gb
I <- ideal("t^4 - x", "t^3 - y", "t^2 - z")
gb_(I)

# note that gb() works here, too, since there is only one input
gb(I)

# ideal pointers can be passed to gb
I. <- ideal.("t^4 - x", "t^3 - y", "t^2 - z")
gb_(I.)

# setting raw_chars is a bit faster, because it doesn't use ideal()
gb("t^4 - x", "t^3 - y", "t^2 - z", raw_chars = TRUE, code = TRUE)
gb("t^4 - x", "t^3 - y", "t^2 - z", raw_chars = TRUE)



##### more advanced usage
########################################

# the control argument accepts a named list with additional
# options
gb_(
  c("t^4 - x", "t^3 - y", "t^2 - z"),
  control = list(StopWithMinimalGenerators = TRUE),
  code = TRUE
)

gb_(
  c("t^4 - x", "t^3 - y", "t^2 - z"),
  control = list(StopWithMinimalGenerators = TRUE)
)



##### potential issues
########################################

# when specifying raw_chars, be sure to add asterisks
# between variables to create monomials; that's the M2 way
ring("x", "y", "z", coefring = "QQ")
gb("x y", "x z", "x", raw_chars = TRUE, code = TRUE) # errors without code = TRUE
gb("x*y", "x*z", "x", raw_chars = TRUE, code = TRUE) # correct way
gb("x*y", "x*z", "x", raw_chars = TRUE)









# }

Run the code above in your browser using DataCamp Workspace