I would like to do symbolic matrix operations with Ryacas
using a function that converts base R
matrices to Ryacas
format. The result of the function seems to match Ryacas
format. But when I attempt to multiply the matrices, the error
# Error in aa %*% aa : requires numeric/complex matrix/vector arguments
throws. The code below is a minimal example that shows the case.
Any suggestion, please?
library(Ryacas)
conv.mat <- function(x) {
conv <- lapply(1:nrow(x), function(i) paste0(x[i, ], collapse = ", "))
conv <- paste0("List(", paste0("List(", unlist(conv), ")", collapse = ", "), ")")
noquote(conv)
}
# Writing a matrix manually for Ryacas format
a <- List(List(1, 2), List(3, 7))
a * a
# expression(list(list(7, 16), list(24, 55)))
# Writing a matrix in R and convert it to Ryacas format by the function conv.mat
aa <- matrix(c(1, 2, 3, 7), 2, byrow = TRUE)
aa <- conv.mat(aa)
# [1] List(List(1, 2), List(3, 7))
aa * aa
# Error in aa * aa : non-numeric argument to binary operator