Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
habrok:examples:r [2025/06/11 12:07] – Use R syntax highlighting pedrohabrok:examples:r [2025/06/11 12:15] (current) – [Multiple CPUs] lint pedro
Line 10: Line 10:
 # Simple t-test between two equally large groups. # Simple t-test between two equally large groups.
 # Let us generate some data. # Let us generate some data.
-apples <- rnorm(20,mean=1.5,sd=.1) +apples <- rnorm(20, mean = 1.5, sd = .1) 
-pears <- rnorm(20,mean=1.6,sd=.1) +pears <- rnorm(20, mean = 1.6, sd = .1) 
-print(t.test(pears,apples))+print(t.test(pears, apples))
 </code> </code>
  
Line 86: Line 86:
  
 cpu <- Sys.getenv("SLURM_CPUS_ON_NODE", 1) # Number of cores requested (use 1 core if running outside a job). cpu <- Sys.getenv("SLURM_CPUS_ON_NODE", 1) # Number of cores requested (use 1 core if running outside a job).
-hosts <- rep("localhost",cpu)+hosts <- rep("localhost", cpu)
 cl <- makeCluster(hosts, type = "SOCK") cl <- makeCluster(hosts, type = "SOCK")
 # Create random matrices. # Create random matrices.
 n <- 5000 n <- 5000
-A <- matrix(rnorm(n^2),n) +A <- matrix(rnorm(n^2), n) 
-B <- matrix(rnorm(n^2),n)+B <- matrix(rnorm(n^2), n)
  
 # Single core time of matrix multiplication of matrices # Single core time of matrix multiplication of matrices