#include <kv/strobomap.hpp>
#include <kv/kraw-approx.hpp>

namespace ub = boost::numeric::ublas;

typedef kv::interval<double> itv;

struct Func {
	template <class T> ub::vector<T> operator() (const ub::vector<T>& x, T t){
		ub::vector<T> y(2);

		y(0) = - x(1) + 1;
		y(1) = x(0) - 1;

		return y;
	}
};

template <class F> struct Tmp {
	F f;
	Tmp(F f): f(f) {}
	template <class T> ub::vector<T> operator() (const ub::vector<T>& x){
		ub::vector<T> y(2);
		y = f(x);
		y(0) -= 1.;
		y(1) -= 0.;
		return y;
	}
};

int main()
{
	ub::vector<double> x;
	ub::vector<itv> ix;
	bool r;

	std::cout.precision(17);

	Func f;
	kv::StroboMap<Func,double> g(f, (itv)0., (itv)1.);
	Tmp< kv::StroboMap<Func,double> > h(g);

	x.resize(2);
	x(0) = 0;
	x(1) = 0.5;
	r = kv::krawczyk_approx(h, x, ix, 3);
	if (r) std::cout << "Solution Found\n";
}
