### R code from vignette source 'matrix-BxC.rnw'
### Encoding: UTF-8

###################################################
### code chunk number 1: matrix-BxC.rnw:61-63
###################################################
a <- c(1,3,2)
a


###################################################
### code chunk number 2: matrix-BxC.rnw:97-98
###################################################
t(a)


###################################################
### code chunk number 3: matrix-BxC.rnw:138-139
###################################################
7*a


###################################################
### code chunk number 4: matrix-BxC.rnw:206-209
###################################################
a <- c(1,3,2)
b <- c(2,8,9)
a+b


###################################################
### code chunk number 5: matrix-BxC.rnw:222-223
###################################################
sum(a*b)


###################################################
### code chunk number 6: matrix-BxC.rnw:234-235
###################################################
sqrt(sum(a*a))


###################################################
### code chunk number 7: matrix-BxC.rnw:248-250
###################################################
rep(0,5)
rep(1,5)


###################################################
### code chunk number 8: matrix-BxC.rnw:265-268
###################################################
v1 <- c(1,1)
v2 <- c(-1,1)
sum(v1*v2)


###################################################
### code chunk number 9: matrix-BxC.rnw:299-301
###################################################
A <- matrix(c(1,3,2,2,8,9),ncol=3)
A


###################################################
### code chunk number 10: matrix-BxC.rnw:306-308
###################################################
A2 <- matrix(c(1,3,2,2,8,9),ncol=3,byrow=T)
A2


###################################################
### code chunk number 11: matrix-BxC.rnw:335-336
###################################################
7*A


###################################################
### code chunk number 12: matrix-BxC.rnw:367-368
###################################################
t(A)


###################################################
### code chunk number 13: matrix-BxC.rnw:408-410
###################################################
B <- matrix(c(5,8,3,4,2,7),ncol=3,byrow=T)
A+B


###################################################
### code chunk number 14: matrix-BxC.rnw:479-480
###################################################
A%*%a


###################################################
### code chunk number 15: matrix-BxC.rnw:485-486
###################################################
A*a


###################################################
### code chunk number 16: matrix-BxC.rnw:601-604
###################################################
A <- matrix(c(1,3,2,2,8,9),ncol=2)
B <- matrix(c(5,8,4,2), ncol=2)
A%*%B


###################################################
### code chunk number 17: matrix-BxC.rnw:639-641
###################################################
matrix(0,nrow=2,ncol=3)
matrix(1,nrow=2,ncol=3)


###################################################
### code chunk number 18: matrix-BxC.rnw:647-649
###################################################
diag(c(1,2,3))
diag(1,3)


###################################################
### code chunk number 19: matrix-BxC.rnw:654-656
###################################################
diag(diag(c(1,2,3)))
diag(A)


###################################################
### code chunk number 20: matrix-BxC.rnw:715-721
###################################################
A <- matrix(c(1,3,2,4),ncol=2,byrow=T)
A
#M2 <- matrix(c(-2,1.5,1,-0.5),ncol=2,byrow=T)
B <- solve(A)
B
A%*%B


###################################################
### code chunk number 21: matrix-BxC.rnw:814-818
###################################################
A <- matrix(c(1,2,3,4),ncol=2)
b <- c(7,10)
x <- solve(A)%*%b
x


###################################################
### code chunk number 22: matrix-BxC.rnw:826-827
###################################################
solve(A,b)


###################################################
### code chunk number 23: matrix-BxC.rnw:943-949
###################################################
library( MASS )
( A <- rbind(c(1,3,2),c(2,8,9)) )
ginv(A)
A %*% ginv(A)
ginv(A) %*% A
A %*% ginv(A) %*% A


###################################################
### code chunk number 24: matrix-BxC.rnw:971-973
###################################################
A <- matrix(c(2,2,3,3,5,9,5,6,7),ncol=3)
A


###################################################
### code chunk number 25: matrix-BxC.rnw:980-982
###################################################
AB <- cbind(A,diag(c(1,1,1)))
AB


###################################################
### code chunk number 26: matrix-BxC.rnw:1006-1010
###################################################
AB[1,] <- AB[1,]/AB[1,1]
AB[2,] <- AB[2,]-2*AB[1,]
AB[3,] <- AB[3,]-3*AB[1,]
AB


###################################################
### code chunk number 27: matrix-BxC.rnw:1018-1020
###################################################
AB[2,] <- AB[2,]/AB[2,2]
AB[3,] <- AB[3,]-4.5*AB[2,]


###################################################
### code chunk number 28: matrix-BxC.rnw:1026-1028
###################################################
AB[3,] <- AB[3,]/AB[3,3]
AB


###################################################
### code chunk number 29: matrix-BxC.rnw:1036-1041
###################################################
AB[2,] <- AB[2,] - 0.5*AB[3,]
AB[1,] <- AB[1,] - 2.5*AB[3,]
AB
AB[1,] <- AB[1,] - 1.5*AB[2,]
AB


###################################################
### code chunk number 30: matrix-BxC.rnw:1050-1052
###################################################
B <- AB[,4:6]
A%*% B


