// ***************************************** //
// Evaluation Function //
// ***************************************** //
FLOAT FLOAT_POLY::operator()(FLOAT x)
{
FLOAT value;
int i;
if(head==NULL){
//this polynomial is degenerate
value = 0.0;
return(value);
}
else{
//this is Non NULL
FLOAT value = 0.0;
FLOAT product = 1.0;
FLOAT_POLY_CELL* temp = head;
if(temp->next==NULL && temp->power==0){
value = temp->element;
return value;
}
if(temp->next==NULL && temp->power>0){
product = 1;
for(i=0;i<temp->power;++i)
product *= x;
return(product*temp->element);
}
value = temp->element;
while(temp->next!=NULL){
product = 1.0;
for(i=0;i<temp->power-temp->next->power;++i)
product *= x;
value = (temp->next->element+value*product);
temp = temp->next;
}
if(temp->power>0){
product = 1.0;
for(i = 0;i<temp->power;++i)
product *= x;
value *= product;
return value;
}
return(value);
}
}