@@ -351,7 +351,7 @@ def distance(self, other):
351351 # E.g., `self=R<f,[x + 2]>` and `other=W<f,[i + 1]>`
352352 # E.g., `self=R<f,[x]>`, `other=W<f,[x + 1]>`,
353353 # `self.itintervals=(x<0>,)`, `other.itintervals=(x<1>,)`
354- return vinf (ret )
354+ return v_undef (ret )
355355 except AttributeError :
356356 # E.g., `self=R<f,[cy]>` and `self.itintervals=(y,)` => `sai=None`
357357 pass
@@ -413,10 +413,12 @@ def distance(self, other):
413413 # E.g., `self=R<f,[x, y]>`, `sai=time`,
414414 # `self.itintervals=(time, x, y)`, `n=0`
415415 continue
416+ elif not sai or not oai :
417+ return v_undef (ret , val = S .NaN )
416418 else :
417419 # E.g., `self=R<u,[t+1, ii_src_0+1, ii_src_1+2]>`, `fi=p_src`,
418420 # and `n=1`
419- return vinf (ret )
421+ return v_undef (ret )
420422
421423 n = len (ret )
422424
@@ -640,7 +642,11 @@ def cause(self):
640642 """Return the findex causing the dependence."""
641643 for i , j in zip (self .findices , self .distance ):
642644 try :
643- if j > 0 :
645+ # If j is S.Infinity, then the direction was not defined
646+ # so we treat it as non cause.
647+ if j is S .NaN :
648+ continue
649+ elif j > 0 :
644650 return i ._defines
645651 except TypeError :
646652 # Conservatively assume this is an offending dimension
@@ -1353,8 +1359,8 @@ def is_regular(self):
13531359
13541360# *** Utils
13551361
1356- def vinf (entries ):
1357- return Vector (* (entries + [S . Infinity ]))
1362+ def v_undef (entries , val = S . Infinity ):
1363+ return Vector (* (entries + [val ]))
13581364
13591365
13601366def retrieve_accesses (exprs , ** kwargs ):
0 commit comments