最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

r - dgCMatrix is not an extension of class matrix? - Stack Overflow

programmeradmin5浏览0评论

I am working on a program which works with Volesti package in R. I have a large matrix (About 40k x 120k) and I want to use a function from Volesti which only accepts either class matrix or classes extended from it. I found in the documentation that dgCMatrix should be an extension of class matrix but I get this error:

Error in validObject(.Object) : 
  invalid class "Hpolytope" object: 1: invalid object for slot "A" in class "Hpolytope": got class "dgCMatrix", should be or extend class "matrix"
invalid class "Hpolytope" object: 2: invalid object for slot "b" in class "Hpolytope": got class "dgCMatrix", should be or extend class "numeric"

The matrix is currently read from csv and my code looks like this:

df <- read.csv("matrix.csv")
colnames(df) <- c("row", "col", "value")
spmatrix <- sparseMatrix(i = df$row + 1, j = df$col + 1, x = df$value)
dff <- read.csv("vector.csv")
colnames(dff) <- c("row", "col", "value")
vector <- sparseMatrix(i = dff$row + 1, j = dff$col + 1, x = dff$value)
P <- Hpolytope(A = spmatrix, b = vector)

Is there a way that would allow me to somehow make matrix A and vector b from the class dgCMatrix so I can use it for Volesti? Mind there is no way to convert it to normal dense matrix, since it would not fit into RAM and its way too large.

发布评论

评论列表(0)

  1. 暂无评论