#example 1
x<-matrix(c(17,24,1,8,15,23,5,7,14,16,4,6,13,20,22,10,12,19,21,3,11,18,25,2,9),
5,5,byrow=TRUE)
y<-matrix(13,1,5)
op<-'+'
BSXFUN(op,x,y)
#example 2
d1<-c(4,3,1,2)
x = array(runif(prod(d1)),d1)
d2<-c(4,1,5,2)
y = array(runif(prod(d2)),d2)
op<-'*'
BSXFUN(op,x,y)
#example 3
d1<-c(1,2,5,6,3)
x<-array(1:prod(d1),d1)
d2<-c(1,2,5,1,3,4)
y<-array(1:prod(d2),d2)
op<-'+'
BSXFUN(op,x,y)
Run the code above in your browser using DataLab