Questions tagged [vectorization]
Use this tag if your code contains vectorized operations - where functions operate on whole arrays in one go. If it doesn't, but you want it to, then you should make those changes (perhaps with help from elsewhere) before presenting code for review.
103 questions
4
votes
1
answer
437
views
Bernoulli trials using a condition in a vectorized operation
I was wondering how to vectorize the following code instead of using the for-loop and still be able to check for a condition.
...
3
votes
2
answers
493
views
Calculating mesh centers runs very slowly
I have a piece of code that is used to calculate the cell centers in a rectangular mesh. The mesh size is pretty large (650 columns by 1150 rows). The code runs very slowly. I was wondering if I could ...
5
votes
1
answer
496
views
Vectorize Matlab sum
I have the following Matlab function:
function [res] = a3_funct(x)
res = 0;
for i = 1:size(x,1)
res = res + abs(x(i))^(i+1);
end
end
It's ...