R Under development (unstable) (2023-10-16 r85339 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 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. > # HEADER #################################################### > # This is file spam/tests/demo_timing.R. # > # It is part of the R package spam, # > # --> https://CRAN.R-project.org/package=spam # > # --> https://CRAN.R-project.org/package=spam64 # > # --> https://git.math.uzh.ch/reinhard.furrer/spam # > # by Reinhard Furrer [aut, cre], Florian Gerber [aut], # > # Roman Flury [aut], Daniel Gerber [ctb], # > # Kaspar Moesinger [ctb] # > # HEADER END ################################################ > > > # We construct a few large matrices and we compare how much faster (slower) > # we are compared to the full matrix analysis. > # Since all the calculation are also done with full matrices, we do not > # exagerate with the sizes. > > options( echo=FALSE) Spam version 2.10-0 (2023-10-17) is loaded. Type 'help( Spam)' or 'demo( spam)' for a short introduction and overview of this package. Help for individual functions is also obtained by adding the suffix '.spam' to the function name, e.g. 'help( chol.spam)'. Comparing: Transpose Comparing: multiplication Comparing: solving Comparing: Transpose Comparing: multiplication Comparing: add identity Comparing: add identity quicker Comparing: solving Matrix object of class 'spam' of dimension 10x10, with 10 (row-wise) nonzero elements. Density of the matrix is 10%. Class 'spam' (32-bit) > > > > > > # illustrate the new spam x matrix multiply: > if (F){ + n <- 1000 + + A <- spam(0,n,n) + A[cbind(1:(n-1),2:n)] <- -c(2,rep(4,n-3),2) + A[cbind(1:(n-2),3:n)] <- rep(1,n-2) + A <- A + t( A) + diag(A) <- c(1,5,rep(6,n-4),5,1) + + + B <- array(rnorm(n*n),c(n,n)) + + system.time(C1 <- .spam.matmul.mat(A,B)) + system.time(C2 <- .spam.matmul(A,B)) + norm(C1-C2) + + + } > > proc.time() user system elapsed 1.17 0.07 1.23