63 lines
1.9 KiB
C
63 lines
1.9 KiB
C
/*
|
|
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)
|
|
|