Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
82 lines (56 sloc) 1.92 KB
R version 3.4.2 (2017-09-28)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 17.10
Matrix products: default
BLAS/LAPACK: /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin/libmkl_gf_lp64.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Matrix_1.2-11 magrittr_1.5
loaded via a namespace (and not attached):
[1] compiler_3.4.2 tools_3.4.2 yaml_2.1.14 grid_3.4.2 lattice_0.20-35
> # Set MKL threads if Revolution R Open or Revoltion R Enterprise is available
> ######if(require(Revobase)){
> ###### setMKLthreads(4)
> ######}
>
> # Initialization
> set.seed (1)
> m <- 10000
> n <- 5000
> A <- matrix (runif (m*n),m,n)
> # Matrix multiply
> system.time (B <- crossprod(A))
user system elapsed
5.985 0.252 3.179
> # Cholesky Factorization
> system.time (C <- chol(B))
user system elapsed
1.061 0.040 0.590
> # Singular Value Deomposition
> m <- 10000
> n <- 2000
> A <- matrix (runif (m*n),m,n)
> system.time (S <- svd (A,nu=0,nv=0))
user system elapsed
7.267 0.099 3.848
> # Principal Components Analysis
> m <- 10000
> n <- 2000
> A <- matrix (runif (m*n),m,n)
> system.time (P <- prcomp(A))
user system elapsed
14.932 0.304 8.028
> # Linear Discriminant Analysis
> library('MASS')
> g <- 5
> k <- round (m/2)
> A <- data.frame (A, fac=sample (LETTERS[1:g],m,replace=TRUE))
> train <- sample(1:m, k)
> system.time (L <- lda(fac ~., data=A, prior=rep(1,g)/g, subset=train))
user system elapsed
26.195 0.332 21.022