diff options
Diffstat (limited to 'src/polynomialMV_mpz.h')
-rw-r--r-- | src/polynomialMV_mpz.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/polynomialMV_mpz.h b/src/polynomialMV_mpz.h new file mode 100644 index 0000000..4b99aa6 --- /dev/null +++ b/src/polynomialMV_mpz.h @@ -0,0 +1,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) + |