Is there a "inner" function that takes a function argument. Similar to outer () vs. %o% such that inner (x, y, FUN = function (z1, z2) sum (z1 * z2)) returns the same result as x %*% y? Michael
This is inefficient and its is not precisely the set of arguments you requested but its concise and perhaps its close enough.> inner = function(a,b,f,g) apply(apply(outer(a,b,FUN=g),c(1,4),diag),2:3,f) > a=matrix(1:8,2,4) > b=t(a) > inner(a,b,sum,"*")[,1] [,2] [1,] 84 100 [2,] 100 120> a%*%b[,1] [,2] [1,] 84 100 [2,] 100 120> inner(a,b,all,"==")[,1] [,2] [1,] TRUE FALSE [2,] FALSE TRUE