Ian Jauslin
summaryrefslogtreecommitdiff
blob: 4b99aa656ae9972e489f8abf60132cb2e8efd2df (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
/*
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 multi-precision integer (mpz) 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_mpz
// prefix of function names
#define POLYNOMIALMV_FUNC(NAME) polynomialMV_mpz_ ## NAME

// type of the coefficient
#define POLYNOMIALMV_COEF_TYPE mpz_t
// init coefficient
#define POLYNOMIALMV_COEF_INIT(VAR) mpz_init(VAR)
// free coefficient
#define POLYNOMIALMV_COEF_FREE(VAR) mpz_clear(VAR)
// set coefficient
#define POLYNOMIALMV_COEF_SET(COEF, VAL) COEF[0]=VAL[0]
// copy coefficient
#define POLYNOMIALMV_COEF_CPY(COEF, VAL) mpz_init(COEF); mpz_set(COEF, VAL)
// add coefficients
#define POLYNOMIALMV_COEF_ADD(COEF, VAL1, VAL2) mpz_add(COEF, VAL1, VAL2)
// multiply coefficients
#define POLYNOMIALMV_COEF_MUL(COEF, VAL1, VAL2) mpz_mul(COEF, VAL1, VAL2)
// print a coefficient
#define POLYNOMIALMV_COEF_PRINT(COEF) gmp_printf("%Zd", 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)