Reputation: 159
I want to perform index-wise operation on a matrix. I know that you can write a regular function and perform it on each entry of the matrix e.g.
function foo(x::Int64)
return x * 2
end
myArray = [1 2 3; 4 5 6]
foo.(myArray)
how would I go about doing something like x * x.elementCol + x.elementrow
? essentially the following code in parallel:
function goo(x::Array{Int64,2})
for j = 1:size(x,2)
for i = 1:size(x,1)
x[i,j] = (x[i,j] * j) + i
end
end
return x
end
Upvotes: 1
Views: 75