R Under development (unstable) (2024-09-21 r87186 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(glmm) Loading required package: trust Loading required package: mvtnorm Loading required package: Matrix Loading required package: parallel Loading required package: doParallel Loading required package: foreach Loading required package: iterators > set.seed(1234) > > nrow <- 5 > ncol <- 3 > > a <- matrix(rnorm(nrow * ncol), nrow = nrow) > b <- rnorm(ncol) > > foo1 <- as.numeric(a %*% b) > > mout3 <- .C(glmm:::C_matvecmult, a = as.double(a), b = as.double(b), + nrow = as.integer(nrow), ncol = as.integer(ncol), result = double(nrow)) > identical(foo1, mout3$result) [1] TRUE > all.equal(foo1, mout3$result) [1] TRUE > > a<-matrix(1:8,nrow=2) > b<-matrix(1:4,nrow=2) > right<-t(a)%*%b > > stuff<-.C(glmm:::C_matTmatmult,as.double(a),as.double(b),as.integer(2),as.integer(4),as.integer(2),double(8))[[6]] > stuff2<-matrix(stuff,byrow=F,nrow=4) #at least > all.equal(right,stuff2) [1] TRUE > > #make sure the function to add a vector up works > a<-1:5 > right<-sum(a) > stuff<-.C(glmm:::C_sumup,as.double(a),as.integer(length(a)),double(1))[[3]] > all.equal(stuff,right) [1] TRUE > > #make sure the function to do a-b works > a<-6:10 > b<-1:5 > right<-a-b > stuff<-.C(glmm:::C_subvec,as.double(a),as.double(b),length(a),result=double(length(a))) > all.equal(right,stuff$result) [1] TRUE > > # make sure matTvecmult works > a<-matrix(1:8,nrow=2) > b<-1:2 > right<-t(a)%*%b > alsoright<-.C(glmm:::C_matvecmult,as.double(t(a)),as.double(b),as.integer(nrow(t(a))),as.integer(ncol(t(a))),double(4))[[5]] > alsoright<-matrix(alsoright,ncol=1) > all.equal(right,alsoright) [1] TRUE > stuff<-matrix(.C(glmm:::C_matTvecmult,as.double(a),as.double(b),as.integer(nrow(a)),as.integer(ncol(a)),double(4))[[5]],ncol=1) > all.equal(stuff,right) [1] TRUE > > > > proc.time() user system elapsed 1.23 0.23 1.45