0

我有一个列表,R=

[[1]]
     [,1] [,2]
[1,]  100    0
[2,]    0  100

[[2]]
             [,1]       [,2]
[1,] 0.0006364031  0.2521204
[2,] 0.2521204236 99.9993643`

我想这样做F %*% R

         F
[1,] 1 -6.264917e-04
[2,] 1  1.575666e-04

F[1,]矩阵乘以R[[1]]F[2,]矩阵乘以R[[2]]

我该怎么做呢?

对不起。我想我被误解了。我真正想要的是F[1,]%*%R[[1]]%*%t(F[1,])F[2,]%*%R[[2]]%*%t(F[2,]) @Sven Hohenstein

4

3 回答 3

6
mapply("%*%", as.data.frame(t(F)), R, SIMPLIFY = FALSE)

$V1
     [,1]        [,2]
[1,]  100 -0.06264917

$V2
             [,1]     [,2]
[1,] 0.0006761289 0.267877

更新

回答你的第二个问题:

lapply(R, function(x) F %*% x %*% t(F))

[[1]]
          [,1]      [,2]
[1,] 100.00004  99.99999
[2,]  99.99999 100.00000

[[2]]
             [,1]         [,2]
[1,] 0.0003597493 0.0005083061
[2,] 0.0005083062 0.0007183373

更新

要回答您更新的问题:

mapply(function(x, y) y %*% x %*% as.matrix(y), R, as.data.frame(t(F)), 
       SIMPLIFY = FALSE)

[[1]]
     [,1]
[1,]  100

[[2]]
             [,1]
[1,] 0.0007183373
于 2013-03-13T13:40:08.787 回答
3
R <- list(matrix(c(100,0,0,100), 2), matrix(c(0.0006364031,0.2521204236,0.2521204,99.9993643), 2))
F <- matrix(c(1, 1, -6.264917e-04,  1.575666e-04), 2)

lapply(1:2, function(x) F[x,] %*% R[[x]])
## [[1]]
##      [,1]        [,2]
## [1,]  100 -0.06264917
## 
## [[2]]
##              [,1]     [,2]
## [1,] 0.0006761289 0.267877
于 2013-03-13T13:33:43.080 回答
3

只需这样做:

> F[1,]%*%R[[1]]
     [,1]        [,2]
[1,]  100 -0.06264917


> F[2,]%*%R[[2]]
             [,1]     [,2]
[1,] 0.0006761289 0.267877

您是否希望以某种特定方式存储它们?

于 2013-03-13T13:59:12.350 回答