eg_emptyhandles.c

Go to the documentation of this file.
00001 #include "eg_emptyhandles.h"
00002 int DPremoveEmptyHandles (int *const nIneq,
00003                           int **const ndominoes,
00004                           int ***const naset,
00005                           int ***const nbset,
00006                           int **const nhandle,
00007                           int ****const aset,
00008                           int ****const bset,
00009                           int ***const handle)
00010 {
00011 
00012   int nIneq2 = 0;
00013   int *ndominoes2 = 0;
00014   int **naset2 = 0;
00015   int **nbset2 = 0;
00016   int *nhandle2 = 0;
00017   int ***aset2 = 0;
00018   int ***bset2 = 0;
00019   int **handle2 = 0;
00020 
00021   int i,
00022     cnt = 0,
00023     d,
00024     nelim = 0;
00025 
00026   for (i = 0; i < *nIneq; i++)
00027     if ((*nhandle)[i] == 0)
00028       nelim += 1;
00029 
00030   nIneq2 = *nIneq - nelim;
00031   if (!nelim)
00032     return 0;
00033 
00034   ndominoes2 = EGsMalloc (int, nIneq2);
00035   naset2 = EGsMalloc (int *,
00036                       nIneq2);
00037   nbset2 = EGsMalloc (int *,
00038                       nIneq2);
00039   nhandle2 = EGsMalloc (int,
00040                         nIneq2);
00041   aset2 = EGsMalloc (int **,
00042                      nIneq2);
00043   bset2 = EGsMalloc (int **,
00044                      nIneq2);
00045   handle2 = EGsMalloc (int *,
00046                        nIneq2);
00047 
00048   for (i = 0; i < *nIneq; i++)
00049   {
00050     if ((*nhandle)[i] == 0)
00051     {
00052       for (d = 0; d < (*ndominoes)[i]; d++)
00053       {
00054         EGfree ((*aset)[i][d]);
00055         EGfree ((*bset)[i][d]);
00056       }
00057       EGfree ((*naset)[i]);
00058       EGfree ((*nbset)[i]);
00059       EGfree ((*aset)[i]);
00060       EGfree ((*bset)[i]);
00061     }
00062     else
00063     {
00064       ndominoes2[cnt] = (*ndominoes)[i];
00065       naset2[cnt] = (*naset)[i];
00066       nbset2[cnt] = (*nbset)[i];
00067       nhandle2[cnt] = (*nhandle)[i];
00068       aset2[cnt] = (*aset)[i];
00069       bset2[cnt] = (*bset)[i];
00070       handle2[cnt] = (*handle)[i];
00071       cnt += 1;
00072     }
00073   }
00074 
00075   EGfree (*ndominoes);
00076   EGfree (*naset);
00077   EGfree (*nbset);
00078   EGfree (*nhandle);
00079   EGfree (*aset);
00080   EGfree (*bset);
00081   EGfree (*handle);
00082 
00083   *ndominoes = ndominoes2;
00084   *naset = naset2;
00085   *nbset = nbset2;
00086   *nhandle = nhandle2;
00087   *aset = aset2;
00088   *bset = bset2;
00089   *handle = handle2;
00090 
00091   *nIneq = nIneq2;
00092   fprintf (stderr, "Eliminated %d empty-handle DP contraints\n", nelim);
00093 
00094   return 0;
00095 
00096 }

Generated on Thu Oct 20 14:58:41 2005 for DominoParitySeparator by  doxygen 1.4.5