Changeset 9fbf02 in git for factory


Ignore:
Timestamp:
Jan 6, 2014, 11:42:51 PM (10 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '98550b669234b32be762076c32b3be2c35188ac4')
Children:
49ba0963eace9d5fafa517dc5e9b39eb0ed0a096
Parents:
f63d2e83242d64e2f8e687d91e9ab3ddabad5ac0
git-author:
Martin Lee <martinlee84@web.de>2014-01-06 23:42:51+01:00
git-committer:
Martin Lee <martinlee84@web.de>2014-01-20 16:45:04+01:00
Message:
fix: bug in computing bounds for factor recombination
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/facFqBivarUtil.cc

    rf63d2e8 r9fbf02  
    788788  }
    789789  int k= 0;
     790  int* point= new int [2];
    790791  for (int i= 0; i < n; i++)
    791792  {
     
    834835      continue;
    835836    }
    836     int* point= new int [2];
    837837    point [0]= k;
    838838    point [1]= i + 1;
     
    840840      k= 0;
    841841    result [i]= k;
    842     delete [] point;
    843   }
     842  }
     843
     844  delete [] point;
    844845
    845846  for (int i= 0; i < sizeOfNewtonPolygon; i++)
     
    894895  }
    895896
     897  int swap;
     898  for (int i= 0; i < sizeOfNewtonPolygon; i++)
     899  {
     900    swap= newtonPolyg[i][1];
     901    newtonPolyg[i][1]=newtonPolyg[i][0];
     902    newtonPolyg[i][0]= swap;
     903  }
     904
     905  sizeOfNewtonPolygon= polygon(newtonPolyg, sizeOfNewtonPolygon);
     906
    896907  int minX, minY, maxX, maxY;
    897908  minX= newtonPolyg [0] [0];
     
    902913  for (int i= 1; i < sizeOfNewtonPolygon; i++)
    903914  {
    904     if (newtonPolyg[i][0] == 0)
    905     {
    906       if (newtonPolyg[indZero][0] == 0)
    907       {
    908         if (newtonPolyg[indZero][1] < newtonPolyg[i][1])
     915    if (newtonPolyg[i][1] == 0)
     916    {
     917      if (newtonPolyg[indZero][1] == 0)
     918      {
     919        if (newtonPolyg[indZero][0] < newtonPolyg[i][0])
    909920          indZero= i;
    910921      }
     
    926937  if (indZero != sizeOfNewtonPolygon - 1)
    927938  {
    928     slopeNum= newtonPolyg[indZero+1][1]-newtonPolyg[indZero][1];
    929     slopeDen= newtonPolyg[indZero+1][0];
    930     constTerm= newtonPolyg[indZero][1];
     939    slopeNum= newtonPolyg[indZero+1][0]-newtonPolyg[indZero][0];
     940    slopeDen= newtonPolyg[indZero+1][1];
     941    constTerm= newtonPolyg[indZero][0];
    931942  }
    932943  else
    933944  {
    934     slopeNum= newtonPolyg[0][1]-newtonPolyg[indZero][1];
    935     slopeDen= newtonPolyg[0][0];
    936     constTerm= newtonPolyg[indZero][1];
     945    slopeNum= newtonPolyg[0][0]-newtonPolyg[indZero][0];
     946    slopeDen= newtonPolyg[0][1];
     947    constTerm= newtonPolyg[indZero][0];
    937948  }
    938949  if (slopeNum < 0)
     
    942953  }
    943954  int k= 0;
     955
     956  int* point= new int [2];
    944957  for (int i= 0; i < n; i++)
    945958  {
    946     if (((indZero+1) < sizeOfNewtonPolygon && (i+1) > newtonPolyg[indZero+1][0])
    947         || ((indZero+1) >= sizeOfNewtonPolygon && (i+1) > newtonPolyg[0][0]))
     959    if (((indZero+1) < sizeOfNewtonPolygon && (i+1) > newtonPolyg[indZero+1][1])
     960        || ((indZero+1) >= sizeOfNewtonPolygon && (i+1) > newtonPolyg[0][1]))
    948961    {
    949962      if (indZero + 1 != sizeOfNewtonPolygon)
     
    953966      if (indZero != sizeOfNewtonPolygon - 1)
    954967      {
    955         slopeNum= newtonPolyg[indZero+1][1]-newtonPolyg[indZero][1];
    956         slopeDen= newtonPolyg[indZero+1][0]-newtonPolyg[indZero][0];
    957         constTerm= newtonPolyg[indZero][1];
     968        slopeNum= newtonPolyg[indZero+1][0]-newtonPolyg[indZero][0];
     969        slopeDen= newtonPolyg[indZero+1][1]-newtonPolyg[indZero][1];
     970        constTerm= newtonPolyg[indZero][0];
    958971      }
    959972      else
    960973      {
    961         slopeNum= newtonPolyg[0][1]-newtonPolyg[indZero][1];
    962         slopeDen= newtonPolyg[0][0]-newtonPolyg[indZero][0];
    963         constTerm= newtonPolyg[indZero][1];
     974        slopeNum= newtonPolyg[0][0]-newtonPolyg[indZero][0];
     975        slopeDen= newtonPolyg[0][1]-newtonPolyg[indZero][1];
     976        constTerm= newtonPolyg[indZero][0];
    964977      }
    965978      if (slopeNum < 0)
     
    967980        negativeSlope= true;
    968981        slopeNum= - slopeNum;
    969         k= (int) -(((long) slopeNum*((i+1)-newtonPolyg[indZero][0])+slopeDen-1)/
     982        k= (int) -(((long) slopeNum*((i+1)-newtonPolyg[indZero][1])+slopeDen-1)/
    970983                   slopeDen) + constTerm;
    971984      }
    972985      else
    973         k= (int) (((long) slopeNum*((i+1)-newtonPolyg[indZero][0])) / slopeDen)
     986        k= (int) (((long) slopeNum*((i+1)-newtonPolyg[indZero][1])) / slopeDen)
    974987                  + constTerm;
    975988    }
     
    977990    {
    978991      if (negativeSlope)
    979         k= (int) -(((long) slopeNum*((i+1)-newtonPolyg[indZero][0])+slopeDen-1)/
     992        k= (int) -(((long) slopeNum*((i+1)-newtonPolyg[indZero][1])+slopeDen-1)/
    980993                   slopeDen) + constTerm;
    981994      else
    982         k= (int) ((long) slopeNum*((i+1)-newtonPolyg[indZero][0])) / slopeDen
     995        k= (int) ((long) slopeNum*((i+1)-newtonPolyg[indZero][1])) / slopeDen
    983996                  + constTerm;
    984997    }
    985     if (i + 1 > maxX || i + 1 < minX)
     998    if (i + 1 > maxY || i + 1 < minY)
    986999    {
    9871000      result [i]= 0;
    9881001      continue;
    9891002    }
    990     int* point= new int [2];
    991     point [0]= i + 1;
    992     point [1]= k;
     1003
     1004    point [0]= k;
     1005    point [1]= i + 1;
    9931006    if (!isInPolygon (newtonPolyg, sizeOfNewtonPolygon, point) && k > 0)
    9941007      k= 0;
    9951008    result [i]= k;
    996     delete [] point;
    997   }
     1009  }
     1010
     1011  delete [] point;
    9981012
    9991013  for (int i= 0; i < sizeOfNewtonPolygon; i++)
Note: See TracChangeset for help on using the changeset viewer.