# NOT RUN {
# }
# NOT RUN {
<!-- % library(miraculix); RFoptions(cores=1) -->
# }
# NOT RUN {
require(RandomFieldsUtils)
set.seed(0)
indiv <- 1 + sample(500, 1)
snps <- indiv * 2^sample(7, 1)
snps <- indiv * 100
M <- matrix(ncol=indiv, sample(0:2, indiv * snps, replace=TRUE))
print(system.time(CM <- genomicmatrix(M)))
## V %*% G
Vl <- runif(snps)
print(system.time(VM1 <- vectorGeno(Vl, CM))) # 1.2x slower than '%*%'
print(system.time(VM <- as.vector(Vl %*% M)))
stopifnot(all.equal(as.double(VM), as.double(VM1)))
## G %*% V
Vr <- runif(indiv)
print(system.time(MV1 <- genoVector(CM, Vr))) ## 3x faster than '%*%'
print(system.time(MV <- as.vector(M %*% Vr)))
stopifnot(all.equal(as.double(MV), as.double(MV1)))
# }
Run the code above in your browser using DataLab