Пример #1
0
//----------------------------------------------------------------------
bool Disjoint(const box& X, const box& Y)
{
	if (X.IsEmpty() || Y.IsEmpty()) return true;
	for (int i = 1; i <= Size(X); i++)
		if (Disjoint(X[i], Y[i])) return true;
	return false;
}
Пример #2
0
//----------------------------------------------------------------------
double Eloignement(box& X, box& Y)
{
	if ((X.IsEmpty()) || (Y.IsEmpty())) return oo;
	double e = 0;
	for (int k = 1; k <= Size(X); k++) { e = max(e, Eloignement(X[k], Y[k])); }
	return e;
}
Пример #3
0
//----------------------------------------------------------------------
bool SubsetStrict(box& X, box& Y)
{
	if (Y.IsEmpty()) return false;
	if (X.IsEmpty()) return true;
	bool b = true;
	for (int k = 1; k <= Size(X); k++) b = b && SubsetStrict(X[k], Y[k]);
	return (b);
}
Пример #4
0
//----------------------------------------------------------------------
interval NormInf(box X, box Y)
{
	if (Size(X) != Size(Y)) return interval();
	if (X.IsEmpty() || Y.IsEmpty()) return interval();
	interval ans = Abs(Y[1] - X[1]);
	for (int i = 1; i <= Size(X); i++) ans = Max(ans, Abs(Y[i] - X[i]));
	return ans;
}
Пример #5
0
//----------------------------------------------------------------------
double Marge(box X, box Y)
{
	if ((X.IsEmpty()) || (Y.IsEmpty())) return -oo;
	double ans = Marge(X[1], Y[1]);
	for (int i = 2; i <= Size(X); i++)
		ans = min(ans, Marge(X[i], Y[i]));
	return ans;
}
Пример #6
0
//----------------------------------------------------------------------
box Union(const box& X, const box& Y)
{
	box Ans(max(Size(X), Size(Y)));
	if (X.IsEmpty()) return (Y);
	if (Y.IsEmpty()) return (X);
	for (int k = 1; k <= Size(Ans); k++)  Ans[k] = Union(X[k], Y[k]);
	return Ans;
}
Пример #7
0
//------------------------------------------------------------------------------
bool Prop(box& X, box& Y)  // Normalement X is a subset of y (used in SIVEX)
{
	if (X.IsEmpty()) return false;
	if (Y.IsEmpty()) return false;
	for (int k = 1; k <= Size(X); k++)
		if ((X[k].inf == Y[k].inf)||(X[k].sup == Y[k].sup)) return (true);
	return false;
}
Пример #8
0
//----------------------------------------------------------------------
interval NormEuclid(box X, box Y)
{
	if (Size(X) != Size(Y)) return interval();
	if (X.IsEmpty() || Y.IsEmpty()) return interval();
	interval r = 0;
	for (int i = 1; i <= Size(X); i++) r = r + Sqr(Y[i] - X[i]);
	return (Sqrt(r));
}
Пример #9
0
//----------------------------------------------------------------------
box Inter(const box& X, const box& Y)
{
	box Ans(Size(X));
	if ((X.IsEmpty()) || (Y.IsEmpty())) { return Ans; }
	for (int k = 1; k <= Size(Ans); k++)
	{
		Ans[k] = Inter(X[k], Y[k]);
		if (Ans[k].isEmpty) { Update(Ans); return Ans; }
	}
	return Ans;
}
Пример #10
0
//-----------------------------------------------------------------------
// Produit Cartesien ou Concatenation de deuX paves X et y :
// Ans=[X,Y]     =>     Ans=Concat(X,Y); 
box Concat(const box& X, const box& Y)
{
	double dim = X.dim + Y.dim; box Ans((int)dim);
	if ((!X.IsEmpty()) && (!Y.IsEmpty()))
	{
		for (int i = 1; i <= dim; i++)
		{
			if (i <= Size(X)) Ans[i] = X[i]; else Ans[i] = Y[i - X.dim];
		}
	}
	return Ans;
}
Пример #11
0
//----------------------------------------------------------------------
iboolean In(box X, box Y)
{
	if (X.IsEmpty() || Y.IsEmpty()) return ifalse;
	iboolean r = itrue;
	for (int k = 1; k <= X.dim; k++)
	{
		iboolean in1 = In(X[k], Y[k]);
		if (in1 == false) return ifalse;
		else if (in1.value == iperhaps) r = iperhaps;
	}
	return r;
}
Пример #12
0
//----------------------------------------------------------------------
interval Norm(box X)
{
	if (X.IsEmpty()) return interval();
	interval r = 0;
	for (int i = 1; i <= Size(X); i++) r = r + Sqr(X[i]);
	return (Sqrt(r));
}
Пример #13
0
//----------------------------------------------------------------------
box Rand(const box& X)
{
	int sizeX = Size(X); box Ans(sizeX);
	//if (X.IsEmpty()) Ans = Empty(sizeX);
	if (X.IsEmpty()) Ans = EmptyBox(X);
	else { for (int k = 1; k <= sizeX; k++) Ans[k] = Rand(X[k]); }
	return Ans;
}
Пример #14
0
//----------------------------------------------------------------------
void Cnotin(box& X, const box& Y)
{
	int notindim = -1;
	if (Y.IsEmpty()) return;
	if (X.IsEmpty()||(In(X, Y) == itrue))
	{
		X = box();
		return;
	}
	for (int i = 1; i <= Size(X); i++)
	{ 
		if (In(X[i], Y[i]) != itrue) 
		{
			if (notindim != -1) return; else notindim = i;
		}
	}
	Cnotin(X[notindim], Y[notindim]);
}
Пример #15
0
//-----------------------------------------------------------------------
bool IsBox(box X)
{
	if (X.IsEmpty()) return false;
	for (int i = 1; i <= Size(X); i++)
	{
		if (Width(X[i]) == 0) return false;
	}
	return true;
}
Пример #16
0
//----------------------------------------------------------------------
// Projection du pave X dans un espace de dimension dim=(j-i)+1;
// X=[[X1],[X2],..,[Xi],..,[Xj],..[Xn]]
// =>  Proj(X,i,j)=[[Xi],..,[Xj]] et Proj(X,i,i)=[Xi]
box Proj(const box& X, int i, int j)
{
	int dim = abs(j - i) + 1; box Ans(dim);
	if (!X.IsEmpty())
	{
		int lb = min(i, j);
		for (int k = 1; k <= dim; k++) Ans[k] = X[k + lb - 1];
	}
	return Ans;
}
Пример #17
0
//------------------------------------------------------------------------------
double EloignementRelatif2(box& X, box& Y)
{
	// prend le point X1 de X qui est le plus eloigne de [Y] et renvoie la
	// distance de X1 avec [Y]
	Update(X); Update(Y);
	if (Subset(X, Y)) return 0;
	if (Y.IsEmpty()) return oo;
	double e = 0;
	for (int k = 1; k <= X.dim; k++)
	{
		double e1 = 0;
		double Xinf = X[k].inf;
		double Xsup = X[k].sup;
		double Yinf = Y[k].inf;
		double Ysup = Y[k].sup;
		if (Xsup > Ysup) e1 = max(e1, fabs((Xsup - Ysup) / Ysup));
		if (Xinf < Yinf) e1 = max(e1, fabs((Yinf - Xinf) / Yinf));
		e = max(e, e1);
	}
	return e;
}