1 /* PPL Java interface: domain-independent functions.
2 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3 Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4
5 This file is part of the Parma Polyhedra Library (PPL).
6
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23
24 #include "ppl_java_common_defs.hh"
25 #include "parma_polyhedra_library_Artificial_Parameter.h"
26 #include "parma_polyhedra_library_Artificial_Parameter_Sequence.h"
27 #include "parma_polyhedra_library_Bounded_Integer_Type_Overflow.h"
28 #include "parma_polyhedra_library_Bounded_Integer_Type_Representation.h"
29 #include "parma_polyhedra_library_Bounded_Integer_Type_Width.h"
30 #include "parma_polyhedra_library_By_Reference.h"
31 #include "parma_polyhedra_library_Coefficient.h"
32 #include "parma_polyhedra_library_Complexity_Class.h"
33 #include "parma_polyhedra_library_Congruence.h"
34 #include "parma_polyhedra_library_Congruence_System.h"
35 #include "parma_polyhedra_library_Constraint.h"
36 #include "parma_polyhedra_library_Constraint_System.h"
37 #include "parma_polyhedra_library_Degenerate_Element.h"
38 #include "parma_polyhedra_library_Generator.h"
39 #include "parma_polyhedra_library_Generator_System.h"
40 #include "parma_polyhedra_library_Generator_Type.h"
41 #include "parma_polyhedra_library_Grid_Generator.h"
42 #include "parma_polyhedra_library_Grid_Generator_System.h"
43 #include "parma_polyhedra_library_Grid_Generator_Type.h"
44 #include "parma_polyhedra_library_IO.h"
45 #include "parma_polyhedra_library_Linear_Expression.h"
46 #include "parma_polyhedra_library_Linear_Expression_Coefficient.h"
47 #include "parma_polyhedra_library_Linear_Expression_Difference.h"
48 #include "parma_polyhedra_library_Linear_Expression_Sum.h"
49 #include "parma_polyhedra_library_Linear_Expression_Times.h"
50 #include "parma_polyhedra_library_Linear_Expression_Unary_Minus.h"
51 #include "parma_polyhedra_library_Linear_Expression_Variable.h"
52 #include "parma_polyhedra_library_MIP_Problem.h"
53 #include "parma_polyhedra_library_MIP_Problem_Status.h"
54 #include "parma_polyhedra_library_Optimization_Mode.h"
55 #include "parma_polyhedra_library_Pair.h"
56 #include "parma_polyhedra_library_Parma_Polyhedra_Library.h"
57 #include "parma_polyhedra_library_Partial_Function.h"
58 #include "parma_polyhedra_library_PIP_Problem.h"
59 #include "parma_polyhedra_library_PIP_Problem_Status.h"
60 #include "parma_polyhedra_library_PIP_Decision_Node.h"
61 #include "parma_polyhedra_library_PIP_Solution_Node.h"
62 #include "parma_polyhedra_library_PIP_Tree_Node.h"
63 #include "parma_polyhedra_library_Poly_Con_Relation.h"
64 #include "parma_polyhedra_library_Poly_Gen_Relation.h"
65 #include "parma_polyhedra_library_PPL_Object.h"
66 #include "parma_polyhedra_library_Relation_Symbol.h"
67 #include "parma_polyhedra_library_Variable.h"
68 #include "parma_polyhedra_library_Variables_Set.h"
69
70 using namespace Parma_Polyhedra_Library;
71 using namespace Parma_Polyhedra_Library::Interfaces::Java;
72
73 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_initialize_1library(JNIEnv * env,jclass)74 Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_initialize_1library
75 (JNIEnv* env, jclass /* ppl_class */) {
76 initialize();
77 cached_classes.init_cache(env);
78 }
79
80 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_finalize_1library(JNIEnv * env,jclass)81 Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_finalize_1library
82 (JNIEnv* env, jclass /* ppl_class */) {
83 cached_classes.clear_cache(env);
84 finalize();
85 }
86
87
88 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_By_1Reference_initIDs(JNIEnv * env,jclass j_by_ref_class)89 Java_parma_1polyhedra_1library_By_1Reference_initIDs
90 (JNIEnv* env, jclass j_by_ref_class) {
91 jfieldID fID;
92 fID = env->GetFieldID(j_by_ref_class, "obj", "Ljava/lang/Object;");
93 CHECK_RESULT_ASSERT(env, fID);
94 cached_FMIDs.By_Reference_obj_ID = fID;
95 jmethodID mID;
96 mID = env->GetMethodID(j_by_ref_class, "<init>", "(Ljava/lang/Object;)V");
97 CHECK_RESULT_ASSERT(env, mID);
98 cached_FMIDs.By_Reference_init_ID = mID;
99 }
100
101 JNIEXPORT jint JNICALL
Java_parma_1polyhedra_1library_Coefficient_bits(JNIEnv *,jclass)102 Java_parma_1polyhedra_1library_Coefficient_bits(JNIEnv*, jclass) {
103 return PPL_COEFFICIENT_BITS;
104 }
105
106 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Coefficient_initIDs(JNIEnv * env,jclass j_coeff_class)107 Java_parma_1polyhedra_1library_Coefficient_initIDs
108 (JNIEnv* env, jclass j_coeff_class) {
109 jfieldID fID;
110 fID = env->GetFieldID(j_coeff_class, "value", "Ljava/math/BigInteger;");
111 CHECK_RESULT_ASSERT(env, fID);
112 cached_FMIDs.Coefficient_value_ID = fID;
113 jmethodID mID;
114 mID = env->GetMethodID(j_coeff_class, "<init>", "(Ljava/lang/String;)V");
115 CHECK_RESULT_ASSERT(env, mID);
116 cached_FMIDs.Coefficient_init_from_String_ID = mID;
117 mID = env->GetMethodID(j_coeff_class, "toString", "()Ljava/lang/String;");
118 CHECK_RESULT_ASSERT(env, mID);
119 cached_FMIDs.Coefficient_toString_ID = mID;
120 // Boolean.
121 mID = env->GetStaticMethodID(cached_classes.Boolean, "valueOf",
122 "(Z)Ljava/lang/Boolean;");
123 CHECK_RESULT_ASSERT(env, mID);
124 cached_FMIDs.Boolean_valueOf_ID = mID;
125 // Integer.
126 mID = env->GetStaticMethodID(cached_classes.Integer, "valueOf",
127 "(I)Ljava/lang/Integer;");
128 CHECK_RESULT_ASSERT(env, mID);
129 cached_FMIDs.Integer_valueOf_ID = mID;
130 mID = env->GetMethodID(cached_classes.Integer, "intValue", "()I");
131 CHECK_RESULT_ASSERT(env, mID);
132 cached_FMIDs.Integer_intValue_ID = mID;
133 // Long.
134 mID = env->GetStaticMethodID(cached_classes.Long, "valueOf",
135 "(J)Ljava/lang/Long;");
136 CHECK_RESULT_ASSERT(env, mID);
137 cached_FMIDs.Long_valueOf_ID = mID;
138 mID = env->GetMethodID(cached_classes.Long, "longValue", "()J");
139 CHECK_RESULT_ASSERT(env, mID);
140 cached_FMIDs.Long_longValue_ID = mID;
141 }
142
143 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Complexity_1Class_initIDs(JNIEnv * env,jclass j_complexity_class)144 Java_parma_1polyhedra_1library_Complexity_1Class_initIDs
145 (JNIEnv* env, jclass j_complexity_class) {
146 jmethodID mID = env->GetMethodID(j_complexity_class, "ordinal", "()I");
147 CHECK_RESULT_ASSERT(env, mID);
148 cached_FMIDs.Complexity_Class_ordinal_ID = mID;
149 }
150
151 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Congruence_initIDs(JNIEnv * env,jclass j_congruence_class)152 Java_parma_1polyhedra_1library_Congruence_initIDs
153 (JNIEnv* env, jclass j_congruence_class) {
154 jfieldID fID;
155 fID = env->GetFieldID(j_congruence_class, "mod",
156 "Lparma_polyhedra_library/Coefficient;");
157 CHECK_RESULT_ASSERT(env, fID);
158 cached_FMIDs.Congruence_mod_ID = fID;
159 fID = env->GetFieldID(j_congruence_class, "lhs",
160 "Lparma_polyhedra_library/Linear_Expression;");
161 CHECK_RESULT_ASSERT(env, fID);
162 cached_FMIDs.Congruence_lhs_ID = fID;
163 fID = env->GetFieldID(j_congruence_class, "rhs",
164 "Lparma_polyhedra_library/Linear_Expression;");
165 CHECK_RESULT_ASSERT(env, fID);
166 cached_FMIDs.Congruence_rhs_ID = fID;
167 jmethodID mID;
168 mID = env->GetMethodID(j_congruence_class, "<init>",
169 "(Lparma_polyhedra_library/Linear_Expression;"
170 "Lparma_polyhedra_library/Linear_Expression;"
171 "Lparma_polyhedra_library/Coefficient;)V");
172 CHECK_RESULT_ASSERT(env, mID);
173 cached_FMIDs.Congruence_init_ID = mID;
174 }
175
176 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Congruence_1System_initIDs(JNIEnv * env,jclass j_con_sys_class)177 Java_parma_1polyhedra_1library_Congruence_1System_initIDs
178 (JNIEnv* env, jclass j_con_sys_class) {
179 jmethodID mID;
180 mID = env->GetMethodID(j_con_sys_class, "<init>", "()V");
181 CHECK_RESULT_ASSERT(env, mID);
182 cached_FMIDs.Congruence_System_init_ID = mID;
183 mID = env->GetMethodID(j_con_sys_class, "add", "(Ljava/lang/Object;)Z");
184 CHECK_RESULT_ASSERT(env, mID);
185 cached_FMIDs.Congruence_System_add_ID = mID;
186 }
187
188 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Constraint_initIDs(JNIEnv * env,jclass j_constraint_class)189 Java_parma_1polyhedra_1library_Constraint_initIDs
190 (JNIEnv* env, jclass j_constraint_class) {
191 jfieldID fID;
192 fID = env->GetFieldID(j_constraint_class, "lhs",
193 "Lparma_polyhedra_library/Linear_Expression;");
194 CHECK_RESULT_ASSERT(env, fID);
195 cached_FMIDs.Constraint_lhs_ID = fID;
196 fID = env->GetFieldID(j_constraint_class, "rhs",
197 "Lparma_polyhedra_library/Linear_Expression;");
198 CHECK_RESULT_ASSERT(env, fID);
199 cached_FMIDs.Constraint_rhs_ID = fID;
200 fID = env->GetFieldID(j_constraint_class, "kind",
201 "Lparma_polyhedra_library/Relation_Symbol;");
202 CHECK_RESULT_ASSERT(env, fID);
203 cached_FMIDs.Constraint_kind_ID = fID;
204 jmethodID mID;
205 mID = env->GetMethodID(j_constraint_class, "<init>",
206 "(Lparma_polyhedra_library/Linear_Expression;"
207 "Lparma_polyhedra_library/Relation_Symbol;"
208 "Lparma_polyhedra_library/Linear_Expression;)V");
209 CHECK_RESULT_ASSERT(env, mID);
210 cached_FMIDs.Constraint_init_ID = mID;
211 }
212
213 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Constraint_1System_initIDs(JNIEnv * env,jclass j_con_sys_class)214 Java_parma_1polyhedra_1library_Constraint_1System_initIDs
215 (JNIEnv* env, jclass j_con_sys_class) {
216 jmethodID mID;
217 mID = env->GetMethodID(j_con_sys_class, "<init>", "()V");
218 CHECK_RESULT_ASSERT(env, mID);
219 cached_FMIDs.Constraint_System_init_ID = mID;
220 mID = env->GetMethodID(j_con_sys_class, "add", "(Ljava/lang/Object;)Z");
221 CHECK_RESULT_ASSERT(env, mID);
222 cached_FMIDs.Constraint_System_add_ID = mID;
223 // NOTE: initialize the iterator method IDs common to all *_System classes.
224 mID = env->GetMethodID(j_con_sys_class, "iterator",
225 "()Ljava/util/Iterator;");
226 CHECK_RESULT_ASSERT(env, mID);
227 cached_FMIDs.System_iterator_ID = mID;
228 mID = env->GetMethodID(cached_classes.Iterator, "hasNext", "()Z");
229 CHECK_RESULT_ASSERT(env, mID);
230 cached_FMIDs.System_Iterator_has_next_ID = mID;
231 assert(cached_classes.Iterator != NULL);
232 mID = env->GetMethodID(cached_classes.Iterator, "next",
233 "()Ljava/lang/Object;");
234 CHECK_RESULT_ASSERT(env, mID);
235 cached_FMIDs.System_Iterator_next_ID = mID;
236 }
237
238 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Degenerate_1Element_initIDs(JNIEnv * env,jclass j_degenerate_class)239 Java_parma_1polyhedra_1library_Degenerate_1Element_initIDs
240 (JNIEnv* env, jclass j_degenerate_class) {
241 jmethodID mID = env->GetMethodID(j_degenerate_class, "ordinal", "()I");
242 CHECK_RESULT_ASSERT(env, mID);
243 cached_FMIDs.Degenerate_Element_ordinal_ID = mID;
244 }
245
246 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Generator_initIDs(JNIEnv * env,jclass j_generator_class)247 Java_parma_1polyhedra_1library_Generator_initIDs
248 (JNIEnv* env, jclass j_generator_class) {
249 jfieldID fID;
250 fID = env->GetFieldID(j_generator_class, "gt",
251 "Lparma_polyhedra_library/Generator_Type;");
252 CHECK_RESULT_ASSERT(env, fID);
253 cached_FMIDs.Generator_gt_ID = fID;
254 fID = env->GetFieldID(j_generator_class, "le",
255 "Lparma_polyhedra_library/Linear_Expression;");
256 CHECK_RESULT_ASSERT(env, fID);
257 cached_FMIDs.Generator_le_ID = fID;
258 fID = env->GetFieldID(j_generator_class, "div",
259 "Lparma_polyhedra_library/Coefficient;");
260 CHECK_RESULT_ASSERT(env, fID);
261 cached_FMIDs.Generator_div_ID = fID;
262 jmethodID mID;
263 mID = env->GetStaticMethodID(j_generator_class, "line",
264 "(Lparma_polyhedra_library/Linear_Expression;)"
265 "Lparma_polyhedra_library/Generator;");
266 CHECK_RESULT_ASSERT(env, mID);
267 cached_FMIDs.Generator_line_ID = mID;
268 mID = env->GetStaticMethodID(j_generator_class, "ray",
269 "(Lparma_polyhedra_library/Linear_Expression;)"
270 "Lparma_polyhedra_library/Generator;");
271 CHECK_RESULT_ASSERT(env, mID);
272 cached_FMIDs.Generator_ray_ID = mID;
273 mID = env->GetStaticMethodID(j_generator_class, "point",
274 "(Lparma_polyhedra_library/Linear_Expression;"
275 "Lparma_polyhedra_library/Coefficient;)"
276 "Lparma_polyhedra_library/Generator;");
277 CHECK_RESULT_ASSERT(env, mID);
278 cached_FMIDs.Generator_point_ID = mID;
279 mID = env->GetStaticMethodID(j_generator_class, "closure_point",
280 "(Lparma_polyhedra_library/Linear_Expression;"
281 "Lparma_polyhedra_library/Coefficient;)"
282 "Lparma_polyhedra_library/Generator;");
283 CHECK_RESULT_ASSERT(env, mID);
284 cached_FMIDs.Generator_closure_point_ID = mID;
285 }
286
287 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Generator_1System_initIDs(JNIEnv * env,jclass j_gen_sys_class)288 Java_parma_1polyhedra_1library_Generator_1System_initIDs
289 (JNIEnv* env, jclass j_gen_sys_class) {
290 jmethodID mID;
291 mID = env->GetMethodID(j_gen_sys_class, "<init>", "()V");
292 CHECK_RESULT_ASSERT(env, mID);
293 cached_FMIDs.Generator_System_init_ID = mID;
294 mID = env->GetMethodID(j_gen_sys_class, "add", "(Ljava/lang/Object;)Z");
295 CHECK_RESULT_ASSERT(env, mID);
296 cached_FMIDs.Generator_System_add_ID = mID;
297 }
298
299 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Generator_1Type_initIDs(JNIEnv * env,jclass j_gen_type_class)300 Java_parma_1polyhedra_1library_Generator_1Type_initIDs
301 (JNIEnv* env, jclass j_gen_type_class) {
302 jmethodID mID;
303 mID = env->GetMethodID(j_gen_type_class, "ordinal", "()I");
304 CHECK_RESULT_ASSERT(env, mID);
305 cached_FMIDs.Generator_Type_ordinal_ID = mID;
306 }
307
308 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Grid_1Generator_initIDs(JNIEnv * env,jclass j_grid_generator_class)309 Java_parma_1polyhedra_1library_Grid_1Generator_initIDs
310 (JNIEnv* env, jclass j_grid_generator_class) {
311 jfieldID fID;
312 fID = env->GetFieldID(j_grid_generator_class, "gt",
313 "Lparma_polyhedra_library/Grid_Generator_Type;");
314 CHECK_RESULT_ASSERT(env, fID);
315 cached_FMIDs.Grid_Generator_gt_ID = fID;
316 fID = env->GetFieldID(j_grid_generator_class, "le",
317 "Lparma_polyhedra_library/Linear_Expression;");
318 CHECK_RESULT_ASSERT(env, fID);
319 cached_FMIDs.Grid_Generator_le_ID = fID;
320 fID = env->GetFieldID(j_grid_generator_class, "div",
321 "Lparma_polyhedra_library/Coefficient;");
322 CHECK_RESULT_ASSERT(env, fID);
323 cached_FMIDs.Grid_Generator_div_ID = fID;
324 jmethodID mID;
325 mID = env->GetStaticMethodID(j_grid_generator_class, "grid_line",
326 "(Lparma_polyhedra_library/Linear_Expression;)"
327 "Lparma_polyhedra_library/Grid_Generator;");
328 CHECK_RESULT_ASSERT(env, mID);
329 cached_FMIDs.Grid_Generator_grid_line_ID = mID;
330 mID = env->GetStaticMethodID(j_grid_generator_class, "parameter",
331 "(Lparma_polyhedra_library/Linear_Expression;"
332 "Lparma_polyhedra_library/Coefficient;)"
333 "Lparma_polyhedra_library/Grid_Generator;");
334 CHECK_RESULT_ASSERT(env, mID);
335 cached_FMIDs.Grid_Generator_parameter_ID = mID;
336 mID = env->GetStaticMethodID(j_grid_generator_class, "grid_point",
337 "(Lparma_polyhedra_library/Linear_Expression;"
338 "Lparma_polyhedra_library/Coefficient;)"
339 "Lparma_polyhedra_library/Grid_Generator;");
340 CHECK_RESULT_ASSERT(env, mID);
341 cached_FMIDs.Grid_Generator_grid_point_ID = mID;
342 }
343
344 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Grid_1Generator_1System_initIDs(JNIEnv * env,jclass j_gen_sys_class)345 Java_parma_1polyhedra_1library_Grid_1Generator_1System_initIDs
346 (JNIEnv* env, jclass j_gen_sys_class) {
347 jmethodID mID;
348 mID = env->GetMethodID(j_gen_sys_class, "<init>", "()V");
349 CHECK_RESULT_ASSERT(env, mID);
350 cached_FMIDs.Grid_Generator_System_init_ID = mID;
351 mID = env->GetMethodID(j_gen_sys_class, "add", "(Ljava/lang/Object;)Z");
352 CHECK_RESULT_ASSERT(env, mID);
353 cached_FMIDs.Grid_Generator_System_add_ID = mID;
354 }
355
356 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Grid_1Generator_1Type_initIDs(JNIEnv * env,jclass j_grid_gen_type_class)357 Java_parma_1polyhedra_1library_Grid_1Generator_1Type_initIDs
358 (JNIEnv* env, jclass j_grid_gen_type_class) {
359 jmethodID mID;
360 mID = env->GetMethodID(j_grid_gen_type_class, "ordinal", "()I");
361 CHECK_RESULT_ASSERT(env, mID);
362 cached_FMIDs.Grid_Generator_Type_ordinal_ID = mID;
363 }
364
365 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Linear_1Expression_initIDs(JNIEnv * env,jclass j_le_class)366 Java_parma_1polyhedra_1library_Linear_1Expression_initIDs
367 (JNIEnv* env, jclass j_le_class) {
368 jmethodID mID;
369 mID = env->GetMethodID(j_le_class, "sum",
370 "(Lparma_polyhedra_library/Linear_Expression;)"
371 "Lparma_polyhedra_library/Linear_Expression;");
372 CHECK_RESULT_ASSERT(env, mID);
373 cached_FMIDs.Linear_Expression_sum_ID = mID;
374 mID = env->GetMethodID(j_le_class, "times",
375 "(Lparma_polyhedra_library/Coefficient;)"
376 "Lparma_polyhedra_library/Linear_Expression;");
377 CHECK_RESULT_ASSERT(env, mID);
378 cached_FMIDs.Linear_Expression_times_ID = mID;
379 }
380
381 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Linear_1Expression_1Coefficient_initIDs(JNIEnv * env,jclass j_le_coeff_class)382 Java_parma_1polyhedra_1library_Linear_1Expression_1Coefficient_initIDs
383 (JNIEnv* env, jclass j_le_coeff_class) {
384 jfieldID fID;
385 fID = env->GetFieldID(j_le_coeff_class, "coeff",
386 "Lparma_polyhedra_library/Coefficient;");
387 CHECK_RESULT_ASSERT(env, fID);
388 cached_FMIDs.Linear_Expression_Coefficient_coeff_ID = fID;
389 jmethodID mID;
390 mID = env->GetMethodID(j_le_coeff_class, "<init>",
391 "(Lparma_polyhedra_library/Coefficient;)V");
392 CHECK_RESULT_ASSERT(env, mID);
393 cached_FMIDs.Linear_Expression_Coefficient_init_ID = mID;
394 }
395
396 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Linear_1Expression_1Difference_initIDs(JNIEnv * env,jclass j_le_diff_class)397 Java_parma_1polyhedra_1library_Linear_1Expression_1Difference_initIDs
398 (JNIEnv* env, jclass j_le_diff_class) {
399 jfieldID fID;
400 fID = env->GetFieldID(j_le_diff_class, "lhs",
401 "Lparma_polyhedra_library/Linear_Expression;");
402 CHECK_RESULT_ASSERT(env, fID);
403 cached_FMIDs.Linear_Expression_Difference_lhs_ID = fID;
404 fID = env->GetFieldID(j_le_diff_class, "rhs",
405 "Lparma_polyhedra_library/Linear_Expression;");
406 CHECK_RESULT_ASSERT(env, fID);
407 cached_FMIDs.Linear_Expression_Difference_rhs_ID = fID;
408 }
409
410 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Linear_1Expression_1Sum_initIDs(JNIEnv * env,jclass j_le_sum_class)411 Java_parma_1polyhedra_1library_Linear_1Expression_1Sum_initIDs
412 (JNIEnv* env, jclass j_le_sum_class) {
413 jfieldID fID;
414 fID = env->GetFieldID(j_le_sum_class, "lhs",
415 "Lparma_polyhedra_library/Linear_Expression;");
416 CHECK_RESULT_ASSERT(env, fID);
417 cached_FMIDs.Linear_Expression_Sum_lhs_ID = fID;
418 fID = env->GetFieldID(j_le_sum_class, "rhs",
419 "Lparma_polyhedra_library/Linear_Expression;");
420 CHECK_RESULT_ASSERT(env, fID);
421 cached_FMIDs.Linear_Expression_Sum_rhs_ID = fID;
422 }
423
424 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Linear_1Expression_1Times_initIDs(JNIEnv * env,jclass j_le_times_class)425 Java_parma_1polyhedra_1library_Linear_1Expression_1Times_initIDs
426 (JNIEnv* env, jclass j_le_times_class) {
427 jfieldID fID;
428 fID = env->GetFieldID(j_le_times_class, "coeff",
429 "Lparma_polyhedra_library/Coefficient;");
430 CHECK_RESULT_ASSERT(env, fID);
431 cached_FMIDs.Linear_Expression_Times_coeff_ID = fID;
432 fID = env->GetFieldID(j_le_times_class, "lin_expr",
433 "Lparma_polyhedra_library/Linear_Expression;");
434 CHECK_RESULT_ASSERT(env, fID);
435 cached_FMIDs.Linear_Expression_Times_lin_expr_ID = fID;
436 jmethodID mID;
437 mID = env->GetMethodID(j_le_times_class, "<init>",
438 "(Lparma_polyhedra_library/Coefficient;"
439 "Lparma_polyhedra_library/Variable;)V");
440 CHECK_RESULT_ASSERT(env, mID);
441 cached_FMIDs.Linear_Expression_Times_init_from_coeff_var_ID = mID;
442 }
443
444 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Linear_1Expression_1Unary_1Minus_initIDs(JNIEnv * env,jclass j_le_uminus_class)445 Java_parma_1polyhedra_1library_Linear_1Expression_1Unary_1Minus_initIDs
446 (JNIEnv* env, jclass j_le_uminus_class) {
447 jfieldID fID;
448 fID = env->GetFieldID(j_le_uminus_class, "arg",
449 "Lparma_polyhedra_library/Linear_Expression;");
450 CHECK_RESULT_ASSERT(env, fID);
451 cached_FMIDs.Linear_Expression_Unary_Minus_arg_ID = fID;
452 }
453
454 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Linear_1Expression_1Variable_initIDs(JNIEnv * env,jclass j_le_var_class)455 Java_parma_1polyhedra_1library_Linear_1Expression_1Variable_initIDs
456 (JNIEnv* env, jclass j_le_var_class) {
457 jmethodID mID;
458 mID = env->GetMethodID(j_le_var_class, "<init>",
459 "(Lparma_polyhedra_library/Variable;)V");
460 CHECK_RESULT_ASSERT(env, mID);
461 cached_FMIDs.Linear_Expression_Variable_init_ID = mID;
462 mID = env->GetMethodID(j_le_var_class, "var_id", "()J");
463 CHECK_RESULT_ASSERT(env, mID);
464 cached_FMIDs.Linear_Expression_Variable_var_id_ID = mID;
465 }
466
467 JNIEXPORT jboolean JNICALL
Java_parma_1polyhedra_1library_Linear_1Expression_is_1zero(JNIEnv * env,jobject j_this)468 Java_parma_1polyhedra_1library_Linear_1Expression_is_1zero
469 (JNIEnv* env, jobject j_this) {
470 try {
471 return build_cxx_linear_expression(env, j_this).is_zero();
472 }
473 CATCH_ALL
474 return false;
475 }
476
477 JNIEXPORT jboolean JNICALL
Java_parma_1polyhedra_1library_Linear_1Expression_all_1homogeneous_1terms_1are_1zero(JNIEnv * env,jobject j_this)478 Java_parma_1polyhedra_1library_Linear_1Expression_all_1homogeneous_1terms_1are_1zero
479 (JNIEnv* env, jobject j_this) {
480 try {
481 return build_cxx_linear_expression(env, j_this).all_homogeneous_terms_are_zero();
482 }
483 CATCH_ALL
484 return false;
485 }
486
487 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_1Status_initIDs(JNIEnv * env,jclass j_mip_status_class)488 Java_parma_1polyhedra_1library_MIP_1Problem_1Status_initIDs
489 (JNIEnv* env, jclass j_mip_status_class) {
490 jfieldID fID;
491 fID = env->GetStaticFieldID(j_mip_status_class, "UNFEASIBLE_MIP_PROBLEM",
492 "Lparma_polyhedra_library/MIP_Problem_Status;");
493 CHECK_RESULT_ASSERT(env, fID);
494 cached_FMIDs.MIP_Problem_Status_UNFEASIBLE_MIP_PROBLEM_ID = fID;
495 fID = env->GetStaticFieldID(j_mip_status_class, "UNBOUNDED_MIP_PROBLEM",
496 "Lparma_polyhedra_library/MIP_Problem_Status;");
497 CHECK_RESULT_ASSERT(env, fID);
498 cached_FMIDs.MIP_Problem_Status_UNBOUNDED_MIP_PROBLEM_ID = fID;
499 fID = env->GetStaticFieldID(j_mip_status_class, "OPTIMIZED_MIP_PROBLEM",
500 "Lparma_polyhedra_library/MIP_Problem_Status;");
501 CHECK_RESULT_ASSERT(env, fID);
502 cached_FMIDs.MIP_Problem_Status_OPTIMIZED_MIP_PROBLEM_ID = fID;
503 jmethodID mID;
504 mID = env->GetMethodID(j_mip_status_class, "ordinal", "()I");
505 CHECK_RESULT_ASSERT(env, mID);
506 cached_FMIDs.MIP_Problem_Status_ordinal_ID = mID;
507 }
508
509 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_1Status_initIDs(JNIEnv * env,jclass j_mip_status_class)510 Java_parma_1polyhedra_1library_PIP_1Problem_1Status_initIDs
511 (JNIEnv* env, jclass j_mip_status_class) {
512 jfieldID fID;
513 fID = env->GetStaticFieldID(j_mip_status_class, "UNFEASIBLE_PIP_PROBLEM",
514 "Lparma_polyhedra_library/PIP_Problem_Status;");
515 CHECK_RESULT_ASSERT(env, fID);
516 cached_FMIDs.PIP_Problem_Status_UNFEASIBLE_PIP_PROBLEM_ID = fID;
517 fID = env->GetStaticFieldID(j_mip_status_class, "OPTIMIZED_PIP_PROBLEM",
518 "Lparma_polyhedra_library/PIP_Problem_Status;");
519 CHECK_RESULT_ASSERT(env, fID);
520 cached_FMIDs.PIP_Problem_Status_OPTIMIZED_PIP_PROBLEM_ID = fID;
521 jmethodID mID;
522 mID = env->GetMethodID(j_mip_status_class, "ordinal", "()I");
523 CHECK_RESULT_ASSERT(env, mID);
524 cached_FMIDs.PIP_Problem_Status_ordinal_ID = mID;
525 }
526
527 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Optimization_1Mode_initIDs(JNIEnv * env,jclass j_opt_mode_class)528 Java_parma_1polyhedra_1library_Optimization_1Mode_initIDs
529 (JNIEnv* env, jclass j_opt_mode_class) {
530 jfieldID fID;
531 fID = env->GetStaticFieldID(j_opt_mode_class, "MAXIMIZATION",
532 "Lparma_polyhedra_library/Optimization_Mode;");
533 CHECK_RESULT_ASSERT(env, fID);
534 cached_FMIDs.Optimization_Mode_MAXIMIZATION_ID = fID;
535 fID = env->GetStaticFieldID(j_opt_mode_class, "MINIMIZATION",
536 "Lparma_polyhedra_library/Optimization_Mode;");
537 CHECK_RESULT_ASSERT(env, fID);
538 cached_FMIDs.Optimization_Mode_MINIMIZATION_ID = fID;
539 jmethodID mID;
540 mID = env->GetMethodID(j_opt_mode_class, "ordinal", "()I");
541 CHECK_RESULT_ASSERT(env, mID);
542 cached_FMIDs.Optimization_Mode_ordinal_ID = mID;
543 }
544
545 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Pair_initIDs(JNIEnv * env,jclass j_pair_class)546 Java_parma_1polyhedra_1library_Pair_initIDs
547 (JNIEnv* env, jclass j_pair_class) {
548 jfieldID fID;
549 fID = env->GetFieldID(j_pair_class, "first", "Ljava/lang/Object;");
550 CHECK_RESULT_ASSERT(env, fID);
551 cached_FMIDs.Pair_first_ID = fID;
552 fID = env->GetFieldID(j_pair_class, "second", "Ljava/lang/Object;");
553 CHECK_RESULT_ASSERT(env, fID);
554 cached_FMIDs.Pair_second_ID = fID;
555 }
556
557 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Poly_1Con_1Relation_initIDs(JNIEnv * env,jclass j_poly_con_relation_class)558 Java_parma_1polyhedra_1library_Poly_1Con_1Relation_initIDs
559 (JNIEnv* env, jclass j_poly_con_relation_class) {
560 jmethodID mID;
561 mID = env->GetMethodID(j_poly_con_relation_class, "<init>", "(I)V");
562 CHECK_RESULT_ASSERT(env, mID);
563 cached_FMIDs.Poly_Con_Relation_init_ID = mID;
564 }
565
566 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Poly_1Gen_1Relation_initIDs(JNIEnv * env,jclass j_poly_gen_relation_class)567 Java_parma_1polyhedra_1library_Poly_1Gen_1Relation_initIDs
568 (JNIEnv* env, jclass j_poly_gen_relation_class) {
569 jmethodID mID;
570 mID = env->GetMethodID(j_poly_gen_relation_class, "<init>", "(I)V");
571 CHECK_RESULT_ASSERT(env, mID);
572 cached_FMIDs.Poly_Gen_Relation_init_ID = mID;
573 }
574
575 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_PPL_1Object_initIDs(JNIEnv * env,jclass j_ppl_object_class)576 Java_parma_1polyhedra_1library_PPL_1Object_initIDs
577 (JNIEnv* env, jclass j_ppl_object_class) {
578 jfieldID fID = env->GetFieldID(j_ppl_object_class, "ptr", "J");
579 CHECK_RESULT_ASSERT(env, fID);
580 cached_FMIDs.PPL_Object_ptr_ID = fID;
581 }
582
583 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Relation_1Symbol_initIDs(JNIEnv * env,jclass j_rel_sym_class)584 Java_parma_1polyhedra_1library_Relation_1Symbol_initIDs
585 (JNIEnv* env, jclass j_rel_sym_class) {
586 jfieldID fID;
587 fID = env->GetStaticFieldID(j_rel_sym_class, "EQUAL",
588 "Lparma_polyhedra_library/Relation_Symbol;");
589 CHECK_RESULT_ASSERT(env, fID);
590 cached_FMIDs.Relation_Symbol_EQUAL_ID = fID;
591 fID = env->GetStaticFieldID(j_rel_sym_class, "GREATER_THAN",
592 "Lparma_polyhedra_library/Relation_Symbol;");
593 CHECK_RESULT_ASSERT(env, fID);
594 cached_FMIDs.Relation_Symbol_GREATER_THAN_ID = fID;
595 fID = env->GetStaticFieldID(j_rel_sym_class, "GREATER_OR_EQUAL",
596 "Lparma_polyhedra_library/Relation_Symbol;");
597 CHECK_RESULT_ASSERT(env, fID);
598 cached_FMIDs.Relation_Symbol_GREATER_OR_EQUAL_ID = fID;
599 jmethodID mID;
600 mID = env->GetMethodID(j_rel_sym_class, "ordinal", "()I");
601 CHECK_RESULT_ASSERT(env, mID);
602 cached_FMIDs.Relation_Symbol_ordinal_ID = mID;
603 }
604
605 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Bounded_1Integer_1Type_1Overflow_initIDs(JNIEnv * env,jclass j_bounded_overflow_class)606 Java_parma_1polyhedra_1library_Bounded_1Integer_1Type_1Overflow_initIDs
607 (JNIEnv* env, jclass j_bounded_overflow_class) {
608 jfieldID fID;
609 fID = env->GetStaticFieldID(j_bounded_overflow_class, "OVERFLOW_WRAPS",
610 "Lparma_polyhedra_library/Bounded_Integer_Type_Overflow;");
611 CHECK_RESULT_ASSERT(env, fID);
612 cached_FMIDs.Bounded_Integer_Type_Overflow_OVERFLOW_WRAPS_ID = fID;
613 fID = env->GetStaticFieldID(j_bounded_overflow_class, "OVERFLOW_UNDEFINED",
614 "Lparma_polyhedra_library/Bounded_Integer_Type_Overflow;");
615 CHECK_RESULT_ASSERT(env, fID);
616 cached_FMIDs.Bounded_Integer_Type_Overflow_OVERFLOW_UNDEFINED_ID = fID;
617 fID = env->GetStaticFieldID(j_bounded_overflow_class, "OVERFLOW_IMPOSSIBLE",
618 "Lparma_polyhedra_library/Bounded_Integer_Type_Overflow;");
619 CHECK_RESULT_ASSERT(env, fID);
620 cached_FMIDs.Bounded_Integer_Type_Overflow_OVERFLOW_IMPOSSIBLE_ID = fID;
621 jmethodID mID;
622 mID = env->GetMethodID(j_bounded_overflow_class, "ordinal", "()I");
623 CHECK_RESULT_ASSERT(env, mID);
624 cached_FMIDs.Bounded_Integer_Type_Overflow_ordinal_ID = mID;
625 }
626
627 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Bounded_1Integer_1Type_1Representation_initIDs(JNIEnv * env,jclass j_bounded_rep_class)628 Java_parma_1polyhedra_1library_Bounded_1Integer_1Type_1Representation_initIDs
629 (JNIEnv* env, jclass j_bounded_rep_class) {
630 jfieldID fID;
631 fID = env->GetStaticFieldID(j_bounded_rep_class, "UNSIGNED",
632 "Lparma_polyhedra_library/Bounded_Integer_Type_Representation;");
633 CHECK_RESULT_ASSERT(env, fID);
634 cached_FMIDs.Bounded_Integer_Type_Representation_UNSIGNED_ID = fID;
635 fID = env->GetStaticFieldID(j_bounded_rep_class, "SIGNED_2_COMPLEMENT",
636 "Lparma_polyhedra_library/Bounded_Integer_Type_Representation;");
637 CHECK_RESULT_ASSERT(env, fID);
638 cached_FMIDs.Bounded_Integer_Type_Representation_SIGNED_2_COMPLEMENT_ID = fID;
639 jmethodID mID;
640 mID = env->GetMethodID(j_bounded_rep_class, "ordinal", "()I");
641 CHECK_RESULT_ASSERT(env, mID);
642 cached_FMIDs.Bounded_Integer_Type_Representation_ordinal_ID = mID;
643 }
644
645 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Bounded_1Integer_1Type_1Width_initIDs(JNIEnv * env,jclass j_bounded_width_class)646 Java_parma_1polyhedra_1library_Bounded_1Integer_1Type_1Width_initIDs
647 (JNIEnv* env, jclass j_bounded_width_class) {
648 jfieldID fID;
649 fID = env->GetStaticFieldID(j_bounded_width_class, "BITS_8",
650 "Lparma_polyhedra_library/Bounded_Integer_Type_Width;");
651 CHECK_RESULT_ASSERT(env, fID);
652 cached_FMIDs.Bounded_Integer_Type_Width_BITS_8_ID = fID;
653 fID = env->GetStaticFieldID(j_bounded_width_class, "BITS_16",
654 "Lparma_polyhedra_library/Bounded_Integer_Type_Width;");
655 CHECK_RESULT_ASSERT(env, fID);
656 cached_FMIDs.Bounded_Integer_Type_Width_BITS_16_ID = fID;
657 fID = env->GetStaticFieldID(j_bounded_width_class, "BITS_32",
658 "Lparma_polyhedra_library/Bounded_Integer_Type_Width;");
659 CHECK_RESULT_ASSERT(env, fID);
660 cached_FMIDs.Bounded_Integer_Type_Width_BITS_32_ID = fID;
661 fID = env->GetStaticFieldID(j_bounded_width_class, "BITS_64",
662 "Lparma_polyhedra_library/Bounded_Integer_Type_Width;");
663 CHECK_RESULT_ASSERT(env, fID);
664 cached_FMIDs.Bounded_Integer_Type_Width_BITS_64_ID = fID;
665 fID = env->GetStaticFieldID(j_bounded_width_class, "BITS_128",
666 "Lparma_polyhedra_library/Bounded_Integer_Type_Width;");
667 CHECK_RESULT_ASSERT(env, fID);
668 cached_FMIDs.Bounded_Integer_Type_Width_BITS_128_ID = fID;
669 jmethodID mID;
670 mID = env->GetMethodID(j_bounded_width_class, "ordinal", "()I");
671 CHECK_RESULT_ASSERT(env, mID);
672 cached_FMIDs.Bounded_Integer_Type_Width_ordinal_ID = mID;
673 }
674
675 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Variable_initIDs(JNIEnv * env,jclass j_variable_class)676 Java_parma_1polyhedra_1library_Variable_initIDs
677 (JNIEnv* env, jclass j_variable_class) {
678 jfieldID fID = env->GetFieldID(j_variable_class, "varid", "J");
679 CHECK_RESULT_ASSERT(env, fID);
680 cached_FMIDs.Variable_varid_ID = fID;
681 fID = env->GetStaticFieldID(j_variable_class, "stringifier",
682 "Lparma_polyhedra_library/Variable_Stringifier;");
683 CHECK_RESULT_ASSERT(env, fID);
684 cached_FMIDs.Variable_stringifier_ID = fID;
685 jmethodID mID = env->GetMethodID(j_variable_class, "<init>", "(J)V");
686 CHECK_RESULT_ASSERT(env, mID);
687 cached_FMIDs.Variable_init_ID = mID;
688 }
689
690 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Variables_1Set_initIDs(JNIEnv * env,jclass j_vset_class)691 Java_parma_1polyhedra_1library_Variables_1Set_initIDs
692 (JNIEnv* env, jclass j_vset_class) {
693 jmethodID mID;
694 mID = env->GetMethodID(j_vset_class, "<init>", "()V");
695 CHECK_RESULT_ASSERT(env, mID);
696 cached_FMIDs.Variables_Set_init_ID = mID;
697 mID = env->GetMethodID(j_vset_class, "add", "(Ljava/lang/Object;)Z");
698 CHECK_RESULT_ASSERT(env, mID);
699 cached_FMIDs.Variables_Set_add_ID = mID;
700 mID = env->GetMethodID(j_vset_class, "iterator", "()Ljava/util/Iterator;");
701 CHECK_RESULT_ASSERT(env, mID);
702 cached_FMIDs.Variables_Set_iterator_ID = mID;
703 // Iterator on Variables_Set.
704 jclass j_vset_iter_class = env->FindClass("java/util/Iterator");
705 CHECK_RESULT_ASSERT(env, j_vset_iter_class);
706 mID = env->GetMethodID(j_vset_iter_class, "hasNext", "()Z");
707 CHECK_RESULT_ASSERT(env, mID);
708 cached_FMIDs.Variables_Set_Iterator_has_next_ID = mID;
709 mID = env->GetMethodID(j_vset_iter_class, "next", "()Ljava/lang/Object;");
710 CHECK_RESULT_ASSERT(env, mID);
711 cached_FMIDs.Variables_Set_Iterator_next_ID = mID;
712 }
713
714
715 JNIEXPORT jint JNICALL
Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_version_1major(JNIEnv *,jclass)716 Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_version_1major
717 (JNIEnv *, jclass) {
718 return version_major();
719 }
720
721 JNIEXPORT jint JNICALL
Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_version_1minor(JNIEnv *,jclass)722 Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_version_1minor
723 (JNIEnv *, jclass) {
724 return version_minor();
725 }
726
727 JNIEXPORT jint JNICALL
Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_version_1revision(JNIEnv *,jclass)728 Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_version_1revision
729 (JNIEnv *, jclass) {
730 return version_revision();
731 }
732
733 JNIEXPORT jint JNICALL
Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_version_1beta(JNIEnv *,jclass)734 Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_version_1beta
735 (JNIEnv *, jclass) {
736 return version_beta();
737 }
738
739 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_version(JNIEnv * env,jclass)740 Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_version
741 (JNIEnv* env, jclass) {
742 #if defined(__sun) || defined(__sun__)
743
744 // Some versions of Solaris declare a version() function that causes
745 // the following function call to be ambiguous.
746 return env->NewStringUTF(Parma_Polyhedra_Library::version());
747
748 #else // !(defined(__sun) || defined(__sun__))
749
750 return env->NewStringUTF(version());
751
752 #endif // !(defined(__sun) || defined(__sun__))
753 }
754
755 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_banner(JNIEnv * env,jclass)756 Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_banner
757 (JNIEnv* env, jclass) {
758 return env->NewStringUTF(banner());
759 }
760
761 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_set_1rounding_1for_1PPL(JNIEnv * env,jclass)762 Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_set_1rounding_1for_1PPL
763 (JNIEnv* env, jclass) {
764 try {
765 set_rounding_for_PPL();
766 }
767 CATCH_ALL;
768 }
769
770 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_restore_1pre_1PPL_1rounding(JNIEnv * env,jclass)771 Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_restore_1pre_1PPL_1rounding
772 (JNIEnv* env, jclass) {
773 try {
774 restore_pre_PPL_rounding();
775 }
776 CATCH_ALL;
777 }
778
779 JNIEXPORT jint JNICALL
Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_irrational_1precision(JNIEnv * env,jclass)780 Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_irrational_1precision
781 (JNIEnv* env , jclass) {
782 try {
783 return irrational_precision();
784 }
785 CATCH_ALL;
786 return 0;
787 }
788
789 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_set_1irrational_1precision(JNIEnv * env,jclass,jint p)790 Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_set_1irrational_1precision
791 (JNIEnv* env , jclass, jint p) {
792 try {
793 unsigned cxx_p = jtype_to_unsigned<unsigned>(p);
794 set_irrational_precision(cxx_p);
795 }
796 CATCH_ALL;
797 }
798
799 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_set_1timeout(JNIEnv * env,jclass,jint csecs)800 Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_set_1timeout
801 (JNIEnv* env, jclass, jint csecs) {
802 try {
803 // In case a timeout was already set.
804 reset_timeout();
805 assert(csecs > 0);
806 unsigned cxx_csecs = jtype_to_unsigned<unsigned>(csecs);
807 assert(cxx_csecs > 0);
808 static timeout_exception e;
809 using Parma_Polyhedra_Library::Watchdog;
810 p_timeout_object
811 = new Watchdog(cxx_csecs, abandon_expensive_computations, e);
812 }
813 CATCH_ALL;
814 }
815
816 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_reset_1timeout(JNIEnv * env,jclass)817 Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_reset_1timeout
818 (JNIEnv* env, jclass) {
819 try {
820 reset_timeout();
821 }
822 CATCH_ALL;
823 }
824
825 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_set_1deterministic_1timeout(JNIEnv * env,jclass,jint unscaled_weight,jint scale)826 Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_set_1deterministic_1timeout
827 (JNIEnv* env, jclass, jint unscaled_weight, jint scale) {
828 try {
829 // In case a timeout was already set.
830 reset_deterministic_timeout();
831 // Note: let `unscaled_weight == 0' result in an exception.
832 assert(unscaled_weight >= 0 && scale >= 0);
833 unsigned long cxx_unscaled_weight
834 = jtype_to_unsigned<unsigned long>(unscaled_weight);
835 unsigned cxx_scale = jtype_to_unsigned<unsigned>(scale);
836 static deterministic_timeout_exception e;
837 typedef Parma_Polyhedra_Library::Weightwatch_Traits Traits;
838 p_deterministic_timeout_object
839 = new Weightwatch(Traits::compute_delta(cxx_unscaled_weight, cxx_scale),
840 abandon_expensive_computations, e);
841 }
842 CATCH_ALL;
843 }
844
845 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_reset_1deterministic_1timeout(JNIEnv * env,jclass)846 Java_parma_1polyhedra_1library_Parma_1Polyhedra_1Library_reset_1deterministic_1timeout
847 (JNIEnv* env, jclass) {
848 try {
849 reset_deterministic_timeout();
850 }
851 CATCH_ALL;
852 }
853
854 JNIEXPORT jlong JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_max_1space_1dimension(JNIEnv * env,jobject j_this_mip_problem)855 Java_parma_1polyhedra_1library_MIP_1Problem_max_1space_1dimension
856 (JNIEnv* env , jobject j_this_mip_problem) {
857 try {
858 MIP_Problem* mip
859 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
860 return mip->max_space_dimension();
861 }
862 CATCH_ALL;
863 return 0;
864 }
865
866 JNIEXPORT jlong JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_space_1dimension(JNIEnv * env,jobject j_this_mip_problem)867 Java_parma_1polyhedra_1library_MIP_1Problem_space_1dimension
868 (JNIEnv* env , jobject j_this_mip_problem) {
869 try {
870 MIP_Problem* mip
871 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
872 return mip->space_dimension();
873 }
874 CATCH_ALL;
875 return 0;
876 }
877
878 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_integer_1space_1dimensions(JNIEnv * env,jobject j_this_mip_problem)879 Java_parma_1polyhedra_1library_MIP_1Problem_integer_1space_1dimensions
880 (JNIEnv* env , jobject j_this_mip_problem) {
881 try {
882 MIP_Problem* mip
883 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
884 return build_java_variables_set(env, mip->integer_space_dimensions());
885 }
886 CATCH_ALL;
887 jobject null = 0;
888 return null;
889 }
890
891 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_objective_1function(JNIEnv * env,jobject j_this_mip_problem)892 Java_parma_1polyhedra_1library_MIP_1Problem_objective_1function
893 (JNIEnv* env , jobject j_this_mip_problem) {
894 try {
895 MIP_Problem* mip
896 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
897 PPL_DIRTY_TEMP_COEFFICIENT(inhomogeneous_term);
898 inhomogeneous_term = mip->objective_function().inhomogeneous_term();
899 jobject j_coeff_inhomogeneous_term
900 = build_java_coeff(env, inhomogeneous_term);
901 jobject j_le_coeff
902 = env->NewObject(cached_classes.Linear_Expression_Coefficient,
903 cached_FMIDs.Linear_Expression_Coefficient_init_ID,
904 j_coeff_inhomogeneous_term);
905 CHECK_RESULT_RETURN(env, j_le_coeff, 0);
906
907 jobject j_le = build_linear_expression(env, mip->objective_function());
908 return env->CallObjectMethod(j_le,
909 cached_FMIDs.Linear_Expression_sum_ID,
910 j_le_coeff);
911 }
912 CATCH_ALL;
913 jobject null = 0;
914 return null;
915 }
916
917 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_optimization_1mode(JNIEnv * env,jobject j_this_mip_problem)918 Java_parma_1polyhedra_1library_MIP_1Problem_optimization_1mode
919 (JNIEnv* env , jobject j_this_mip_problem) {
920 try {
921 MIP_Problem* mip
922 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
923 return build_java_optimization_mode(env, mip->optimization_mode());
924 }
925 CATCH_ALL;
926 jobject null = 0;
927 return null;
928 }
929
930 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_get_1control_1parameter(JNIEnv * env,jobject j_this_mip_problem,jobject j_cpn)931 Java_parma_1polyhedra_1library_MIP_1Problem_get_1control_1parameter
932 (JNIEnv* env , jobject j_this_mip_problem,
933 jobject j_cpn) {
934 try {
935 MIP_Problem* mip
936 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
937 MIP_Problem::Control_Parameter_Name cpn
938 = build_cxx_control_parameter_name(env, j_cpn);
939 return
940 build_java_control_parameter_value(env,
941 mip->get_control_parameter(cpn));
942 }
943 CATCH_ALL;
944 jobject null = 0;
945 return null;
946 }
947
948 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_set_1control_1parameter(JNIEnv * env,jobject j_this_mip_problem,jobject j_cpv)949 Java_parma_1polyhedra_1library_MIP_1Problem_set_1control_1parameter
950 (JNIEnv* env , jobject j_this_mip_problem,
951 jobject j_cpv) {
952 try {
953 MIP_Problem* mip
954 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
955 MIP_Problem::Control_Parameter_Value cpv
956 = build_cxx_control_parameter_value(env, j_cpv);
957 mip->set_control_parameter(cpv);
958 }
959 CATCH_ALL;
960 }
961
962 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_constraints(JNIEnv * env,jobject j_this_mip_problem)963 Java_parma_1polyhedra_1library_MIP_1Problem_constraints
964 (JNIEnv* env, jobject j_this_mip_problem) {
965 try {
966 jobject j_cs = env->NewObject(cached_classes.Constraint_System,
967 cached_FMIDs.Constraint_System_init_ID);
968 CHECK_RESULT_RETURN(env, j_cs, 0);
969
970 MIP_Problem* mip
971 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
972 for (MIP_Problem::const_iterator cs_it = mip->constraints_begin(),
973 cs_end = mip->constraints_end(); cs_it != cs_end; ++cs_it) {
974 jobject j_constraint = build_java_constraint(env, *cs_it);
975 env->CallBooleanMethod(j_cs,
976 cached_FMIDs.Constraint_System_add_ID,
977 j_constraint);
978 CHECK_EXCEPTION_RETURN(env, 0);
979 }
980 return j_cs;
981 }
982 CATCH_ALL;
983 jobject null = 0;
984 return null;
985 }
986
987 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_clear(JNIEnv * env,jobject j_this_mip_problem)988 Java_parma_1polyhedra_1library_MIP_1Problem_clear
989 (JNIEnv* env , jobject j_this_mip_problem) {
990 try {
991 MIP_Problem* mip
992 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
993 mip->clear();
994 }
995 CATCH_ALL;
996 }
997
998 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_add_1space_1dimensions_1and_1embed(JNIEnv * env,jobject j_this_mip_problem,jlong j_dim)999 Java_parma_1polyhedra_1library_MIP_1Problem_add_1space_1dimensions_1and_1embed
1000 (JNIEnv* env , jobject j_this_mip_problem, jlong j_dim) {
1001 try {
1002 MIP_Problem* mip
1003 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
1004 dimension_type ppl_dim = jtype_to_unsigned<dimension_type>(j_dim);
1005 mip->add_space_dimensions_and_embed(ppl_dim);
1006 }
1007 CATCH_ALL;
1008 }
1009
1010 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_add_1to_1integer_1space_1dimensions(JNIEnv * env,jobject j_this_mip_problem,jobject j_vset)1011 Java_parma_1polyhedra_1library_MIP_1Problem_add_1to_1integer_1space_1dimensions
1012 (JNIEnv* env , jobject j_this_mip_problem, jobject j_vset) {
1013 try {
1014 MIP_Problem* mip
1015 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
1016 Variables_Set v_set = build_cxx_variables_set(env, j_vset);
1017 mip->add_to_integer_space_dimensions(v_set);
1018 }
1019 CATCH_ALL;
1020 }
1021
1022 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_add_1constraint(JNIEnv * env,jobject j_this_mip_problem,jobject j_c)1023 Java_parma_1polyhedra_1library_MIP_1Problem_add_1constraint
1024 (JNIEnv* env , jobject j_this_mip_problem, jobject j_c) {
1025 try {
1026 MIP_Problem* mip
1027 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
1028 Constraint c = build_cxx_constraint(env, j_c);
1029 mip->add_constraint(c);
1030 }
1031 CATCH_ALL;
1032 }
1033
1034 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_add_1constraints(JNIEnv * env,jobject j_this_mip_problem,jobject j_cs)1035 Java_parma_1polyhedra_1library_MIP_1Problem_add_1constraints
1036 (JNIEnv* env , jobject j_this_mip_problem, jobject j_cs) {
1037 try {
1038 MIP_Problem* mip
1039 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
1040 Constraint_System cs = build_cxx_constraint_system(env, j_cs);
1041 mip->add_constraints(cs);
1042 }
1043 CATCH_ALL;
1044 }
1045
1046 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_set_1objective_1function(JNIEnv * env,jobject j_this_mip_problem,jobject j_le)1047 Java_parma_1polyhedra_1library_MIP_1Problem_set_1objective_1function
1048 (JNIEnv* env , jobject j_this_mip_problem, jobject j_le) {
1049 try {
1050 MIP_Problem* mip
1051 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
1052 Linear_Expression le = build_cxx_linear_expression(env, j_le);
1053 mip->set_objective_function(le);
1054 }
1055 CATCH_ALL;
1056 }
1057
1058 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_set_1optimization_1mode(JNIEnv * env,jobject j_this_mip_problem,jobject j_opt_mode)1059 Java_parma_1polyhedra_1library_MIP_1Problem_set_1optimization_1mode
1060 (JNIEnv* env , jobject j_this_mip_problem, jobject j_opt_mode) {
1061 try {
1062 MIP_Problem* mip
1063 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
1064 Optimization_Mode opt_mode = build_cxx_optimization_mode(env, j_opt_mode);
1065 mip->set_optimization_mode(opt_mode);
1066 }
1067 CATCH_ALL;
1068 }
1069
1070 JNIEXPORT jboolean JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_is_1satisfiable(JNIEnv * env,jobject j_this_mip_problem)1071 Java_parma_1polyhedra_1library_MIP_1Problem_is_1satisfiable
1072 (JNIEnv* env , jobject j_this_mip_problem) {
1073 try {
1074 MIP_Problem* mip
1075 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
1076 return mip->is_satisfiable();
1077 }
1078 CATCH_ALL;
1079 return false;
1080 }
1081
Java_parma_1polyhedra_1library_MIP_1Problem_solve(JNIEnv * env,jobject j_this_mip_problem)1082 JNIEXPORT jobject JNICALL Java_parma_1polyhedra_1library_MIP_1Problem_solve
1083 (JNIEnv* env , jobject j_this_mip_problem) {
1084 try {
1085 MIP_Problem* mip
1086 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
1087 return build_java_mip_status(env, mip->solve());
1088 }
1089 CATCH_ALL;
1090 jobject null = 0;
1091 return null;
1092 }
1093
1094 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_evaluate_1objective_1function(JNIEnv * env,jobject j_this_mip_problem,jobject j_gen,jobject j_coeff_num,jobject j_coeff_den)1095 Java_parma_1polyhedra_1library_MIP_1Problem_evaluate_1objective_1function
1096 (JNIEnv* env, jobject j_this_mip_problem, jobject j_gen,
1097 jobject j_coeff_num, jobject j_coeff_den) {
1098 try {
1099 MIP_Problem* mip
1100 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
1101 Generator g = build_cxx_generator(env, j_gen);
1102 PPL_DIRTY_TEMP_COEFFICIENT(num);
1103 PPL_DIRTY_TEMP_COEFFICIENT(den);
1104 mip->evaluate_objective_function(g, num, den);
1105 set_coefficient(env, j_coeff_num, build_java_coeff(env, num));
1106 set_coefficient(env, j_coeff_den, build_java_coeff(env, den));
1107 }
1108 CATCH_ALL;
1109 }
1110
1111 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_feasible_1point(JNIEnv * env,jobject j_this_mip_problem)1112 Java_parma_1polyhedra_1library_MIP_1Problem_feasible_1point
1113 (JNIEnv* env , jobject j_this_mip_problem) {
1114 try {
1115 MIP_Problem* mip
1116 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
1117 Generator g = mip->feasible_point();
1118 return build_java_generator(env, g);
1119 }
1120 CATCH_ALL;
1121 jobject null = 0;
1122 return null;
1123 }
1124
1125 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_optimizing_1point(JNIEnv * env,jobject j_this_mip_problem)1126 Java_parma_1polyhedra_1library_MIP_1Problem_optimizing_1point
1127 (JNIEnv* env , jobject j_this_mip_problem) {
1128 try {
1129 MIP_Problem* mip
1130 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
1131 Generator g = mip->optimizing_point();
1132 return build_java_generator(env, g);
1133 }
1134 CATCH_ALL;
1135 jobject null = 0;
1136 return null;
1137 }
1138
1139 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_optimal_1value(JNIEnv * env,jobject j_this_mip_problem,jobject j_coeff_num,jobject j_coeff_den)1140 Java_parma_1polyhedra_1library_MIP_1Problem_optimal_1value
1141 (JNIEnv* env, jobject j_this_mip_problem,
1142 jobject j_coeff_num, jobject j_coeff_den) {
1143 try {
1144 PPL_DIRTY_TEMP_COEFFICIENT(coeff_num);
1145 PPL_DIRTY_TEMP_COEFFICIENT(coeff_den);
1146 MIP_Problem* mip
1147 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
1148 mip->optimal_value(coeff_num, coeff_den);
1149 set_coefficient(env, j_coeff_num, build_java_coeff(env, coeff_num));
1150 set_coefficient(env, j_coeff_den, build_java_coeff(env, coeff_den));
1151 }
1152 CATCH_ALL;
1153 }
1154
1155 JNIEXPORT jboolean JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_OK(JNIEnv * env,jobject j_this_mip_problem)1156 Java_parma_1polyhedra_1library_MIP_1Problem_OK
1157 (JNIEnv* env , jobject j_this_mip_problem) {
1158 try {
1159 MIP_Problem* mip
1160 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
1161 return mip->OK();
1162 }
1163 CATCH_ALL;
1164 return false;
1165 }
1166
1167 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_build_1cpp_1object__J(JNIEnv * env,jobject j_this_mip_problem,jlong j_dim)1168 Java_parma_1polyhedra_1library_MIP_1Problem_build_1cpp_1object__J
1169 (JNIEnv* env, jobject j_this_mip_problem, jlong j_dim) {
1170 try {
1171 dimension_type ppl_dim = jtype_to_unsigned<dimension_type>(j_dim);
1172 MIP_Problem* mip_ptr = new MIP_Problem(ppl_dim);
1173 set_ptr(env, j_this_mip_problem, mip_ptr);
1174 }
1175 CATCH_ALL;
1176 }
1177
1178 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_build_1cpp_1object__JLparma_1polyhedra_1library_Constraint_1System_2Lparma_1polyhedra_1library_Linear_1Expression_2Lparma_1polyhedra_1library_Optimization_1Mode_2(JNIEnv * env,jobject j_this_mip_problem,jlong j_dim,jobject j_cs,jobject j_le,jobject j_opt_mode)1179 Java_parma_1polyhedra_1library_MIP_1Problem_build_1cpp_1object__JLparma_1polyhedra_1library_Constraint_1System_2Lparma_1polyhedra_1library_Linear_1Expression_2Lparma_1polyhedra_1library_Optimization_1Mode_2
1180 (JNIEnv* env , jobject j_this_mip_problem, jlong j_dim, jobject j_cs,
1181 jobject j_le, jobject j_opt_mode) {
1182 try {
1183 dimension_type ppl_dim = jtype_to_unsigned<dimension_type>(j_dim);
1184 Constraint_System cs = build_cxx_constraint_system(env, j_cs);
1185 Linear_Expression le = build_cxx_linear_expression(env, j_le);
1186 Optimization_Mode opt_mode = build_cxx_optimization_mode(env, j_opt_mode);
1187 MIP_Problem* mip_ptr = new MIP_Problem(ppl_dim, cs, le, opt_mode);
1188 set_ptr(env, j_this_mip_problem, mip_ptr);
1189 }
1190 CATCH_ALL;
1191 }
1192
1193 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_build_1cpp_1object__Lparma_1polyhedra_1library_MIP_1Problem_2(JNIEnv * env,jobject j_this,jobject j_y)1194 Java_parma_1polyhedra_1library_MIP_1Problem_build_1cpp_1object__Lparma_1polyhedra_1library_MIP_1Problem_2
1195 (JNIEnv* env, jobject j_this, jobject j_y)
1196 {
1197 MIP_Problem* y_ptr = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_y));
1198 MIP_Problem* this_ptr = new MIP_Problem(*y_ptr);
1199 set_ptr(env, j_this, this_ptr);
1200 }
1201
1202 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_free(JNIEnv * env,jobject j_this)1203 Java_parma_1polyhedra_1library_MIP_1Problem_free
1204 (JNIEnv* env, jobject j_this) {
1205 MIP_Problem* mip = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this));
1206 if (!is_java_marked(env, j_this)) {
1207 delete mip;
1208 void* null_ptr = 0;
1209 set_ptr(env, j_this, null_ptr);
1210 }
1211 }
1212
1213 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_finalize(JNIEnv * env,jobject j_this)1214 Java_parma_1polyhedra_1library_MIP_1Problem_finalize
1215 (JNIEnv* env, jobject j_this) {
1216 MIP_Problem* mip = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this));
1217 if (!is_java_marked(env, j_this))
1218 delete mip;
1219 }
1220
1221 JNIEXPORT jlong JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_total_1memory_1in_1bytes(JNIEnv * env,jobject j_this_mip_problem)1222 Java_parma_1polyhedra_1library_MIP_1Problem_total_1memory_1in_1bytes
1223 (JNIEnv* env , jobject j_this_mip_problem) {
1224 try {
1225 MIP_Problem* mip
1226 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem));
1227 return mip->total_memory_in_bytes();
1228 }
1229 CATCH_ALL;
1230 return 0;
1231 }
1232
1233 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_toString(JNIEnv * env,jobject j_this)1234 Java_parma_1polyhedra_1library_MIP_1Problem_toString
1235 (JNIEnv* env, jobject j_this) {
1236 MIP_Problem* this_ptr
1237 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this));
1238 using namespace Parma_Polyhedra_Library::IO_Operators;
1239 std::ostringstream s;
1240 s << *this_ptr;
1241 return env->NewStringUTF(s.str().c_str());
1242 }
1243
1244 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_MIP_1Problem_ascii_1dump(JNIEnv * env,jobject j_this)1245 Java_parma_1polyhedra_1library_MIP_1Problem_ascii_1dump
1246 (JNIEnv* env, jobject j_this) {
1247 try {
1248 MIP_Problem* this_ptr
1249 = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this));
1250 std::ostringstream s;
1251 this_ptr->ascii_dump(s);
1252 return env->NewStringUTF(s.str().c_str());
1253 }
1254 CATCH_ALL;
1255 return 0;
1256 }
1257
1258 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Variable_toString(JNIEnv * env,jobject j_this)1259 Java_parma_1polyhedra_1library_Variable_toString
1260 (JNIEnv* env, jobject j_this) {
1261 using namespace Parma_Polyhedra_Library::IO_Operators;
1262 Variable ppl_var = build_cxx_variable(env, j_this);
1263 std::ostringstream s;
1264 s << ppl_var;
1265 return env->NewStringUTF(s.str().c_str());
1266 }
1267
1268 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Variable_setStringifier(JNIEnv * env,jclass j_variable_class,jobject j_stringifier)1269 Java_parma_1polyhedra_1library_Variable_setStringifier
1270 (JNIEnv* env, jclass j_variable_class, jobject j_stringifier) {
1271 // Store j_stringifier in the corresponding static field.
1272 env->SetStaticObjectField(j_variable_class,
1273 cached_FMIDs.Variable_stringifier_ID,
1274 j_stringifier);
1275 if (j_stringifier == NULL) {
1276 // No stringifier object: reset cache values.
1277 cached_classes.Variable_Stringifier = NULL;
1278 cached_FMIDs.Variable_Stringifier_stringify_ID = NULL;
1279 // Reset default C++ output function.
1280 Variable::set_output_function(&Variable::default_output_function);
1281 }
1282 else {
1283 // Update cache with values computed for concrete class.
1284 jclass vs_class = env->GetObjectClass(j_stringifier);
1285 CHECK_RESULT_ASSERT(env, vs_class);
1286 cached_classes.Variable_Stringifier = vs_class;
1287 jmethodID mID = env->GetMethodID(vs_class, "stringify",
1288 "(J)Ljava/lang/String;");
1289 CHECK_RESULT_ASSERT(env, mID);
1290 cached_FMIDs.Variable_Stringifier_stringify_ID = mID;
1291 // Set C++ output function to the Java wrapper.
1292 Variable::set_output_function(&Java_Variable_output_function);
1293 }
1294 }
1295
1296 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Linear_1Expression_toString(JNIEnv * env,jobject j_this)1297 Java_parma_1polyhedra_1library_Linear_1Expression_toString
1298 (JNIEnv* env, jobject j_this) {
1299 using namespace Parma_Polyhedra_Library::IO_Operators;
1300 Linear_Expression ppl_le = build_cxx_linear_expression(env, j_this);
1301 std::ostringstream s;
1302 s << ppl_le;
1303 return env->NewStringUTF(s.str().c_str());
1304 }
1305
1306 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Linear_1Expression_ascii_1dump(JNIEnv * env,jobject j_this)1307 Java_parma_1polyhedra_1library_Linear_1Expression_ascii_1dump
1308 (JNIEnv* env, jobject j_this) {
1309 try {
1310 std::ostringstream s;
1311 Linear_Expression le = build_cxx_linear_expression(env, j_this);
1312 le.ascii_dump(s);
1313 return env->NewStringUTF(s.str().c_str());
1314 }
1315 CATCH_ALL;
1316 return 0;
1317 }
1318
1319 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Generator_toString(JNIEnv * env,jobject g)1320 Java_parma_1polyhedra_1library_Generator_toString
1321 (JNIEnv* env, jobject g) {
1322 using namespace Parma_Polyhedra_Library::IO_Operators;
1323 std::ostringstream s;
1324 Generator ppl_g = build_cxx_generator(env, g);
1325 s << ppl_g;
1326 return env->NewStringUTF(s.str().c_str());
1327 }
1328
1329 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Generator_ascii_1dump(JNIEnv * env,jobject j_this)1330 Java_parma_1polyhedra_1library_Generator_ascii_1dump
1331 (JNIEnv* env, jobject j_this) {
1332 try {
1333 std::ostringstream s;
1334 Generator g = build_cxx_generator(env, j_this);
1335 g.ascii_dump(s);
1336 return env->NewStringUTF(s.str().c_str());
1337 }
1338 CATCH_ALL;
1339 return 0;
1340 }
1341
1342 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Constraint_toString(JNIEnv * env,jobject c)1343 Java_parma_1polyhedra_1library_Constraint_toString
1344 (JNIEnv* env, jobject c) {
1345 using namespace Parma_Polyhedra_Library::IO_Operators;
1346 std::ostringstream s;
1347 Constraint ppl_c = build_cxx_constraint(env, c);
1348 s << ppl_c;
1349 return env->NewStringUTF(s.str().c_str());
1350 }
1351
1352 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Constraint_ascii_1dump(JNIEnv * env,jobject j_this)1353 Java_parma_1polyhedra_1library_Constraint_ascii_1dump
1354 (JNIEnv* env, jobject j_this) {
1355 try {
1356 std::ostringstream s;
1357 Constraint c = build_cxx_constraint(env, j_this);
1358 c.ascii_dump(s);
1359 return env->NewStringUTF(s.str().c_str());
1360 }
1361 CATCH_ALL;
1362 return 0;
1363 }
1364
1365 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Grid_1Generator_toString(JNIEnv * env,jobject g)1366 Java_parma_1polyhedra_1library_Grid_1Generator_toString
1367 (JNIEnv* env, jobject g) {
1368 using namespace Parma_Polyhedra_Library::IO_Operators;
1369 std::ostringstream s;
1370 Grid_Generator ppl_g = build_cxx_grid_generator(env, g);
1371 s << ppl_g;
1372 return env->NewStringUTF(s.str().c_str());
1373 }
1374
1375 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Grid_1Generator_ascii_1dump(JNIEnv * env,jobject j_this)1376 Java_parma_1polyhedra_1library_Grid_1Generator_ascii_1dump
1377 (JNIEnv* env, jobject j_this) {
1378 try {
1379 std::ostringstream s;
1380 Grid_Generator g = build_cxx_grid_generator(env, j_this);
1381 g.ascii_dump(s);
1382 return env->NewStringUTF(s.str().c_str());
1383 }
1384 CATCH_ALL;
1385 return 0;
1386 }
1387
1388 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Congruence_toString(JNIEnv * env,jobject g)1389 Java_parma_1polyhedra_1library_Congruence_toString
1390 (JNIEnv* env, jobject g) {
1391 using namespace Parma_Polyhedra_Library::IO_Operators;
1392 std::ostringstream s;
1393 Congruence ppl_g = build_cxx_congruence(env, g);
1394 s << ppl_g;
1395 return env->NewStringUTF(s.str().c_str());
1396 }
1397
1398 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Congruence_ascii_1dump(JNIEnv * env,jobject j_this)1399 Java_parma_1polyhedra_1library_Congruence_ascii_1dump
1400 (JNIEnv* env, jobject j_this) {
1401 try {
1402 std::ostringstream s;
1403 Congruence c = build_cxx_congruence(env, j_this);
1404 c.ascii_dump(s);
1405 return env->NewStringUTF(s.str().c_str());
1406 }
1407 CATCH_ALL;
1408 return 0;
1409 }
1410
1411 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Grid_1Generator_1System_toString(JNIEnv * env,jobject ggs)1412 Java_parma_1polyhedra_1library_Grid_1Generator_1System_toString
1413 (JNIEnv* env, jobject ggs) {
1414 using namespace Parma_Polyhedra_Library::IO_Operators;
1415 std::ostringstream s;
1416 Grid_Generator_System ppl_ggs = build_cxx_grid_generator_system(env, ggs);
1417 s << ppl_ggs;
1418 return env->NewStringUTF(s.str().c_str());
1419 }
1420
1421 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Grid_1Generator_1System_ascii_1dump(JNIEnv * env,jobject j_this)1422 Java_parma_1polyhedra_1library_Grid_1Generator_1System_ascii_1dump
1423 (JNIEnv* env, jobject j_this) {
1424 try {
1425 std::ostringstream s;
1426 Grid_Generator_System gs = build_cxx_grid_generator_system(env, j_this);
1427 gs.ascii_dump(s);
1428 return env->NewStringUTF(s.str().c_str());
1429 }
1430 CATCH_ALL;
1431 return 0;
1432 }
1433
1434 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Generator_1System_toString(JNIEnv * env,jobject gs)1435 Java_parma_1polyhedra_1library_Generator_1System_toString
1436 (JNIEnv* env, jobject gs) {
1437 using namespace Parma_Polyhedra_Library::IO_Operators;
1438 std::ostringstream s;
1439 Generator_System ppl_gs = build_cxx_generator_system(env, gs);
1440 s << ppl_gs;
1441 return env->NewStringUTF(s.str().c_str());
1442 }
1443
1444 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Generator_1System_ascii_1dump(JNIEnv * env,jobject j_this)1445 Java_parma_1polyhedra_1library_Generator_1System_ascii_1dump
1446 (JNIEnv* env, jobject j_this) {
1447 try {
1448 std::ostringstream s;
1449 Generator_System gs = build_cxx_generator_system(env, j_this);
1450 gs.ascii_dump(s);
1451 return env->NewStringUTF(s.str().c_str());
1452 }
1453 CATCH_ALL;
1454 return 0;
1455 }
1456
1457 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Constraint_1System_toString(JNIEnv * env,jobject cs)1458 Java_parma_1polyhedra_1library_Constraint_1System_toString
1459 (JNIEnv* env, jobject cs) {
1460 using namespace Parma_Polyhedra_Library::IO_Operators;
1461 std::ostringstream s;
1462 Constraint_System ppl_cs = build_cxx_constraint_system(env, cs);
1463 s << ppl_cs;
1464 return env->NewStringUTF(s.str().c_str());
1465 }
1466
1467
1468 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Constraint_1System_ascii_1dump(JNIEnv * env,jobject j_this)1469 Java_parma_1polyhedra_1library_Constraint_1System_ascii_1dump
1470 (JNIEnv* env, jobject j_this) {
1471 try {
1472 std::ostringstream s;
1473 Constraint_System cs = build_cxx_constraint_system(env, j_this);
1474 cs.ascii_dump(s);
1475 return env->NewStringUTF(s.str().c_str());
1476 }
1477 CATCH_ALL;
1478 return 0;
1479 }
1480
1481 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Congruence_1System_toString(JNIEnv * env,jobject cgs)1482 Java_parma_1polyhedra_1library_Congruence_1System_toString
1483 (JNIEnv* env, jobject cgs) {
1484 using namespace Parma_Polyhedra_Library::IO_Operators;
1485 std::ostringstream s;
1486 Congruence_System ppl_cgs = build_cxx_congruence_system(env, cgs);
1487 s << ppl_cgs;
1488 return env->NewStringUTF(s.str().c_str());
1489 }
1490
1491 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Congruence_1System_ascii_1dump(JNIEnv * env,jobject j_this)1492 Java_parma_1polyhedra_1library_Congruence_1System_ascii_1dump
1493 (JNIEnv* env, jobject j_this) {
1494 try {
1495 std::ostringstream s;
1496 Congruence_System cs = build_cxx_congruence_system(env, j_this);
1497 cs.ascii_dump(s);
1498 return env->NewStringUTF(s.str().c_str());
1499 }
1500 CATCH_ALL;
1501 return 0;
1502 }
1503
1504 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_IO_wrap_1string(JNIEnv * env,jclass,jstring str,jint indent_depth,jint preferred_first_line_length,jint preferred_line_length)1505 Java_parma_1polyhedra_1library_IO_wrap_1string
1506 (JNIEnv* env, jclass, jstring str, jint indent_depth,
1507 jint preferred_first_line_length, jint preferred_line_length) {
1508 try {
1509 unsigned ind = jtype_to_unsigned<unsigned int>(indent_depth);
1510 unsigned pfll = jtype_to_unsigned<unsigned int>
1511 (preferred_first_line_length);
1512 unsigned pll = jtype_to_unsigned<unsigned int>(preferred_line_length);
1513 const char* chars = env->GetStringUTFChars(str, 0);
1514 CHECK_RESULT_RETURN(env, chars, 0);
1515 using namespace Parma_Polyhedra_Library::IO_Operators;
1516 std::string s = wrap_string(chars, ind, pfll, pll);
1517 env->ReleaseStringUTFChars(str, chars);
1518 return env->NewStringUTF(s.c_str());
1519 }
1520 CATCH_ALL;
1521 return 0;
1522 }
1523
1524 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_build_1cpp_1object__J(JNIEnv * env,jobject j_this_pip_problem,jlong j_dim)1525 Java_parma_1polyhedra_1library_PIP_1Problem_build_1cpp_1object__J
1526 (JNIEnv* env, jobject j_this_pip_problem, jlong j_dim) {
1527 try {
1528 dimension_type ppl_dim = jtype_to_unsigned<dimension_type>(j_dim);
1529 PIP_Problem* pip_ptr = new PIP_Problem(ppl_dim);
1530 set_ptr(env, j_this_pip_problem, pip_ptr);
1531 }
1532 CATCH_ALL;
1533 }
1534
1535 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_build_1cpp_1object__JLparma_1polyhedra_1library_Constraint_1System_2Lparma_1polyhedra_1library_Variables_1Set_2(JNIEnv * env,jobject j_this_pip_problem,jlong j_dim,jobject j_cs,jobject j_vars)1536 Java_parma_1polyhedra_1library_PIP_1Problem_build_1cpp_1object__JLparma_1polyhedra_1library_Constraint_1System_2Lparma_1polyhedra_1library_Variables_1Set_2
1537 (JNIEnv* env , jobject j_this_pip_problem, jlong j_dim,
1538 jobject j_cs, jobject j_vars) {
1539 try {
1540 dimension_type p_dim = jtype_to_unsigned<dimension_type>(j_dim);
1541 Constraint_System p_cs = build_cxx_constraint_system(env, j_cs);
1542 Variables_Set p_vars = build_cxx_variables_set(env, j_vars);
1543 PIP_Problem* pip_ptr = new PIP_Problem(p_dim, p_cs.begin(),
1544 p_cs.end(), p_vars);
1545 set_ptr(env, j_this_pip_problem, pip_ptr);
1546 }
1547 CATCH_ALL;
1548 }
1549
1550 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_build_1cpp_1object__Lparma_1polyhedra_1library_PIP_1Problem_2(JNIEnv * env,jobject j_this,jobject j_y)1551 Java_parma_1polyhedra_1library_PIP_1Problem_build_1cpp_1object__Lparma_1polyhedra_1library_PIP_1Problem_2
1552 (JNIEnv* env, jobject j_this, jobject j_y)
1553 {
1554 PIP_Problem* y_ptr = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_y));
1555 PIP_Problem* this_ptr = new PIP_Problem(*y_ptr);
1556 set_ptr(env, j_this, this_ptr);
1557 }
1558
1559 JNIEXPORT jboolean JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_OK(JNIEnv * env,jobject j_this_pip_problem)1560 Java_parma_1polyhedra_1library_PIP_1Problem_OK
1561 (JNIEnv* env , jobject j_this_pip_problem) {
1562 try {
1563 PIP_Problem* pip
1564 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1565 return pip->OK();
1566 }
1567 CATCH_ALL;
1568 return false;
1569 }
1570
1571 JNIEXPORT jlong JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_total_1memory_1in_1bytes(JNIEnv * env,jobject j_this_pip_problem)1572 Java_parma_1polyhedra_1library_PIP_1Problem_total_1memory_1in_1bytes
1573 (JNIEnv* env , jobject j_this_pip_problem) {
1574 try {
1575 PIP_Problem* pip
1576 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1577 return pip->total_memory_in_bytes();
1578 }
1579 CATCH_ALL;
1580 return 0;
1581 }
1582
1583 JNIEXPORT jlong JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_external_1memory_1in_1bytes(JNIEnv * env,jobject j_this_pip_problem)1584 Java_parma_1polyhedra_1library_PIP_1Problem_external_1memory_1in_1bytes
1585 (JNIEnv* env , jobject j_this_pip_problem) {
1586 try {
1587 PIP_Problem* pip
1588 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1589 return pip->external_memory_in_bytes();
1590 }
1591 CATCH_ALL;
1592 return 0;
1593 }
1594
1595 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_toString(JNIEnv * env,jobject j_this)1596 Java_parma_1polyhedra_1library_PIP_1Problem_toString
1597 (JNIEnv* env, jobject j_this) {
1598 PIP_Problem* this_ptr
1599 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this));
1600 using namespace Parma_Polyhedra_Library::IO_Operators;
1601 std::ostringstream s;
1602 s << *this_ptr;
1603 return env->NewStringUTF(s.str().c_str());
1604 }
1605
1606 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_ascii_1dump(JNIEnv * env,jobject j_this)1607 Java_parma_1polyhedra_1library_PIP_1Problem_ascii_1dump
1608 (JNIEnv* env, jobject j_this) {
1609 try {
1610 PIP_Problem* this_ptr
1611 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this));
1612 std::ostringstream s;
1613 this_ptr->ascii_dump(s);
1614 return env->NewStringUTF(s.str().c_str());
1615 }
1616 CATCH_ALL;
1617 return 0;
1618 }
1619
1620 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_free(JNIEnv * env,jobject j_this)1621 Java_parma_1polyhedra_1library_PIP_1Problem_free
1622 (JNIEnv* env, jobject j_this) {
1623 PIP_Problem* pip = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this));
1624 if (!is_java_marked(env, j_this)) {
1625 delete pip;
1626 void* null_ptr = 0;
1627 set_ptr(env, j_this, null_ptr);
1628 }
1629 }
1630
1631 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_PIP_1_problem_finalize(JNIEnv * env,jobject j_this)1632 Java_parma_1polyhedra_1library_PIP_1_problem_finalize
1633 (JNIEnv* env, jobject j_this) {
1634 PIP_Problem* pip = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this));
1635 if (!is_java_marked(env, j_this))
1636 delete pip;
1637 }
1638
1639 JNIEXPORT jlong JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_max_1space_1dimension(JNIEnv * env,jobject j_this_pip_problem)1640 Java_parma_1polyhedra_1library_PIP_1Problem_max_1space_1dimension
1641 (JNIEnv* env , jobject j_this_pip_problem) {
1642 try {
1643 PIP_Problem* pip
1644 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1645 return pip->max_space_dimension();
1646 }
1647 CATCH_ALL;
1648 return 0;
1649 }
1650
1651 JNIEXPORT jlong JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_space_1dimension(JNIEnv * env,jobject j_this_pip_problem)1652 Java_parma_1polyhedra_1library_PIP_1Problem_space_1dimension
1653 (JNIEnv* env , jobject j_this_pip_problem) {
1654 try {
1655 PIP_Problem* pip
1656 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1657 return pip->space_dimension();
1658 }
1659 CATCH_ALL;
1660 return 0;
1661 }
1662
1663 JNIEXPORT jlong JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_get_1big_1parameter_1dimension(JNIEnv * env,jobject j_this_pip_problem)1664 Java_parma_1polyhedra_1library_PIP_1Problem_get_1big_1parameter_1dimension
1665 (JNIEnv* env , jobject j_this_pip_problem) {
1666 try {
1667 PIP_Problem* pip
1668 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1669 return pip->get_big_parameter_dimension();
1670 }
1671 CATCH_ALL;
1672 return 0;
1673 }
1674
1675 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_parameter_1space_1dimensions(JNIEnv * env,jobject j_this_pip_problem)1676 Java_parma_1polyhedra_1library_PIP_1Problem_parameter_1space_1dimensions
1677 (JNIEnv* env , jobject j_this_pip_problem) {
1678 try {
1679 PIP_Problem* pip
1680 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1681 return build_java_variables_set(env, pip->parameter_space_dimensions());
1682 }
1683 CATCH_ALL;
1684 jobject null = 0;
1685 return null;
1686 }
1687
1688 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_set_1big_1parameter_1dimension(JNIEnv * env,jobject j_this_pip_problem,jlong j_dim)1689 Java_parma_1polyhedra_1library_PIP_1Problem_set_1big_1parameter_1dimension
1690 (JNIEnv* env , jobject j_this_pip_problem, jlong j_dim) {
1691 try {
1692 PIP_Problem* pip
1693 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1694 dimension_type ppl_dim = jtype_to_unsigned<dimension_type>(j_dim);
1695 pip->set_big_parameter_dimension(ppl_dim);
1696 }
1697 CATCH_ALL;
1698 }
1699
1700 JNIEXPORT jlong JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_number_1of_1parameter_1space_1dimensions(JNIEnv * env,jobject j_this_pip_problem)1701 Java_parma_1polyhedra_1library_PIP_1Problem_number_1of_1parameter_1space_1dimensions
1702 (JNIEnv* env , jobject j_this_pip_problem) {
1703 try {
1704 PIP_Problem* pip
1705 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1706 return pip->parameter_space_dimensions().size();
1707 }
1708 CATCH_ALL;
1709 return 0;
1710 }
1711
1712 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_add_1space_1dimensions_1and_1embed(JNIEnv * env,jobject j_this_pip_problem,jlong j_dim_vars,jlong j_dim_pars)1713 Java_parma_1polyhedra_1library_PIP_1Problem_add_1space_1dimensions_1and_1embed
1714 (JNIEnv* env , jobject j_this_pip_problem, jlong j_dim_vars, jlong j_dim_pars) {
1715 try {
1716 PIP_Problem* pip
1717 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1718 dimension_type ppl_dim_vars = jtype_to_unsigned<dimension_type>(j_dim_vars);
1719 dimension_type ppl_dim_pars = jtype_to_unsigned<dimension_type>(j_dim_pars);
1720 pip->add_space_dimensions_and_embed(ppl_dim_vars, ppl_dim_pars);
1721 }
1722 CATCH_ALL;
1723 }
1724
1725 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_add_1to_1parameter_1space_1dimensions(JNIEnv * env,jobject j_this_pip_problem,jobject j_vars)1726 Java_parma_1polyhedra_1library_PIP_1Problem_add_1to_1parameter_1space_1dimensions
1727 (JNIEnv* env , jobject j_this_pip_problem, jobject j_vars) {
1728 try {
1729 PIP_Problem* pip
1730 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1731 Variables_Set ppl_vars = build_cxx_variables_set(env, j_vars);
1732 pip->add_to_parameter_space_dimensions(ppl_vars);
1733 }
1734 CATCH_ALL;
1735 }
1736
1737 JNIEXPORT jlong JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_number_1of_1constraints(JNIEnv * env,jobject j_this_pip_problem)1738 Java_parma_1polyhedra_1library_PIP_1Problem_number_1of_1constraints
1739 (JNIEnv* env , jobject j_this_pip_problem) {
1740 try {
1741 PIP_Problem* pip
1742 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1743 return pip->constraints_end() - pip->constraints_begin();
1744 }
1745 CATCH_ALL;
1746 return 0;
1747 }
1748
1749 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_add_1constraint(JNIEnv * env,jobject j_this_pip_problem,jobject j_c)1750 Java_parma_1polyhedra_1library_PIP_1Problem_add_1constraint
1751 (JNIEnv* env , jobject j_this_pip_problem, jobject j_c) {
1752 try {
1753 PIP_Problem* pip
1754 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1755 Constraint c = build_cxx_constraint(env, j_c);
1756 pip->add_constraint(c);
1757 }
1758 CATCH_ALL;
1759 }
1760
1761 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_add_1constraints(JNIEnv * env,jobject j_this_pip_problem,jobject j_cs)1762 Java_parma_1polyhedra_1library_PIP_1Problem_add_1constraints
1763 (JNIEnv* env , jobject j_this_pip_problem, jobject j_cs) {
1764 try {
1765 PIP_Problem* pip
1766 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1767 Constraint_System cs = build_cxx_constraint_system(env, j_cs);
1768 pip->add_constraints(cs);
1769 }
1770 CATCH_ALL;
1771 }
1772
1773 JNIEXPORT jboolean JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_is_1satisfiable(JNIEnv * env,jobject j_this_pip_problem)1774 Java_parma_1polyhedra_1library_PIP_1Problem_is_1satisfiable
1775 (JNIEnv* env , jobject j_this_pip_problem) {
1776 try {
1777 PIP_Problem* pip
1778 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1779 return pip->is_satisfiable();
1780 }
1781 CATCH_ALL;
1782 return false;
1783 }
1784
Java_parma_1polyhedra_1library_PIP_1Problem_solve(JNIEnv * env,jobject j_this_pip_problem)1785 JNIEXPORT jobject JNICALL Java_parma_1polyhedra_1library_PIP_1Problem_solve
1786 (JNIEnv* env , jobject j_this_pip_problem) {
1787 try {
1788 PIP_Problem* pip
1789 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1790 return build_java_pip_status(env, pip->solve());
1791 }
1792 CATCH_ALL;
1793 jobject null = 0;
1794 return null;
1795 }
1796
Java_parma_1polyhedra_1library_PIP_1Problem_solution(JNIEnv * env,jobject j_this_pip_problem)1797 JNIEXPORT jobject JNICALL Java_parma_1polyhedra_1library_PIP_1Problem_solution
1798 (JNIEnv* env , jobject j_this_pip_problem) {
1799 try {
1800 PIP_Problem* pip
1801 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1802 const PIP_Tree_Node* solution = pip->solution();
1803
1804 jclass j_class_s = env->FindClass("parma_polyhedra_library/PIP_Tree_Node");
1805 CHECK_RESULT_ASSERT(env, j_class_s);
1806 jmethodID j_ctr_id_s = env->GetMethodID(j_class_s, "<init>", "()V");
1807 CHECK_RESULT_ASSERT(env, j_ctr_id_s);
1808 jobject j_obj_s = env->NewObject(j_class_s, j_ctr_id_s);
1809 CHECK_RESULT_RETURN(env, j_obj_s, 0);
1810 set_ptr(env, j_obj_s, solution);
1811 return j_obj_s;
1812 }
1813 CATCH_ALL;
1814 jobject null = 0;
1815 return null;
1816 }
1817
1818 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_optimizing_1solution(JNIEnv * env,jobject j_this_pip_problem)1819 Java_parma_1polyhedra_1library_PIP_1Problem_optimizing_1solution
1820 (JNIEnv* env , jobject j_this_pip_problem) {
1821 try {
1822 PIP_Problem* pip
1823 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1824 const PIP_Tree_Node* solution = pip->optimizing_solution();
1825
1826 jclass j_class_s = env->FindClass("parma_polyhedra_library/PIP_Tree_Node");
1827 CHECK_RESULT_ASSERT(env, j_class_s);
1828 jmethodID j_ctr_id_s = env->GetMethodID(j_class_s, "<init>", "()V");
1829 CHECK_RESULT_ASSERT(env, j_ctr_id_s);
1830 jobject j_obj_s = env->NewObject(j_class_s, j_ctr_id_s);
1831 CHECK_RESULT_RETURN(env, j_obj_s, 0);
1832 set_ptr(env, j_obj_s, solution);
1833 return j_obj_s;
1834 }
1835 CATCH_ALL;
1836 jobject null = 0;
1837 return null;
1838 }
1839
1840 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_get_1pip_1problem_1control_1parameter(JNIEnv * env,jobject j_this_pip_problem,jobject j_cpn)1841 Java_parma_1polyhedra_1library_PIP_1Problem_get_1pip_1problem_1control_1parameter
1842 (JNIEnv* env , jobject j_this_pip_problem,
1843 jobject j_cpn) {
1844 try {
1845 PIP_Problem* pip
1846 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1847 PIP_Problem::Control_Parameter_Name ppl_cpn
1848 = build_cxx_pip_problem_control_parameter_name(env, j_cpn);
1849 return
1850 build_java_pip_problem_control_parameter_value
1851 (env, pip->get_control_parameter(ppl_cpn));
1852 }
1853 CATCH_ALL;
1854 jobject null = 0;
1855 return null;
1856 }
1857
1858 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_constraint_1at_1index(JNIEnv * env,jobject j_this_pip_problem,jlong j_index)1859 Java_parma_1polyhedra_1library_PIP_1Problem_constraint_1at_1index
1860 (JNIEnv* env, jobject j_this_pip_problem, jlong j_index) {
1861 try {
1862 PIP_Problem* pip
1863 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1864 dimension_type p_index = jtype_to_unsigned<dimension_type>(j_index);
1865 return build_java_constraint(env, *(pip->constraints_begin() + p_index));
1866 }
1867 CATCH_ALL;
1868 jobject null = 0;
1869 return null;
1870 }
1871
1872 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_constraints(JNIEnv * env,jobject j_this_pip_problem)1873 Java_parma_1polyhedra_1library_PIP_1Problem_constraints
1874 (JNIEnv* env, jobject j_this_pip_problem) {
1875 try {
1876 jobject j_cs = env->NewObject(cached_classes.Constraint_System,
1877 cached_FMIDs.Constraint_System_init_ID);
1878 CHECK_RESULT_RETURN(env, j_cs, 0);
1879
1880 PIP_Problem* pip
1881 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1882 for (PIP_Problem::const_iterator cs_it = pip->constraints_begin(),
1883 cs_end = pip->constraints_end(); cs_it != cs_end; ++cs_it) {
1884 jobject j_constraint = build_java_constraint(env, *cs_it);
1885 env->CallBooleanMethod(j_cs,
1886 cached_FMIDs.Constraint_System_add_ID,
1887 j_constraint);
1888 CHECK_EXCEPTION_RETURN(env, 0);
1889 }
1890 return j_cs;
1891 }
1892 CATCH_ALL;
1893 jobject null = 0;
1894 return null;
1895 }
1896
1897 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_PIP_1Problem_set_1pip_1problem_1control_1parameter(JNIEnv * env,jobject j_this_pip_problem,jobject j_cpv)1898 Java_parma_1polyhedra_1library_PIP_1Problem_set_1pip_1problem_1control_1parameter
1899 (JNIEnv* env, jobject j_this_pip_problem, jobject j_cpv) {
1900 try {
1901 PIP_Problem* pip
1902 = reinterpret_cast<PIP_Problem*>(get_ptr(env, j_this_pip_problem));
1903 PIP_Problem::Control_Parameter_Value ppl_cpv
1904 = build_cxx_pip_problem_control_parameter_value(env, j_cpv);
1905 pip->set_control_parameter(ppl_cpv);
1906 }
1907 CATCH_ALL;
1908 }
1909
1910 JNIEXPORT jboolean JNICALL
Java_parma_1polyhedra_1library_PIP_1Tree_1Node_OK(JNIEnv * env,jobject j_this_pip_tree)1911 Java_parma_1polyhedra_1library_PIP_1Tree_1Node_OK
1912 (JNIEnv* env, jobject j_this_pip_tree) {
1913 try {
1914 PIP_Tree_Node* pip
1915 = reinterpret_cast<PIP_Tree_Node*>(get_ptr(env, j_this_pip_tree));
1916 return pip->OK();
1917 }
1918 CATCH_ALL;
1919 return false;
1920 }
1921
1922 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_PIP_1Tree_1Node_free(JNIEnv * env,jobject j_this)1923 Java_parma_1polyhedra_1library_PIP_1Tree_1Node_free
1924 (JNIEnv* env, jobject j_this) {
1925 PIP_Tree_Node* pip = reinterpret_cast<PIP_Tree_Node*>(get_ptr(env, j_this));
1926 if (!is_java_marked(env, j_this)) {
1927 delete pip;
1928 void* null_ptr = 0;
1929 set_ptr(env, j_this, null_ptr);
1930 }
1931 }
1932
1933 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_PIP_1Tree_1Node_finalize(JNIEnv * env,jobject j_this)1934 Java_parma_1polyhedra_1library_PIP_1Tree_1Node_finalize
1935 (JNIEnv* env, jobject j_this) {
1936 PIP_Tree_Node* pip = reinterpret_cast<PIP_Tree_Node*>(get_ptr(env, j_this));
1937 if (!is_java_marked(env, j_this))
1938 delete pip;
1939 }
1940
1941 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_PIP_1Tree_1Node_constraints(JNIEnv * env,jobject j_this_pip_node)1942 Java_parma_1polyhedra_1library_PIP_1Tree_1Node_constraints
1943 (JNIEnv* env, jobject j_this_pip_node) {
1944 try {
1945 jobject j_cs = env->NewObject(cached_classes.Constraint_System,
1946 cached_FMIDs.Constraint_System_init_ID);
1947 CHECK_RESULT_RETURN(env, j_cs, 0);
1948
1949 PIP_Tree_Node* pip
1950 = reinterpret_cast<PIP_Tree_Node*>(get_ptr(env, j_this_pip_node));
1951 return build_java_constraint_system(env, pip->constraints());
1952 }
1953 CATCH_ALL;
1954 jobject null = 0;
1955 return null;
1956 }
1957
1958 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_PIP_1Tree_1Node_as_1solution(JNIEnv * env,jobject j_this)1959 Java_parma_1polyhedra_1library_PIP_1Tree_1Node_as_1solution
1960 (JNIEnv* env, jobject j_this) {
1961 try {
1962 PIP_Tree_Node* pip = reinterpret_cast<PIP_Tree_Node*>(get_ptr(env, j_this));
1963 const PIP_Solution_Node* solution = pip->as_solution();
1964 if (solution == 0) {
1965 jobject null = 0;
1966 return null;
1967 }
1968 // Here we have a solution node.
1969 jclass j_class_s
1970 = env->FindClass("parma_polyhedra_library/PIP_Solution_Node");
1971 CHECK_RESULT_ASSERT(env, j_class_s);
1972 jmethodID j_ctr_id_s = env->GetMethodID(j_class_s, "<init>", "()V");
1973 CHECK_RESULT_ASSERT(env, j_ctr_id_s);
1974 jobject j_obj_s = env->NewObject(j_class_s, j_ctr_id_s);
1975 CHECK_RESULT_RETURN(env, j_obj_s, 0);
1976 set_ptr(env, j_obj_s, solution);
1977 return j_obj_s;
1978 }
1979 CATCH_ALL;
1980 jobject null = 0;
1981 return null;
1982 }
1983
1984 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_PIP_1Tree_1Node_as_1decision(JNIEnv * env,jobject j_this)1985 Java_parma_1polyhedra_1library_PIP_1Tree_1Node_as_1decision
1986 (JNIEnv* env, jobject j_this) {
1987 try {
1988 PIP_Tree_Node* pip = reinterpret_cast<PIP_Tree_Node*>(get_ptr(env, j_this));
1989 const PIP_Decision_Node* decision = pip->as_decision();
1990 if (decision == 0) {
1991 jobject null = 0;
1992 return null;
1993 }
1994 // Here we have a decision node.
1995 jclass j_class_d
1996 = env->FindClass("parma_polyhedra_library/PIP_Decision_Node");
1997 CHECK_RESULT_ASSERT(env, j_class_d);
1998 jmethodID j_ctr_id_d = env->GetMethodID(j_class_d, "<init>", "()V");
1999 CHECK_RESULT_ASSERT(env, j_ctr_id_d);
2000 jobject j_obj_d = env->NewObject(j_class_d, j_ctr_id_d);
2001 CHECK_RESULT_RETURN(env, j_obj_d, 0);
2002 set_ptr(env, j_obj_d, decision);
2003 return j_obj_d;
2004 }
2005 CATCH_ALL;
2006 jobject null = 0;
2007 return null;
2008 }
2009
2010 JNIEXPORT jlong JNICALL
Java_parma_1polyhedra_1library_PIP_1Tree_1Node_number_1of_1artificials(JNIEnv * env,jobject j_this)2011 Java_parma_1polyhedra_1library_PIP_1Tree_1Node_number_1of_1artificials
2012 (JNIEnv* env , jobject j_this) {
2013 try {
2014 PIP_Tree_Node* pip = reinterpret_cast<PIP_Tree_Node*>(get_ptr(env, j_this));
2015 return pip->art_parameter_count();
2016 }
2017 CATCH_ALL;
2018 return 0;
2019 }
2020
2021 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_PIP_1Tree_1Node_artificials(JNIEnv * env,jobject j_this_pip_node)2022 Java_parma_1polyhedra_1library_PIP_1Tree_1Node_artificials
2023 (JNIEnv* env, jobject j_this_pip_node) {
2024 try {
2025 jobject j_arts
2026 = env->NewObject(cached_classes.Artificial_Parameter_Sequence,
2027 cached_FMIDs.Artificial_Parameter_Sequence_init_ID);
2028 CHECK_RESULT_RETURN(env, j_arts, 0);
2029
2030 const PIP_Tree_Node* pip_node
2031 = reinterpret_cast<const PIP_Tree_Node*>(get_ptr(env, j_this_pip_node));
2032 for (PIP_Tree_Node::Artificial_Parameter_Sequence::const_iterator
2033 i = pip_node->art_parameter_begin(),
2034 i_end = pip_node->art_parameter_end(); i != i_end; ++i) {
2035 jobject j_art = build_java_artificial_parameter(env, *i);
2036 env->CallBooleanMethod(j_arts,
2037 cached_FMIDs.Artificial_Parameter_Sequence_add_ID,
2038 j_art);
2039 CHECK_EXCEPTION_RETURN(env, 0);
2040 }
2041 return j_arts;
2042 }
2043 CATCH_ALL;
2044 jobject null = 0;
2045 return null;
2046 }
2047
2048 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_PIP_1Tree_1Node_toString(JNIEnv * env,jobject j_this)2049 Java_parma_1polyhedra_1library_PIP_1Tree_1Node_toString
2050 (JNIEnv* env, jobject j_this) {
2051 PIP_Tree_Node* this_ptr
2052 = reinterpret_cast<PIP_Tree_Node*>(get_ptr(env, j_this));
2053 using namespace Parma_Polyhedra_Library::IO_Operators;
2054 std::ostringstream s;
2055 s << *this_ptr;
2056 return env->NewStringUTF(s.str().c_str());
2057 }
2058
2059 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_PIP_1Decision_1Node_child_1node(JNIEnv * env,jobject j_this,jboolean j_branch)2060 Java_parma_1polyhedra_1library_PIP_1Decision_1Node_child_1node
2061 (JNIEnv* env, jobject j_this, jboolean j_branch) {
2062 try {
2063 PIP_Decision_Node* dec_node
2064 = reinterpret_cast<PIP_Decision_Node*>(get_ptr(env, j_this));
2065 const PIP_Tree_Node* child = dec_node->child_node(j_branch);
2066 if (child == 0) {
2067 jobject null = 0;
2068 return null;
2069 }
2070 jclass j_class_s = env->FindClass("parma_polyhedra_library/PIP_Tree_Node");
2071 CHECK_RESULT_ASSERT(env, j_class_s);
2072 jmethodID j_ctr_id_s = env->GetMethodID(j_class_s, "<init>", "()V");
2073 CHECK_RESULT_ASSERT(env, j_ctr_id_s);
2074 jobject j_obj_s = env->NewObject(j_class_s, j_ctr_id_s);
2075 CHECK_RESULT_RETURN(env, j_obj_s, 0);
2076 set_ptr(env, j_obj_s, child);
2077 return j_obj_s;
2078 }
2079 CATCH_ALL;
2080 jobject null = 0;
2081 return null;
2082 }
2083
2084 JNIEXPORT jobject JNICALL
Java_parma_1polyhedra_1library_PIP_1Solution_1Node_parametric_1values(JNIEnv * env,jobject j_this,jobject j_var)2085 Java_parma_1polyhedra_1library_PIP_1Solution_1Node_parametric_1values
2086 (JNIEnv* env, jobject j_this, jobject j_var) {
2087 PIP_Solution_Node* pip
2088 = reinterpret_cast<PIP_Solution_Node*>(get_ptr(env, j_this));
2089 Variable v = build_cxx_variable(env, j_var);
2090 return build_linear_expression(env, pip->parametric_values(v));
2091 }
2092
2093 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Artificial_1Parameter_initIDs(JNIEnv * env,jclass j_artificial_parameter_class)2094 Java_parma_1polyhedra_1library_Artificial_1Parameter_initIDs
2095 (JNIEnv* env, jclass j_artificial_parameter_class) {
2096 jfieldID fID;
2097 fID = env->GetFieldID(j_artificial_parameter_class, "le",
2098 "Lparma_polyhedra_library/Linear_Expression;");
2099 CHECK_RESULT_ASSERT(env, fID);
2100 cached_FMIDs.Artificial_Parameter_le_ID = fID;
2101 fID = env->GetFieldID(j_artificial_parameter_class, "den",
2102 "Lparma_polyhedra_library/Coefficient;");
2103 CHECK_RESULT_ASSERT(env, fID);
2104 cached_FMIDs.Artificial_Parameter_den_ID = fID;
2105 jmethodID mID;
2106 mID = env->GetMethodID(j_artificial_parameter_class, "<init>",
2107 "(Lparma_polyhedra_library/Linear_Expression;"
2108 "Lparma_polyhedra_library/Coefficient;)V");
2109 CHECK_RESULT_ASSERT(env, mID);
2110 cached_FMIDs.Artificial_Parameter_init_ID = mID;
2111 }
2112
2113 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Artificial_1Parameter_ascii_1dump(JNIEnv * env,jobject j_this)2114 Java_parma_1polyhedra_1library_Artificial_1Parameter_ascii_1dump
2115 (JNIEnv* env, jobject j_this) {
2116 try {
2117 std::ostringstream s;
2118 PIP_Tree_Node::Artificial_Parameter art
2119 = build_cxx_artificial_parameter(env, j_this);
2120 art.ascii_dump(s);
2121 return env->NewStringUTF(s.str().c_str());
2122 }
2123 CATCH_ALL;
2124 return 0;
2125 }
2126
2127 JNIEXPORT jstring JNICALL
Java_parma_1polyhedra_1library_Artificial_1Parameter_toString(JNIEnv * env,jobject j_this)2128 Java_parma_1polyhedra_1library_Artificial_1Parameter_toString
2129 (JNIEnv* env, jobject j_this) {
2130 using namespace Parma_Polyhedra_Library::IO_Operators;
2131 std::ostringstream s;
2132 PIP_Tree_Node::Artificial_Parameter ppl_art
2133 = build_cxx_artificial_parameter(env, j_this);
2134 s << ppl_art;
2135 return env->NewStringUTF(s.str().c_str());
2136 }
2137
2138 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Artificial_1Parameter_1Sequence_initIDs(JNIEnv * env,jclass j_aps_class)2139 Java_parma_1polyhedra_1library_Artificial_1Parameter_1Sequence_initIDs
2140 (JNIEnv* env, jclass j_aps_class) {
2141 jmethodID mID;
2142 mID = env->GetMethodID(j_aps_class, "<init>", "()V");
2143 CHECK_RESULT_ASSERT(env, mID);
2144 cached_FMIDs.Artificial_Parameter_Sequence_init_ID = mID;
2145 mID = env->GetMethodID(j_aps_class, "add", "(Ljava/lang/Object;)Z");
2146 CHECK_RESULT_ASSERT(env, mID);
2147 cached_FMIDs.Artificial_Parameter_Sequence_add_ID = mID;
2148 }
2149
2150
2151 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Partial_1Function_build_1cpp_1object(JNIEnv * env,jobject j_this_pfunc)2152 Java_parma_1polyhedra_1library_Partial_1Function_build_1cpp_1object
2153 (JNIEnv* env, jobject j_this_pfunc) {
2154 try {
2155 Partial_Function* pfunc_ptr = new Partial_Function;
2156 set_ptr(env, j_this_pfunc, pfunc_ptr);
2157 }
2158 CATCH_ALL;
2159 }
2160
2161 JNIEXPORT jboolean JNICALL
Java_parma_1polyhedra_1library_Partial_1Function_has_1empty_1codomain(JNIEnv * env,jobject j_this_pfunc)2162 Java_parma_1polyhedra_1library_Partial_1Function_has_1empty_1codomain
2163 (JNIEnv* env , jobject j_this_pfunc) {
2164 try {
2165 Partial_Function* pfunc
2166 = reinterpret_cast<Partial_Function*>(get_ptr(env, j_this_pfunc));
2167 return pfunc->has_empty_codomain();
2168 }
2169 CATCH_ALL;
2170 return 0;
2171 }
2172
2173 JNIEXPORT jlong JNICALL
Java_parma_1polyhedra_1library_Partial_1Function_max_1in_1codomain(JNIEnv * env,jobject j_this_pfunc)2174 Java_parma_1polyhedra_1library_Partial_1Function_max_1in_1codomain
2175 (JNIEnv* env , jobject j_this_pfunc) {
2176 try {
2177 Partial_Function* pfunc
2178 = reinterpret_cast<Partial_Function*>(get_ptr(env, j_this_pfunc));
2179 return pfunc->max_in_codomain();
2180 }
2181 CATCH_ALL;
2182 return 0;
2183 }
2184
2185 JNIEXPORT jlong JNICALL
Java_parma_1polyhedra_1library_Partial_1Function_maps(JNIEnv * env,jobject j_this_pfunc,jlong j_i)2186 Java_parma_1polyhedra_1library_Partial_1Function_maps
2187 (JNIEnv* env, jobject j_this_pfunc, jlong j_i) {
2188 Partial_Function* pfunc
2189 = reinterpret_cast<Partial_Function*>(get_ptr(env, j_this_pfunc));
2190 dimension_type i = jtype_to_unsigned<dimension_type>(j_i);
2191 dimension_type j;
2192 if (pfunc->maps(i, j))
2193 return j;
2194 else
2195 return -1;
2196 }
2197
2198 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Partial_1Function_insert(JNIEnv * env,jobject j_this_pfunc,jlong i,jlong j)2199 Java_parma_1polyhedra_1library_Partial_1Function_insert
2200 (JNIEnv* env , jobject j_this_pfunc, jlong i, jlong j) {
2201 try {
2202 Partial_Function* pfunc
2203 = reinterpret_cast<Partial_Function*>(get_ptr(env, j_this_pfunc));
2204 pfunc->insert(i, j);
2205 }
2206 CATCH_ALL;
2207 }
2208
2209 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Partial_1Function_free(JNIEnv * env,jobject j_this)2210 Java_parma_1polyhedra_1library_Partial_1Function_free
2211 (JNIEnv* env, jobject j_this) {
2212 Partial_Function* pfunc
2213 = reinterpret_cast<Partial_Function*>(get_ptr(env, j_this));
2214 if (!is_java_marked(env, j_this)) {
2215 delete pfunc;
2216 void* null_ptr = 0;
2217 set_ptr(env, j_this, null_ptr);
2218 }
2219 }
2220
2221 JNIEXPORT void JNICALL
Java_parma_1polyhedra_1library_Partial_1Function_finalize(JNIEnv * env,jobject j_this)2222 Java_parma_1polyhedra_1library_Partial_1Function_finalize
2223 (JNIEnv* env, jobject j_this) {
2224 Partial_Function* pfunc
2225 = reinterpret_cast<Partial_Function*>(get_ptr(env, j_this));
2226 if (!is_java_marked(env, j_this))
2227 delete pfunc;
2228 }
2229