From 2125f01f97abfe343fc5e0cc078bf1d081b2e441 Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Fri, 20 May 2016 20:30:15 +0000 Subject: Initial commit --- src/polynomialMV_int.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/polynomialMV_int.h (limited to 'src/polynomialMV_int.h') diff --git a/src/polynomialMV_int.h b/src/polynomialMV_int.h new file mode 100644 index 0000000..cb25866 --- /dev/null +++ b/src/polynomialMV_int.h @@ -0,0 +1,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) + -- cgit v1.2.3-70-g09d2