Multiply matrices in list

后端 未结 2 1409
南旧
南旧 2021-01-15 15:15

I would like to multiply multiple matrices of a list. I know that this works with a single matrix:

 x1  <- c(2,2,2,3,1,2,4,6,1,2,4)
 y1  <- c(5,4,3,3,         


        
2条回答
  •  再見小時候
    2021-01-15 16:09

    Map is your friend for these sorts of operations. First, let's make some example lists using your data:

    l1 <- replicate(3,mat1,simplify=FALSE)
    l2 <- replicate(3,mat2,simplify=FALSE)
    

    Now, it's as simple as:

    Map("*",l1,l2)
    

提交回复
热议问题