Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Q: Vectorizing loop conditions
Posted:
Aug 7, 1996 7:38 PM


I am trying to vectorize some old Fortran code and have run into a problem. In the finite difference grid, the code checks that it hasn't run into boundaries and so, depending on the component being computed, it tests whether (bth(i,j)>0 & bth(i+1,j)>0) or (bth(i,j)>0 & bth(i,j+1)>0).
I have settled on making a mask of valid bth locations with bthz(2:in,2:jn)=~(bth(2:in,2:jn)<0 & bth(3:ie,2:jn)<0) for example. That makes a zero mask that I then multiply by the terms of the equation. Not very elegant, but it works in a crude way. It calculates the edge terms (near the boundaries) which I don't want to do.
Any ideas on vectorizing the conditional bth test(s) so that the subsequent vectorized loop runs efficiently?
Thanks in advance.



