mult | R Documentation |
Perform a custom multiplication of the matrices x
and y
by
using the callback function f
.
mult(x, y, f, ...)
x |
A first matrix. The number of columns must match with the number of
rows of the |
y |
A second matrix. The number of rows must match with the number of
columns of the |
f |
A function to be applied to the matrices in order to compute the multiplication. It must accept at least two arguments. |
... |
Additional arguments that are passed to the function |
For a matrix x
of size (u,v) and a matrix y
of size
(v,w), mult
calls the function f
uw-times to
create a resulting matrix of size (u,w). Each (i,j)-th element
of the resulting matrix is obtained from a call of the function f
with x
's i-th row and y
's j-th column passed as its arguments.
A matrix with v rows and w columns, where v is the
number of rows of x
and w is the number of columns of y
.
Michal Burda
compose()
x <- matrix(runif(24, -100, 100), ncol=6) y <- matrix(runif(18, -100, 100), nrow=6) mult(x, y, function(xx, yy) sum(xx * yy)) # the same as "x %*% y"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.