nms1 <- letters[1:4]
mat1 <- matrix(1:8, nrow=4, ncol=4, dimnames=list(nms1, nms1))
nms2 <- letters[2:3]
mat2 <- matrix(11:18, nrow=2, ncol=4, dimnames=list(nms2, nms1))
matrix_op(mat1, mat2)
matrix_op(mat1, mat2, `*`)
Run the code above in your browser using DataLab