File: str_m2.R

package info (click to toggle)
r-cran-m2r 1.0.3%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 472 kB
  • sloc: cpp: 195; python: 59; sh: 14; makefile: 2
file content (47 lines) | stat: -rw-r--r-- 1,137 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#' Give the structure of a Macaulay2 ring
#'
#' Give the structure of a Macaulay2 ring
#'
#' @param object An \code{m2} object
#' @param ... ...
#' @return Invisible the object passed in.
#' @export
#' @examples
#'
#' \dontrun{ requires Macaulay2
#'
#' a <- m2("1")
#'
#' R <- ring(c("x1", "x2", "x3"))
#' str_m2(R)
#' str_m2.default(R)
#'
#' }
#'
str_m2 <- function (object, ...) UseMethod("str_m2")



#' @export
str_m2.default <- function(object, ...) {
  cat("M2 Object\n")
  cat(sprintf("    Type : %s\n", class(object)[1]))
  # cat(sprintf("  R Name : %s\n", deparse(substitute(object))))
  cat(sprintf(" M2 Name : %s\n", m2_name(object)))
}



#' @export
str_m2.m2_polynomialring <- function(object, ...){

  cat("M2 Object\n")
  cat(sprintf("     Type : %s\n", class(object)[1]))
  # cat(sprintf("  R Name : %s\n", deparse(substitute(object))))
  cat(sprintf("  M2 Name : %s\n", m2_name(object)))
  cat(sprintf(" Coefring : %s\n", m2_meta(object, "coefring")))
  cat(sprintf("     Vars : %s\n", paste(m2_meta(object, "vars"), collapse = ", ")))
  cat(sprintf("    Order : %s\n", m2_meta(object, "order")))

  invisible(object)
}