// ******************************************** //
// insert and sort a term in the polynomial //
// ******************************************** //
int FLOAT_POLY::insert(FLOAT new_element,unsigned int q)
{
FLOAT_POLY_CELL *current = get_element_address(q);
if(current!=NULL){//power q is in polynomial
current->element += new_element;
}
else{//power q is not in polynomial so add to head
//create new poly cell
FLOAT_POLY_CELL *after = new FLOAT_POLY_CELL(new_element,q);
current = head;
after->next = current;
head = after;
}
//now sort polynomial to get in right order.
mergesort();
}
// ************************************************* //
// insert a term in the polynomial w/o sorting //
// ************************************************* //
int FLOAT_POLY::insert_nosort(FLOAT new_element,unsigned int q)
{
FLOAT_POLY_CELL *current = get_element_address(q);
if(current!=NULL){//power q is in polynomial
current->element += new_element;
}
else{//power q is not in polynomial so add to head
//create new poly cell
FLOAT_POLY_CELL *after = new FLOAT_POLY_CELL(new_element,q);
current = head;
after->next = current;
head = after;
}
}