m2r (version 1.0.2)

m2_matrix: Create a new matrix in Macaulay2

Description

Create a new matrix in Macaulay2

Usage

m2_matrix(mat, ring, name, code = FALSE)

m2_matrix.(mat, ring, name, code = FALSE)

m2_numrows(x, code = FALSE, ...)

m2_numcols(x, code = FALSE, ...)

m2_length(x, code = FALSE, ...)

# S3 method for m2_matrix print(x, ...)

# S3 method for m2_image print(x, ...)

m2_kernel(mat, name, code = FALSE)

m2_kernel.(mat, name, code = FALSE)

Arguments

mat

a matrix

ring

a ring containing the matrix entries

name

the m2_name of the object, which is it's name on the M2 side

code

return only the M2 code? (default: FALSE)

x

formal argument for print method

...

...

Value

an object of class m2_matrix

Examples

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

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

(mat <- m2_matrix(matrix(c(1,2,3,4,5,6), nrow = 3, ncol = 2)))
m2_matrix(matrix(c(1,2,3,4,5,6), nrow = 3, ncol = 2))

m2_name(mat)
m2(m2_name(mat))
m2(sprintf("class(%s)", m2_name(mat)))
(mat <- m2_matrix.(matrix(c(1,2,3,4,5,6), nrow = 3, ncol = 2)))

##### known issues
########################################

ring("x", "y", "z", coefring = "QQ")
(mat <- matrix(mp(c("x","y","x+y","y-2","x-3","y-z")), nrow = 2, ncol = 3))
m2_matrix(mat, code = TRUE)
m2_matrix(mat)
# the above is an mpoly problem, not a m2r problem
# mpoly does not have a data structure for matrices (as of 12/2016)

mat_chars <- sapply(m2_matrix(mat), print, silent = TRUE)
dim(mat_chars) <- c(2, 3)
mat_chars


m2_numrows(mat)
m2_numcols(mat)
m2_parse(mat)

(mat <- m2_matrix(matrix(c(1,2),nrow=1)))
m2_kernel(mat)

# }

Run the code above in your browser using DataCamp Workspace