PIPS
polynome-local.h
Go to the documentation of this file.
1 /*
2 
3  $Id: polynome-local.h 1641 2016-03-02 08:20:19Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of Linear/C3 Library.
8 
9  Linear/C3 Library is free software: you can redistribute it and/or modify it
10  under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  Linear/C3 Library is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with Linear/C3 Library. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 /*
26  *
27  * SYMBOLIC POLYNOMIALS P. Berthomier 02-08-90
28  *
29  * L. Zhou Apr.8,91
30  *
31  *
32  * This package contains some routines manipulating symbolic polynomials
33  * with any number of variables. It uses the packages vecteur and arithmetique.
34  *
35  * There are routines for allocation/duplication/destruction, input/output,
36  * "factorization", variable substitution, integer power exponentiation,
37  * addition, multiplication, integration of polynomials.
38  *
39  * The package lacks: division by a one-variable polynomial, comparison
40  * of two polynomials (when possible), ...
41  *
42  *
43  * POLYNOMIAL STRUCTURE
44  *
45  *
46  * We use a Pvecteur structure to represent a sort of "normalized monomial":
47  * a product of powers of variables without scalar coefficient.
48  *
49  * The field "Variable" of the Pvecteur is a pointer to the variable
50  * We only use pointer equality, so if two different pointers
51  * refer to the same variable, the polynomials won't be normalized:
52  * things such as 2*N + 3*N may appear.
53  * The field "Value" contains the integer exponent of that unknown
54  * in that monomial.
55  *
56  * We add a floating-point coefficient to form a complete monomial
57  * structure: a *Pmonome.
58  *
59  * We define a polynomial as an unsorted list of monomial structure.
60  *
61  *
62  *
63  * Example of Pmonome: 2 * X^2.Y.Z^3
64  * (the "@" below means: beginning of a pointer)
65  *
66  *
67  * -----------
68  * Pmonome @------> | 2 | (coeff:float)
69  * |---------|
70  * | @ | (term:Pvecteur)
71  * ---- | ----
72  * |
73  * V
74  * / -----------
75  * | | Y , 1 |
76  * | -----------
77  * Pvecteur | | Z , 3 |
78  * | -----------
79  * | | X , 2 |
80  * \ -----------
81  *
82  *
83  *
84  * Example of Ppolynome: 6 * N^3.k + 3 * N.k - 2
85  *
86  * ----------- ----------- -----------
87  * Ppolynome:@----> | @-------> | @-------> | / | (succ:Ppolynome)
88  * |---------| |---------| |---------|
89  * | @ | | @ | | @ | (monome:Pmonome)
90  * ---- | ---- ---- | ---- ---- | ----
91  * | | |
92  * V V V
93  * / ----------- ----------- -----------
94  * | | 6 | | 3 | | -2 |
95  * Pmonomes | ----------- ----------- -----------
96  * | | @ | | @ | | @ |
97  * \ ---- | ---- ---- | ---- ---- | ----
98  * | | |
99  * V V V
100  * / ----------- ----------- -----------
101  * | | N , 3 | | N , 1 | | TCST, 1 |
102  * Pvecteurs| ----------- ----------- -----------
103  * | | k , 1 | | k , 1 |
104  * \ ----------- -----------
105  *
106  * Nul polynomials are represented by a fixed pointer: POLYNOME_NUL.
107  * Undefined polynomials are represented by POLYNOME_UNDEFINED.
108  *
109  * The package is cut into ten files:
110  *
111  * pnome-types.h
112  * polynome.h (This file. Automatically generated from pnome-types.h)
113  *
114  * pnome-alloc.c
115  * pnome-bin.c
116  * pnome-error.c
117  * pnome-io.c
118  * pnome-private.c
119  * pnome-reduc.c
120  * pnome-scal.c
121  * pnome-unaires.c
122  *
123  *
124  */
125 
126 
127 #ifndef POLYNOME_INCLUDED
128 #define POLYNOME_INCLUDED
129 
130 typedef struct Smonome {
131  float coeff;
134 
135 typedef struct Spolynome {
137  struct Spolynome *succ;
139 
140 
141 /* Macros definitions */
142 #define monome_coeff(pm) ((pm)->coeff)
143 #define monome_term(pm) ((pm)->term)
144 #define polynome_monome(pp) ((pp)->monome)
145 #define polynome_succ(pp) ((pp)->succ)
146 /*
147 #define is_single_monome(pp) ((POLYNOME_NUL_P(pp)) || (POLYNOME_NUL_P(polynome_succ(pp))))
148 */
149 #define is_single_monome(pp) ((!POLYNOME_NUL_P(pp)) && (POLYNOME_NUL_P(polynome_succ(pp))))
150 
151 #define monome_constant_new(coeff) make_monome(coeff, TCST, 1)
152 #define monome_power1_new(coeff, var) make_monome(coeff, var, 1)
153 
154 /* Null/undefined, monomial/polynomial definitions */
155 #define MONOME_NUL ((Pmonome) -256)
156 #define MONOME_NUL_P(pm) ((pm)==MONOME_NUL)
157 #define MONOME_UNDEFINED ((Pmonome) -252)
158 #define MONOME_UNDEFINED_P(pm) ((pm)==MONOME_UNDEFINED)
159 #define MONOME_CONSTANT_P(pm) (term_cst((pm)->term))
160 
161 #define POLYNOME_NUL ((Ppolynome) NULL)
162 #define POLYNOME_NUL_P(pp) ((pp)==POLYNOME_NUL)
163 #define POLYNOME_UNDEFINED ((Ppolynome) -248)
164 #define POLYNOME_UNDEFINED_P(pp) ((pp)==POLYNOME_UNDEFINED)
165 
166 #define MONOME_COEFF_MULTIPLY_SYMBOL "*"
167 #define MONOME_VAR_MULTIPLY_SYMBOL "."
168 #define POLYNOME_NUL_SYMBOL "0"
169 #define POLYNOME_UNDEFINED_SYMBOL "<polynome undefined>"
170 #define MONOME_NUL_SYMBOL "<monome nul>"
171 #define MONOME_UNDEFINED_SYMBOL "<monome undefined>"
172 
173 #define MAX_NAME_LENGTH 50
174 
175 #define PNOME_MACH_EPS 1E-8 /* below this value, a float is null */
176 #define PNOME_FLOAT_N_DECIMALES 2 /* nb of figures after point for coeffs */
177 #define PNOME_FLOAT_TO_EXP_LEVEL 1E8 /* numbers >1E8 are printed with exponent */
178 #define PNOME_FLOAT_TO_FRAC_LEVEL 9 /* print 1/2..1/9 rather than 0.50..0.11 */
179 
180 #endif /* POLYNOME_INCLUDED */
181 
struct Spolynome Spolynome
struct Smonome Smonome
struct Spolynome * Ppolynome
struct Smonome * Pmonome
Pvecteur term
float coeff
Pmonome monome
struct Spolynome * succ
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89