IT-Academy

Operacie vektory

Apr 26th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.28 KB | None | 0 0
  1. N = 100 #100000000
  2. a = rnorm(N)
  3. b = rnorm(N)
  4.  
  5. # Vektorizovany pristup
  6. c = a * b
  7.  
  8.  
  9. # Devektorizovany pristup
  10. d = rep(NA, N)
  11. for(i in 1:N) {
  12.   d[i] = a[i] * b[i]
  13. }
  14.  
  15.  
  16. a1 = c(1,2,3,4,5)
  17. a2 = c(6,7,8,9,10)
  18. a3 = a1 * a2
  19. a3
  20. a4 = a1 + a2
  21. a4
  22. a5 = a1 > a2
  23. a5
  24. a6 = !a1
  25. a6
Advertisement
Add Comment
Please, Sign In to add comment