V <- matrix(c(1, 0.5, 0.5, 1), ncol = 2)
sd <- 1:2
cor2cov(V, sd)
#> [,1] [,2]
#> [1,] 1 1
#> [2,] 1 4
V_ar <- array(c(1, 0.5, 0.5, 1), dim = c(2, 2, 2))
cor2cov_ar(V_ar, sd)
#> , , 1
#>
#> [,1] [,2]
#> [1,] 1 1
#> [2,] 1 4
#>
#> , , 2
#>
#> [,1] [,2]
#> [1,] 1 1
#> [2,] 1 4
#>