algstat (version 0.0.2)

m2: Evaluate Macaulay2 Code

Description

Write a Macaulay2 file, evaluate it through a back-end connection to Macaulay2, and bring the output back into R.

Usage

m2(code, dir = tempdir(), opts = "--script")

Arguments

code
Macaulay2 code as either a character string or function; see examples
dir
directory to place the files in
opts
options for m2

Value

an object of class m2

Examples

Run this code
## Not run: 
# 
# options(digits = 20)
# 13^20
# m2("13^20") # correct answer
# m2("toRR(20,(19004963774880800571392-13^20)/13^20)") # relative error
# options(digits = 7)
# 
# code <- "
# 1+1
# 2+3
# 100!
# R = QQ[x,y,z]
# (x+y)^10
# curve = ideal( x^4-y^5, x^3-y^7 )
# gens gb curve
# m = matrix {{x^2, x^2-y^2, x*y*z^7 }}
# image m
# R = QQ[a..d]
# I = ideal(a^3-b^2*c, b*c^2-c*d^2, c^3)
# G = gens gb I
# G
# "
# m2(code)
# 
# 
# code <- "
# R = QQ[x,y,z,t]
# I = ideal( t^4 - x, t^3 - y, t^2 - z)
# gens gb I
# "
# m2(code)
# 
# ## End(Not run)

Run the code above in your browser using DataLab