Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/grouped_polynomial.c')
-rw-r--r--src/grouped_polynomial.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/grouped_polynomial.c b/src/grouped_polynomial.c
index b7bea42..0d4d75d 100644
--- a/src/grouped_polynomial.c
+++ b/src/grouped_polynomial.c
@@ -732,7 +732,7 @@ int char_array_to_Grouped_Polynomial(Char_Array str, Grouped_Polynomial* output)
}
-// evaluate an equation on a vector
+// eValuate an equation on a vector
int evaleq(RCC* rccs, Grouped_Polynomial poly){
int i;
long double* res=calloc((*rccs).length,sizeof(long double));
@@ -762,4 +762,32 @@ int evaleq(RCC* rccs, Grouped_Polynomial poly){
return(0);
}
+// evaluate an equation on a vector (using mpfr floats)
+int evaleq_mpfr(RCC_mpfr* rccs, Grouped_Polynomial poly){
+ int i;
+ mpfr_t* res;
+
+ if((*rccs).length!=poly.length){
+ fprintf(stderr, "error: trying to evaluate an flow equation with %d components on an rcc with %d\n",poly.length,(*rccs).length);
+ exit(-1);
+ }
+
+ res=calloc((*rccs).length,sizeof(mpfr_t));
+
+ // for each equation
+ for(i=0;i<poly.length;i++){
+ evalcoef_mpfr(*rccs, poly.coefs[i], res[i]);
+ }
+
+ // copy res to rccs
+ for(i=0;i<(*rccs).length;i++){
+ mpfr_set((*rccs).values[i], res[i], MPFR_RNDN);
+ mpfr_clear(res[i]);
+ }
+
+ // free memory
+ free(res);
+ return(0);
+}
+