def function(self,p): height = p.size width = p.aspect_ratio*height return bitwise_or( bitwise_and(bitwise_and( (self.pattern_x-p.x1)<=p.x1+width/4.0, (self.pattern_x-p.x1)>=p.x1-width/4.0), bitwise_and( (self.pattern_y-p.y1)<=p.y1+width/4.0, (self.pattern_y-p.y1)>=p.y1-width/4.0)), bitwise_and(bitwise_and( (self.pattern_x-p.x2)<=p.x2+width/4.0, (self.pattern_x-p.x2)>=p.x2-width/4.0), bitwise_and( (self.pattern_y-p.y2)<=p.y2+width/4.0, (self.pattern_y-p.y2)>=p.y2-width/4.0)))
assert Numeric.allclose(X, Y) print "Raw reduce using pypar.BAND OK" pypar.raw_reduce(testArray, X, pypar.LOR, 0, 0) if myid == 0: Y = Numeric.zeros(N) for i in range(numproc): Y = Numeric.logical_or(Y, Numeric.array(range(N))*(i+1)) assert Numeric.allclose(X, Y) print "Raw reduce using pypar.LOR OK" pypar.raw_reduce(testArray, X, pypar.BOR, 0, 0) if myid == 0: Y = Numeric.zeros(N) #Neutral element for | for i in range(numproc): Y = Numeric.bitwise_or(Y, Numeric.array(range(N))*(i+1)) assert Numeric.allclose(X, Y) print "Raw reduce using pypar.BOR OK" pypar.raw_reduce(testArray, X, pypar.LXOR, 0, 0) if myid == 0: Y = Numeric.zeros(N) for i in range(numproc): Y = Numeric.logical_xor(Y, Numeric.array(range(N))*(i+1)) assert Numeric.allclose(X, Y) print "Raw reduce using pypar.LXOR OK" pypar.raw_reduce(testArray, X, pypar.BXOR, 0, 0) if myid == 0: Y = Numeric.zeros(N) #Neutral element for xor ? for i in range(numproc):