diff options
Diffstat (limited to 'src/coefficient.h')
-rw-r--r-- | src/coefficient.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/coefficient.h b/src/coefficient.h new file mode 100644 index 0000000..a7a151c --- /dev/null +++ b/src/coefficient.h @@ -0,0 +1,78 @@ +/* +Copyright 2015 Ian Jauslin + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/* +Coefficients represent the collection of terms which appear + on the right hand side of a single flow equation. + +They are used as an elementary building block of grouped polynomials. +*/ + +#ifndef COEFFICIENT_H +#define COEFFICIENT_H + +#include "types.h" + +// allocate memory +int init_Coefficient(Coefficient* coef,int size); +// free memory +int free_Coefficient(Coefficient coef); + +// copy a coefficient +int coefficient_cpy(Coefficient input, Coefficient* output); +int coefficient_cpy_noinit(Coefficient input, Coefficient* output); + +// resize the memory allocated to a coefficient +int resize_Coefficient(Coefficient* coefficient,int new_size); + +// append an element to a coefficient +int coefficient_append(Int_Array factor,Number num, coef_denom denom, Coefficient* output); +int coefficient_append_noinit(Int_Array factor, Number num, coef_denom denom, Coefficient* output); + +// concatenate coefficients and simplify result +int coefficient_concat(Coefficient input, Coefficient* output); +int coefficient_concat_noinit(Coefficient input, Coefficient* output); + +// simplify a Coefficient +int coefficient_simplify(Coefficient* coefficient); +// sort the terms in an equation (quicksort algorithm) +int sort_coefficient(Coefficient* coefficient, int begin, int end); +// exchange two terms (for the sorting algorithm) +int exchange_coefficient_terms(int i, int j, Coefficient* coefficient); + +// derive a coefficient with respect to an index (as a polynomial) (does not derive the 1/(1+C)^p ) +int coefficient_deriv_noinit(Coefficient input, int index, Coefficient* output); +int coefficient_deriv(Coefficient input, int index, Coefficient* output); + +// product of two coefficients +int coefficient_prod(Coefficient coef1, Coefficient coef2, Coefficient* output); +// product of coefficients, output replaces the second coefficient +int coefficient_prod_chain(Coefficient in, Coefficient* inout); + +// print coefficient +int coefficient_sprint(Coefficient coef, Char_Array* output, int offset, char index_pre); + +// read from a string +int char_array_to_Coefficient(Char_Array str_coef, Coefficient* output); +int str_to_Coefficient(char* str, Coefficient* output); + +// compare coefficient denominators +int coef_denom_cmp(coef_denom denom1, coef_denom denom2); + +// evaluate a coefficient on a vector +int evalcoef(RCC rccs, Coefficient coef, long double* out); + +#endif |