R is an open-source Statistical that is rich in vector and mtrix operators. There are versions of R available for Windows, Mac OS and Unix that can be freely downloaded over the Internet.
Note: By default, R displays the elements of an array as a series of horizontal values. This is different from what we are used to in the lectures and in some of the other packages. Not to worry, all of the functions work in the correct manner.
> v <- c(3,2,2) > v [1] 3 2 2
> is.vector(v) [1] TRUE > is.matrix(v) [1] FALSE
> vp <- t(v) > vp [,1] [,2] [,3] [1,] 3 2 2
> w <- c(4,1,2) > s <- v + w > s [1] 7 3 4
> d <- v - w > d [1] -1 1 0
> s <- 3*v > s [1] 9 6 6 > t <- v*3 > t [1] 9 6 6
> d <- v %*% w > d [,1] [1,] 18 > d <- w %*% v > d [,1] [1,] 18 > d <- v %*% v > d [,1] [1,] 17 > d <- w %*% w > d [,1] [1,] 21
> a <- c(4,3) > a [1] 4 3 > sqrt(a %*% a) [,1] [1,] 5 > v [1] 3 2 2 > sqrt(v %*% v) [,1] [1,] 4.123106 > w [1] 4 1 2 > sqrt(w %*% w) [,1] [1,] 4.582576 # you can write a function to get the norm of a vector > normvec<-function(x) + {sqrt(x%*%x)} > normvec(v) [,1] [1,] 4.582576
> l <- c(1/2 , 1/2 , 1/2 , 1/2) > l [1] 0.5 0.5 0.5 0.5 > sqrt(l %*% l) [,1] [1,] 1
> u <- c(1,1,1) > u [1] 1 1 1 > u %*% u [,1] [1,] 3 > v [1] 3 2 2 > u %*% v [,1] [1,] 7 > w [1] 4 1 2 > u %*% w [,1] [1,] 7
Multivariate Course Page
Phil Ender, 23feb05