Ian Jauslin
summaryrefslogtreecommitdiff
blob: 7d95a2e399ee86ad03d93ff07f65216606c690c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
Copyright 2015-2022 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.
*/

/*
Polynomials can be represented in a grouped way, by putting the terms
 proportional to the same monomial together.

The main part of a grouped polynomial is the list of coefficients,
 each of which stands for the set of terms proportional to the
 corresponding monomial, specified in indices and labels.

*/

#ifndef GROUPED_POLYNOMIAL_H
#define GROUPED_POLYNOMIAL_H

#include "types.h"

// memory
int init_Grouped_Polynomial(Grouped_Polynomial* gpolynomial, int size);
int free_Grouped_Polynomial(Grouped_Polynomial gpolynomial);

// resize the memory allocated to a grouped polynomial
int resize_grouped_polynomial(Grouped_Polynomial* grouped_polynomial,int new_size);

// copy a grouped polynomial
int grouped_polynomial_cpy(Grouped_Polynomial input, Grouped_Polynomial* output);
int grouped_polynomial_cpy_noinit(Grouped_Polynomial input, Grouped_Polynomial* output);

// append an element to a polynomial
int grouped_polynomial_append(int index, Coefficient coef, Grouped_Polynomial* output);
int grouped_polynomial_append_noinit(int index, Coefficient coef, Grouped_Polynomial* output);

// concatenate two polynomials
int grouped_polynomial_concat(Grouped_Polynomial input, Grouped_Polynomial* output);
int grouped_polynomial_concat_noinit(Grouped_Polynomial input, Grouped_Polynomial* output);

// construct a grouped polynomial from a polynomial, grouping together the terms specified in the id table.
int group_polynomial(Polynomial polynomial, Grouped_Polynomial* grouped_polynomial, Id_Table idtable, Fields_Table fields);
// more naive and faster version in which the terms in polynomial corresponding to a polynomial in the id table are grouped together (does not allow parts of terms to be grouped together)
int group_polynomial_pickandchoose(Polynomial polynomial, Grouped_Polynomial* grouped_polynomial, Id_Table idtable);

// find the entry in the idtable containing monomial
int find_id(Int_Array monomial, Id_Table idtable, int start);

// simplify grouped polynomial
int simplify_grouped_polynomial(Grouped_Polynomial* polynomial);

// differentiate a flow equation with respect to an unknown variable
int flow_equation_derivx(Grouped_Polynomial flow_equation, Int_Array indices, Grouped_Polynomial* dflow);

// print a grouped polynomial
int grouped_polynomial_print(Grouped_Polynomial grouped_polynomial, char lhs_pre, char rhs_pre);

// read from string
int char_array_to_Grouped_Polynomial(Char_Array str, Grouped_Polynomial* output);

// evaluate an equation on an RCC
int evaleq(RCC out, RCC in, Grouped_Polynomial poly);
// evaluate an equation on a vector (using mpfr floats)
int evaleq_mpfr(RCC_mpfr out, RCC_mpfr in, Grouped_Polynomial poly);

// compose two flow equations (replace the rcc's of flow1 by the right hand side of flow2)
int compose_flow_equations(Grouped_Polynomial flow1, Grouped_Polynomial flow2, Grouped_Polynomial* out);
#endif