update file structure
This commit is contained in:
27
src/reducer.c
Normal file
27
src/reducer.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* reduce.c */
|
||||
|
||||
#include "computorv1.h"
|
||||
|
||||
void reduce(s_term *terms, double *polynom)
|
||||
{
|
||||
int i;
|
||||
int exponent;
|
||||
double tmp;
|
||||
|
||||
i = 0;
|
||||
while (terms[i].position != TERM_END)
|
||||
{
|
||||
// get coefficient with left sign
|
||||
tmp = terms[i].coefficient;
|
||||
if (terms[i].position == TERM_RIGHT)
|
||||
{
|
||||
tmp *= -1;
|
||||
}
|
||||
|
||||
// add coefficient to exponent
|
||||
exponent = terms[i].exponent;
|
||||
polynom[exponent] += tmp;
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user