#include "AnT.hpp"

#define a     parameters[0]
#define X     currentContinuousState[0]
#define mode  currentDiscreteState[0]
#define LEFT  1
#define RIGHT 2

bool tent_map_C (const Array<real_t>& currentContinuousState,
		 const Array<int>& currentDiscreteState,
		 const Array<real_t>& parameters,
		 Array<real_t>& RHS)
{
  if (mode == LEFT)
    RHS[0] = a * X;
  else
    RHS[0] = a * (1 - X);

  return true;
}

bool tent_map_D (const Array<real_t>& currentContinuousState,
		 const Array<int>& currentDiscreteState,
		 const Array<real_t>& parameters,
		 Array<int>& RHS)
{
    if (X < 0.5)
	RHS[0] = LEFT;
    else
	RHS[0] = RIGHT;

    return true;
}

#undef a
#undef X    
#undef mode 
#undef LEFT 
#undef RIGHT

extern "C" 
{

void connectSystem ()
{
  HybridMapProxy::systemFunction = tent_map_C;
  HybridMapProxy::hybridFunction = tent_map_D;
}

}





