/* -*- C++ -*-
*
* This file is a part of LEMON, a generic C++ optimization library
*
* Copyright (C) 2003-2006
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
* (Egervary Research Group on Combinatorial Optimization, EGRES).
*
* Permission to use, modify and distribute this software is granted
* provided that this copyright notice appears in all copies. For
* precise terms see the accompanying LICENSE file.
*
* This software is provided "AS IS" with no warranty of any kind,
* express or implied, and with no claim as to its suitability for any
* purpose.
*
*/
#include
#include
#include
#include "test_tools.h"
using namespace std;
using namespace lemon;
int main()
{
Polynomial pi(5);
check(pi.deg()==5,"Something is wrong here.");
pi[0]=12;
pi[5]=3;
pi[2]=7;
check(pi[1]==0,"Uninitialized elements should be(?) zero.");
{
Polynomial pd=pi;
check(pd.deg()==5,"Something is wrong here.");
check(pd[0]==12,"Something is wrong here.");
check(pd[5]==3,"Something is wrong here.");
}
Polynomial pd;
pd=pi;
check(pd.deg()==5,"Something is wrong here.");
check(pd[0]==12,"Something is wrong here.");
check(pd[5]==3,"Something is wrong here.");
check(pd(0)==12,"Something is wrong here.");
check(pd(1)==22,"Something is wrong here.");
check(pd(2)==136,"Something is wrong here.");
check((pd*pi).deg()==10,"Something is wrong here.");
check((pd*pi)[10]==9,"Something is wrong here.");
check((pd*pi)[7]==42,"Something is wrong here.");
Polynomial pd2=pd+pi;
check(pd2[5]==6,"Something is wrong here.");
pd2+=pd;
pd2+=pi;
check(pd2[5]==12,"Something is wrong here.");
pd2-=pd;
pd2-=pi;
check(pd2[5]==6,"Something is wrong here.");
check((pd-pi)[5]==0,"Something is wrong here.");
Polynomial pdd=pd.derivate();
pd.derivateMyself();
check(pdd==pd,"Something is wrong here.");
check(pd.deg()==4,"Something is wrong here.");
check(pd[4]==15,"Something is wrong here.");
Polynomial pdi=pd.integrate();
pd.integrateMyself();
check(pdi==pd,"Something is wrong here.");
check(pd.deg()==5,"Something is wrong here.");
check(pd[5]==3,"Something is wrong here.");
check(pd[0]==0,"Something is wrong here.");
}