MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: checking for overlap

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20110] Re: [mg20065] checking for overlap
  • From: "Andrzej Kozlowski" <andrzej at tuins.ac.jp>
  • Date: Thu, 30 Sep 1999 02:43:17 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Here is one way:

In[1]:=
overlapcheck[ints_, tvals_] := 
  Outer[IntervalMemberQ, Map[Interval, ints], tvals]

e.g.

In[2]:=
ints = {{-1, 1}, {0, 1}, {2, 4}, {3, 4}};
tvals = {0, 1.5, 3};

In[3]:=
overlapcheck[ints, tvals]
Out[3]=
{{True, False, False}, {True, False, False}, {False, False, True}, {False,
    False, True}}

You may prefer the answer in transposed form:

In[4]:=
Transpose[%]
Out[4]=
{{True, True, False, False}, {False, False, False, False}, {False, False,
    True, True}}

This means that 0 is in the interval {-1, 1}, is in {0, 1}, is not in {2, 4}
and {3, 4} and so on ...

--
Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp
http://eri2.tuins.ac.jp


----------
>From: dennisw555 at aol.com (DennisW555)
>To: mathgroup at smc.vnet.net
>Subject: [mg20110] [mg20065] checking for overlap
>Date: Wed, Sep 29, 1999, 16:33
>

> I am looking for an elegant way of checking for overlap.
>
> Suppose I have a set of time intervals given by
> ints = {{t1,t2},{t3,t4},{t5,t6}. ...} and another set of times
> tvals = {u1,u2,u3, ...}.
>  What is a fast, elegant way of checking which of the tvals is within any of
> the ints time intervals?
>
> Thanks,
> Dennis
> 


  • Prev by Date: RE: checking for overlap
  • Next by Date: Allow only Variables >=0
  • Previous by thread: RE: checking for overlap
  • Next by thread: Re: checking for overlap