Skip to content

Instantly share code, notes, and snippets.

@DexGroves
Created January 12, 2017 14:52
Show Gist options
  • Save DexGroves/97873d19e054eaf0356e718ba2b80d0c to your computer and use it in GitHub Desktop.
Save DexGroves/97873d19e054eaf0356e718ba2b80d0c to your computer and use it in GitHub Desktop.
M1 <- matrix(seq(16), nrow = 4, ncol = 4)
M2 <- matrix(seq(16), nrow = 4, ncol = 4)
M1 * M2
M1 %*% M2
`*` <- function(lhs, rhs) {
if (is.matrix(lhs) & is.matrix(rhs)) {
return(lhs %*% rhs)
}
base::`*`(lhs, rhs)
}
M1 * M2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment