00001 /* Generator Java class declaration and implementation. 00002 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it> 00003 Copyright (C) 2010-2011 BUGSENG srl (http://bugseng.com) 00004 00005 This file is part of the Parma Polyhedra Library (PPL). 00006 00007 The PPL is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 3 of the License, or (at your 00010 option) any later version. 00011 00012 The PPL is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software Foundation, 00019 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. 00020 00021 For the most up-to-date information see the Parma Polyhedra Library 00022 site: http://www.cs.unipr.it/ppl/ . */ 00023 00024 package parma_polyhedra_library; 00025 00026 import java.io.Writer; 00027 import java.io.IOException; 00028 00029 import java.util.*; 00030 import javax.management.RuntimeErrorException; 00031 00033 00040 public class Generator { 00042 private Generator_Type gt; 00043 00045 private Linear_Expression le; 00046 00048 private Coefficient div; 00049 00054 private Generator(Linear_Expression e, Generator_Type g_type) { 00055 le = e.clone(); 00056 gt = g_type; 00057 } 00058 00060 00064 public static Generator closure_point(Linear_Expression e, Coefficient d) { 00065 if (d.getBigInteger().equals(java.math.BigInteger.ZERO)) { 00066 Error cause = new Error("parma_polyhedra_library.Generator::" 00067 + "Generator(e, d):\n" 00068 + "the divisor can not be zero."); 00069 throw new RuntimeErrorException(cause); 00070 } 00071 Generator g = new Generator(e, Generator_Type.CLOSURE_POINT); 00072 g.div = new Coefficient(d); 00073 return g; 00074 } 00075 00077 00082 public static Generator line(Linear_Expression e) { 00083 return new Generator(e, Generator_Type.LINE); 00084 } 00085 00087 00091 public static Generator point(Linear_Expression e, Coefficient d) { 00092 if (d.getBigInteger().equals(java.math.BigInteger.ZERO)) { 00093 Error cause = new Error("parma_polyhedra_library.Generator::" 00094 + "Generator(e, d):\n" 00095 + "the divisor can not be zero."); 00096 throw new RuntimeErrorException(cause); 00097 } 00098 00099 Generator g = new Generator(e, Generator_Type.POINT); 00100 g.div = new Coefficient(d); 00101 return g; 00102 } 00103 00105 00110 public static Generator ray(Linear_Expression e) { 00111 return new Generator(e, Generator_Type.RAY); 00112 } 00113 00115 public Generator_Type type() { 00116 return gt; 00117 } 00118 00120 public Linear_Expression linear_expression() { 00121 return le; 00122 } 00123 00125 00129 public Coefficient divisor() { 00130 if (this.gt == Generator_Type.POINT 00131 || this.gt == Generator_Type.CLOSURE_POINT) 00132 return div; 00133 Error cause = new Error("parma_polyhedra_library.Generator::divisor:\n" 00134 + "this is neither a point" 00135 + " nor a closure point."); 00136 throw new RuntimeErrorException(cause); 00137 } 00138 00140 public native String ascii_dump(); 00141 00143 public native String toString(); 00144 00145 private static native void initIDs(); 00146 static { 00147 initIDs(); 00148 } 00149 }
1.6.3