00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef PPL_ppl_c_implementation_common_inlines_hh
00025 #define PPL_ppl_c_implementation_common_inlines_hh 1
00026
00027 namespace Parma_Polyhedra_Library {
00028
00029 namespace Interfaces {
00030
00031 namespace C {
00032
00033
00034
00035
00037 inline mpz_class&
00038 reinterpret_mpz_class(mpz_t n) {
00039 return reinterpret_cast<mpz_class&>(*n);
00040 }
00041
00042 DECLARE_CONVERSIONS(Coefficient, Coefficient)
00043
00044 DECLARE_CONVERSIONS(Linear_Expression, Linear_Expression)
00045
00046 DECLARE_CONVERSIONS(Constraint, Constraint)
00047
00048 DECLARE_CONVERSIONS(Constraint_System, Constraint_System)
00049
00050 typedef Constraint_System::const_iterator Constraint_System_const_iterator;
00051 DECLARE_CONVERSIONS(Constraint_System_const_iterator,
00052 Constraint_System_const_iterator)
00053
00054 DECLARE_CONVERSIONS(Generator, Generator)
00055
00056 DECLARE_CONVERSIONS(Generator_System, Generator_System)
00057
00058 typedef Generator_System::const_iterator Generator_System_const_iterator;
00059 DECLARE_CONVERSIONS(Generator_System_const_iterator,
00060 Generator_System_const_iterator)
00061
00062 DECLARE_CONVERSIONS(Congruence, Congruence)
00063
00064 DECLARE_CONVERSIONS(Congruence_System, Congruence_System)
00065
00066 typedef Congruence_System::const_iterator Congruence_System_const_iterator;
00067 DECLARE_CONVERSIONS(Congruence_System_const_iterator,
00068 Congruence_System_const_iterator)
00069
00070 DECLARE_CONVERSIONS(Grid_Generator, Grid_Generator)
00071
00072 DECLARE_CONVERSIONS(Grid_Generator_System, Grid_Generator_System)
00073
00074 typedef Grid_Generator_System::const_iterator
00075 Grid_Generator_System_const_iterator;
00076 DECLARE_CONVERSIONS(Grid_Generator_System_const_iterator,
00077 Grid_Generator_System_const_iterator)
00078
00079 typedef PIP_Tree_Node::Artificial_Parameter
00080 Artificial_Parameter;
00081 DECLARE_CONVERSIONS(Artificial_Parameter, Artificial_Parameter)
00082
00083 typedef PIP_Tree_Node::Artificial_Parameter_Sequence
00084 Artificial_Parameter_Sequence;
00085 DECLARE_CONVERSIONS(Artificial_Parameter_Sequence,
00086 Artificial_Parameter_Sequence)
00087
00088 typedef PIP_Tree_Node::Artificial_Parameter_Sequence::const_iterator
00089 Artificial_Parameter_Sequence_const_iterator;
00090 DECLARE_CONVERSIONS(Artificial_Parameter_Sequence_const_iterator,
00091 Artificial_Parameter_Sequence_const_iterator)
00092
00093 DECLARE_CONVERSIONS(MIP_Problem, MIP_Problem)
00094
00095 DECLARE_CONVERSIONS(PIP_Problem, PIP_Problem)
00096
00097 DECLARE_CONVERSIONS(PIP_Tree_Node, PIP_Tree_Node)
00098
00099 DECLARE_CONVERSIONS(PIP_Decision_Node, PIP_Decision_Node)
00100
00101 DECLARE_CONVERSIONS(PIP_Solution_Node, PIP_Solution_Node)
00102
00103 inline Relation_Symbol
00104 relation_symbol(enum ppl_enum_Constraint_Type t) {
00105 switch (t) {
00106 case PPL_CONSTRAINT_TYPE_LESS_THAN:
00107 return LESS_THAN;
00108 case PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL:
00109 return LESS_OR_EQUAL;
00110 case PPL_CONSTRAINT_TYPE_EQUAL:
00111 return EQUAL;
00112 case PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL:
00113 return GREATER_OR_EQUAL;
00114 case PPL_CONSTRAINT_TYPE_GREATER_THAN:
00115 return GREATER_THAN;
00116 default:
00117 return static_cast<Relation_Symbol>(t);
00118 }
00119 }
00120
00121 inline Bounded_Integer_Type_Width
00122 bounded_integer_type_width(enum ppl_enum_Bounded_Integer_Type_Width w) {
00123 switch (w) {
00124 case PPL_BITS_8:
00125 return BITS_8;
00126 case PPL_BITS_16:
00127 return BITS_16;
00128 case PPL_BITS_32:
00129 return BITS_32;
00130 case PPL_BITS_64:
00131 return BITS_64;
00132 case PPL_BITS_128:
00133 return BITS_128;
00134 default:
00135 return static_cast<Bounded_Integer_Type_Width>(w);
00136 }
00137 }
00138
00139 inline Bounded_Integer_Type_Representation
00140 bounded_integer_type_representation(enum ppl_enum_Bounded_Integer_Type_Representation r) {
00141 switch (r) {
00142 case PPL_UNSIGNED:
00143 return UNSIGNED;
00144 case PPL_SIGNED_2_COMPLEMENT:
00145 return SIGNED_2_COMPLEMENT;
00146 default:
00147 return static_cast<Bounded_Integer_Type_Representation>(r);
00148 }
00149 }
00150
00151 inline Bounded_Integer_Type_Overflow
00152 bounded_integer_type_overflow(enum ppl_enum_Bounded_Integer_Type_Overflow o) {
00153 switch (o) {
00154 case PPL_OVERFLOW_WRAPS:
00155 return OVERFLOW_WRAPS;
00156 case PPL_OVERFLOW_UNDEFINED:
00157 return OVERFLOW_UNDEFINED;
00158 case PPL_OVERFLOW_IMPOSSIBLE:
00159 return OVERFLOW_IMPOSSIBLE;
00160 default:
00161 return static_cast<Bounded_Integer_Type_Overflow>(o);
00162 }
00163 }
00164
00165 inline
00166 Array_Partial_Function_Wrapper
00167 ::Array_Partial_Function_Wrapper(dimension_type* v, size_t n)
00168 : vec(v), vec_size(n), max_in_codomain_(not_a_dimension()), empty(-1) {
00169 }
00170
00171 inline bool
00172 Array_Partial_Function_Wrapper::has_empty_codomain() const {
00173 if (empty < 0) {
00174 empty = 1;
00175 for (size_t i = vec_size; i-- > 0; )
00176 if (vec[i] != not_a_dimension()) {
00177 empty = 0;
00178 break;
00179 }
00180 }
00181 return empty;
00182 }
00183
00184 inline dimension_type
00185 Array_Partial_Function_Wrapper::max_in_codomain() const {
00186 if (max_in_codomain_ == not_a_dimension()) {
00187 for (size_t i = vec_size; i-- > 0; ) {
00188 dimension_type vec_i = vec[i];
00189 if (vec_i != not_a_dimension()
00190 && (max_in_codomain_ == not_a_dimension()
00191 || vec_i > max_in_codomain_))
00192 max_in_codomain_ = vec_i;
00193 }
00194 }
00195 return max_in_codomain_;
00196 }
00197
00198 inline bool
00199 Array_Partial_Function_Wrapper::maps(dimension_type i,
00200 dimension_type& j) const {
00201 if (i >= vec_size)
00202 return false;
00203 dimension_type vec_i = vec[i];
00204 if (vec_i == not_a_dimension())
00205 return false;
00206 j = vec_i;
00207 return true;
00208 }
00209
00210 }
00211
00212 }
00213
00214 }
00215
00216 #endif // !defined(PPL_ppl_c_implementation_common_inlines_hh)