#include "Sundance.h"
#include "ADExpr.h"
#include "ADParameter.h"
#include "ADUnknownFunction.h"
#include "ADDerivative.h"
#include "Group.h"
#include "ADCoordExpr.h"

int main(int argc, void** argv)
{
  try
    {
      Sundance::init(&argc, &argv);

      ADExpr u = new ADUnknownFunction("u");
      ADExpr v = new ADUnknownFunction("v");
      ADExpr w = new ADUnknownFunction("w");

      ADExpr x = new ADCoordExpr(0);
      ADExpr y = new ADCoordExpr(1);

      ADExpr Dx = new ADDerivative(0);
      ADExpr Dy = new ADDerivative(1);

      TSFArray<ADExpr> tests;
      tests.append(u);
      tests.append(Dx*(u*y));
      tests.append(Dx*(2.0*u*x));
      tests.append(Dx*(u*2.0));
      tests.append(Dx*(u*v));
      ADExpr::simplifyHungryDiffOps() = false;
      tests.append(u*v*w*Dx*v);
      ADExpr::simplifyHungryDiffOps() = true;
      tests.append(u*v*w*Dx*v);
      tests.append(v*Dx*(u*v));

      for (int i=0; i<tests.length(); i++)
        {
          TSFHashtable<FuncSpec, bool> funcInfo;
          tests[i].getFunctionalDependencies(funcInfo);
          cerr << endl << tests[i] << " " << funcInfo << endl;
        }



    }
  catch(exception& e)
    {
      TSFOut::println(e.what());
      Testing::crash(__FILE__);
      Testing::timeStamp(__FILE__, __DATE__, __TIME__);
    }
  Sundance::finalize();
}

