libmonaa  0.5.2
Classes | Functions
interval.hh File Reference

The implementation of the class Interval and related functions. More...

#include <cmath>
#include "zone.hh"
Include dependency graph for interval.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Interval
 Class for an interval. More...
 

Functions

static Interval operator&& (const Interval &left, const Interval &right)
 The intersection of two intervals.
 
static void land (std::vector< std::shared_ptr< Interval >> &left, const Interval &right)
 The intersection of a set of intervals and an interval. More...
 
static void land (std::vector< std::shared_ptr< Interval >> &left, const std::vector< std::shared_ptr< Interval >> &right)
 The intersection of two sets of intervals. More...
 
static Interval operator+ (Interval left, const Interval &right)
 The sum of two intervals. The formal definition is as follows. More...
 
static void operator+= (std::vector< std::shared_ptr< Interval >> &left, const std::vector< std::shared_ptr< Interval >> &right)
 The sum of two sets of intervals. More...
 
void plus (std::vector< std::shared_ptr< Interval >> &intervals)
 
static std::ostream & operator<< (std::ostream &stream, const Interval &interval)
 

Detailed Description

The implementation of the class Interval and related functions.

Author
Masaki Waga

Function Documentation

◆ land() [1/2]

static void land ( std::vector< std::shared_ptr< Interval >> &  left,
const Interval right 
)
inlinestatic

The intersection of a set of intervals and an interval.

Note
This function is destructive.
Parameters
[in,out]leftThe set of intervals. We take intersection for each element of left and overwrite.
[in]rightThe interval.

We have the following relation between the input and the overwritten value of \(\texttt{left}\).

\[t \in \bigcup_{I \in \texttt{left}_{\mathrm{post}}} I \iff t \in \bigcup_{I \in \texttt{left}_{\mathrm{pre}}} (I \cap \texttt{right})\]

◆ land() [2/2]

static void land ( std::vector< std::shared_ptr< Interval >> &  left,
const std::vector< std::shared_ptr< Interval >> &  right 
)
inlinestatic

The intersection of two sets of intervals.

Note
This function is destructive.
Parameters
[in,out]leftThe set of intervals. We take intersection for each element of left and overwrite.
[in]rightA set of interval. This is not overwritten.

We have the following relation between the input and the overwritten value of \(\texttt{left}\).

\[t \in \bigcup_{I \in \texttt{left}_{\mathrm{post}}} I \iff t \in \bigcup_{I \in \texttt{left}_{\mathrm{pre}}, I' \in \texttt{right}} (I \cap I')\]

◆ operator+()

static Interval operator+ ( Interval  left,
const Interval right 
)
inlinestatic

The sum of two intervals. The formal definition is as follows.

\[I + I' = \{t + t' \mid \exists t \in I, t' \in I'\}\]

◆ operator+=()

static void operator+= ( std::vector< std::shared_ptr< Interval >> &  left,
const std::vector< std::shared_ptr< Interval >> &  right 
)
inlinestatic

The sum of two sets of intervals.

Note
This function is destructive.
Parameters
[in,out]leftThe set of intervals. We take sum for each element of left and overwrite.
[in]rightA set of interval. This is not overwritten.

We have the following for any \(t \in \mathbb{R}\).

\[t \in \bigcup_{I \in \texttt{left}_{\mathrm{post}}} I \iff \exists t' \in \bigcup_{I \in \texttt{left}_{\mathrm{pre}}}, \exists t'' \in \bigcup_{I' \in \texttt{right}}. t = t' + t'' \]

◆ plus()

void plus ( std::vector< std::shared_ptr< Interval >> &  intervals)
inline
Todo:
Optimization: We can use * - 0 instead of cup of +