Ian Jauslin
summaryrefslogtreecommitdiff
blob: cb25866cb513b116836460d4cfe95a6fa85b0cc1 (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
/*
Copyright 2016 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.
*/

/*
  Preprocessor macros for multivariable polynomials with integer coefficients and integer-indexed variables
*/


// reset CPP macros
#undef POLYNOMIALMV_TYPENAME
#undef POLYNOMIALMV_FUNC
#undef POLYNOMIALMV_COEF_TYPE
#undef POLYNOMIALMV_COEF_INIT
#undef POLYNOMIALMV_COEF_FREE
#undef POLYNOMIALMV_COEF_SET
#undef POLYNOMIALMV_COEF_CPY
#undef POLYNOMIALMV_COEF_ADD
#undef POLYNOMIALMV_COEF_MUL
#undef POLYNOMIALMV_COEF_PRINT
#undef POLYNOMIALMV_FACTOR_TYPE
#undef POLYNOMIALMV_FACTOR_FUNC
#undef POLYNOMIALMV_FACTOR_ELT_PRINT


// name of the polynomial type
#define POLYNOMIALMV_TYPENAME polynomialMV_int
// prefix of function names
#define POLYNOMIALMV_FUNC(NAME) polynomialMV_int_ ## NAME

// type of the coefficient
#define POLYNOMIALMV_COEF_TYPE int
// set coefficient
#define POLYNOMIALMV_COEF_SET(COEF, VAL) COEF = VAL
// copy coefficient
#define POLYNOMIALMV_COEF_CPY(COEF, VAL) COEF = VAL
// add coefficients
#define POLYNOMIALMV_COEF_ADD(COEF, VAL1, VAL2) COEF = VAL1 + VAL2
// multiply coefficients
#define POLYNOMIALMV_COEF_MUL(COEF, VAL1, VAL2) COEF = VAL1 * VAL2
// print a coefficient
#define POLYNOMIALMV_COEF_PRINT(COEF) printf("%d", COEF)

// type of the factor (must be an array)
#define POLYNOMIALMV_FACTOR_TYPE array_int
// prefix of factor function names
#define POLYNOMIALMV_FACTOR_FUNC(NAME) array_int_ ## NAME
// print an element of a factor
#define POLYNOMIALMV_FACTOR_ELT_PRINT(ELT) printf("[x%d]", ELT)