Kronecker product for large matrices

后端 未结 2 2111
有刺的猬
有刺的猬 2021-01-02 13:13

I am looking for an effficient way of computing the Kronecker product of two large matrices. I have tried using the method kronecker() as follows:



        
2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-02 13:33

    As long as you use Matrix::Diagonal to construct your diagonal matrix, you'll automatically get your test object constructed as a sparse matrix:

    library(Matrix)
    I=Diagonal(700)
    data = replicate(15,rnorm(120))
    system.time(test <- kronecker(I,data))
    ##   user  system elapsed
    ##  0.600   0.044   0.671 
    dim(test)
    ## [1] 84000 10500
    format(object.size(test),"Mb")
    ## [1] "19.2 Mb"
    

提交回复
热议问题