Given
X = [x0,x1,...,xN];
Y = [y0,y1,...,yM];
function result = f(x, y)
... % Cannot use broadcasting. Must take values. Returns a value.
end
I want to get a matrix
f(x0,y0) f(x0,y1) ... f(x0,yM)
f(x1,y0) f(x1,y1) ... f(x1,yM)
... ... ... ...
f(xN,y0) f(xN,y1) ... f(xN,yN)
I know I can just use two nested for
loops, but is there something that could parallelize this? Something with interface similar to arrayfun
?
For those curious about f
function:
X = [some vector]
W = [some vector]
p(w) % returns a real number; for given vector, returns a vector
g(x, w) % returns value from X; can use broadcasting just like (x .* w).
function result = f(x, y) % takes 2 values from X
result = sum( p( W( g(x,W) == y ) ) );
% | | - boolean vector
% | | - vector of some values from W
% | | - vector of some real values
% | | - a single value
end