Sandia Home Sandia Home
Main Page | Publications | Downloads | Configuration | Running the Code | Solver Parameters | FAQ | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

cddmp.c

Go to the documentation of this file.
00001 
00043 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00044 
00045 /* cddmp.c       (cddlib arithmetic operations using gmp)
00046    Copyright: Komei Fukuda 2000, fukuda@ifor.math.ethz.ch
00047    Version 0.94, Aug. 4, 2005
00048 */
00049 /* This program is free software; you can redistribute it and/or modify
00050    it under the terms of the GNU General Public License as published by
00051    the Free Software Foundation; either version 2 of the License, or
00052    (at your option) any later version.
00053 
00054    This program is distributed in the hope that it will be useful,
00055    but WITHOUT ANY WARRANTY; without even the implied warranty of
00056    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00057    GNU General Public License for more details.
00058 
00059    You should have received a copy of the GNU General Public License
00060    along with this program; if not, write to the Free Software
00061    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00062  */
00063 
00064 #include "setoper.h"  /* set operation library header (Ver. March 16,1995 or later) */
00065 #include "cdd.h"
00066 
00067 void dd_set_global_constants()
00068 {
00069  dd_init(dd_zero);
00070  dd_init(dd_minuszero);
00071  dd_init(dd_one);
00072  dd_init(dd_minusone);
00073  dd_init(dd_purezero);
00074   
00075  time(&dd_statStartTime); /* cddlib starting time */
00076  dd_statBApivots=0;  /* basis finding pivots */
00077  dd_statCCpivots=0;  /* criss-cross pivots */
00078  dd_statDS1pivots=0; /* phase 1 pivots */
00079  dd_statDS2pivots=0; /* phase 2 pivots */
00080  dd_statACpivots=0;  /* anticycling (cc) pivots */
00081 
00082  dd_choiceLPSolverDefault=dd_DualSimplex;  /* Default LP solver Algorithm */
00083  dd_choiceRedcheckAlgorithm=dd_DualSimplex;  /* Redundancy Checking Algorithm */
00084  dd_choiceLexicoPivotQ=dd_TRUE;    /* whether to use the lexicographic pivot */
00085  
00086 #if defined GMPRATIONAL
00087  dd_statBSpivots=0;  /* basis status checking pivots */
00088  mpq_set_ui(dd_zero,0U,1U);
00089  mpq_set_ui(dd_purezero,0U,1U);
00090  mpq_set_ui(dd_one,1U,1U);
00091  mpq_set_si(dd_minusone,-1L,1U);
00092  ddf_set_global_constants();
00093 #elif defined GMPFLOAT
00094  mpf_set_d(dd_zero,dd_almostzero);
00095  mpf_set_ui(dd_purezero,0U);
00096  mpf_set_ui(dd_one,1U);
00097  mpf_set_si(dd_minusone,-1L,1U);
00098 #else
00099  dd_zero[0]= dd_almostzero;  /*real zero */
00100  dd_purezero[0]= 0.0;
00101  dd_one[0]= 1L;
00102  dd_minusone[0]= -1L;
00103 #endif
00104  dd_neg(dd_minuszero,dd_zero);
00105 }
00106 
00107 #if defined GMPRATIONAL
00108 void ddd_mpq_set_si(mytype a,signed long b)
00109 {
00110   mpz_t nz, dz;
00111 
00112   mpz_init(nz); mpz_init(dz);
00113 
00114   mpz_set_si(nz, b);
00115   mpz_set_ui(dz, 1U);
00116   mpq_set_num(a, nz);
00117   mpq_set_den(a, dz);
00118   mpz_clear(nz);  mpz_clear(dz);
00119 }
00120 #endif
00121 
00122 #if defined dd_CDOUBLE
00123 void ddd_init(mytype a)   
00124 {
00125   a[0]=0L;
00126 }
00127   
00128 void ddd_clear(mytype a)
00129 {
00130   /* a[0]=0L;  */
00131 }
00132 
00133 void ddd_set(mytype a,mytype b)
00134 {
00135   a[0]=b[0];
00136 }
00137 
00138 void ddd_set_d(mytype a,double b)
00139 {
00140   a[0]=b;
00141 }
00142 
00143 void ddd_set_si(mytype a,signed long b)
00144 {
00145   a[0]=(double)b;
00146 }
00147 
00148 void ddd_set_si2(mytype a,signed long b, unsigned long c)
00149 {
00150   a[0]=(double)b/(double)c;
00151 }
00152 
00153 void ddd_add(mytype a,mytype b,mytype c)
00154 {
00155   a[0]=b[0]+c[0];
00156 }
00157 
00158 void ddd_sub(mytype a,mytype b,mytype c)
00159 {
00160   a[0]=b[0]-c[0];
00161 }
00162 
00163 void ddd_mul(mytype a,mytype b,mytype c)
00164 {
00165   a[0]=b[0]*c[0];
00166 }
00167 
00168 void ddd_div(mytype a,mytype b,mytype c)
00169 {
00170   a[0]=b[0]/c[0];
00171 }
00172 
00173 void ddd_neg(mytype a,mytype b)
00174 {
00175   a[0]=-b[0];
00176 }
00177 
00178 void ddd_inv(mytype a,mytype b)
00179 {
00180   a[0]=1/b[0];
00181 }
00182 
00183 int ddd_cmp(mytype a,mytype b)
00184 {
00185   if (a[0]-b[0]>0) return 1;
00186   else if (a[0]-b[0]>=0) return 0;
00187   else return -1;
00188 }
00189 
00190 int ddd_sgn(mytype a)
00191 {
00192   if (a[0]>0) return 1;
00193   else if (a[0]>=0) return 0;
00194   else return -1;
00195 }
00196 
00197 double ddd_get_d(mytype a)
00198 {
00199   return a[0];
00200 }
00201 #endif
00202 
00203 /* end of  cddmp.h  */
00204 
00205 #endif

 

© Sandia Corporation | Site Contact | Privacy and Security

Generated on Fri Feb 16 10:33:35 2007 for APPSPACK 5.0.1 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2002