1 /* Copyright (C) 2011 LinBox 2 * Written by Brice Boyer (briceboyer) <boyer.brice@gmail.com> 3 * 4 * 5 * 6 * ========LICENCE======== 7 * This file is part of the library LinBox. 8 * 9 * LinBox is free software: you can redistribute it and/or modify 10 * it under the terms of the GNU Lesser General Public 11 * License as published by the Free Software Foundation; either 12 * version 2.1 of the License, or (at your option) any later version. 13 * 14 * This library is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this library; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 * ========LICENCE======== 23 */ 24 25 /*! @file util/iml_wrapper.h 26 * @ingroup util 27 * @brief Wraper for IML routines and puts them in a dedicated namespace. 28 * This wrapper includes iml.h definitions in an IML namespace. The \#defines 29 * found elsewhere in the library (eg X*ALLOC) are rewritten. The functions 30 * that are provided in the .a but not in the header are provided <code>extern 31 * "C"</code>. 32 */ 33 34 #ifndef __LINBOX_util_iml_wrapper_H 35 #define __LINBOX_util_iml_wrapper_H 36 37 #ifdef __LINBOX_HAVE_IML 38 /*! @brief Namespace for IML routines. 39 * This namespace is foreign to LinBox'. 40 */ 41 namespace IML { 42 extern "C" { 43 #include "iml.h" 44 45 /* Pretend that IML was not included. This is needed if some other 46 * library also wants to include iml.h */ 47 #undef IML_H 48 #undef ENUM_DEFINED_H 49 50 /* basisop.c */ 51 void 52 maxMagnMP (mpz_t *mp_A, const long n, const long m, const long lda, \ 53 mpz_t mp_max) ; 54 /* RNSop.c */ 55 FiniteField RNSbound (const long n) ; 56 57 FiniteField ** 58 findRNS (const FiniteField RNS_bound, const mpz_t mp_maxInter, long *length) ; 59 60 FiniteField * 61 repBound (const long len, const FiniteField *basis, const FiniteField *cmbasis) ; 62 63 void 64 basisProd (const long len, const FiniteField *basis, mpz_t mp_prod) ; 65 66 void 67 ChineseRemainder (const long len, const mpz_t mp_prod, \ 68 const FiniteField *basis, const FiniteField *cmbasis, \ 69 const FiniteField *bdcoeff, Double *Ac, mpz_t mp_Ac); 70 void 71 ChineseRemainderPos (const long len, const FiniteField *basis, \ 72 const FiniteField *cmbasis, Double *Ac, mpz_t mp_Ac); 73 74 75 } 76 // #include <stdlib.h> 77 #ifndef XMALLOC 78 #define IML_XMALLOC(type, num) \ 79 ((type *) malloc ((num) * sizeof(type))) 80 #else 81 #define IML_XMALLOC(type, num) \ 82 XMALLOC(type, num) 83 #endif 84 85 #ifndef XFREE 86 #define IML_XFREE(stale) do { \ 87 if (stale) { free (stale); stale = 0; } \ 88 } while (0) 89 #else 90 #define IML_XFREE(stale) \ 91 XFREE(stale) 92 #endif 93 94 extern "C" { 95 void *xcalloc (size_t num, size_t size); 96 void *xmalloc (size_t num); 97 void *xrealloc (void *p, size_t num); 98 99 } 100 101 #define REINTERP_IML_CONST(GivMat) \ 102 reinterpret_cast<mpz_t*>(const_cast<Givaro::ZRing<Integer>::Element*>((GivMat))) 103 #define REINTERP_IML(GivMat) \ 104 reinterpret_cast<mpz_t*>((GivMat)) 105 106 } 107 #else 108 #error "you are using IML wrapper without IML available in LinBox." 109 #endif 110 111 #endif // __LINBOX_util_iml_wrapper_H 112 113 // Local Variables: 114 // mode: C++ 115 // tab-width: 4 116 // indent-tabs-mode: nil 117 // c-basic-offset: 4 118 // End: 119 // vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s 120