]> git.donarmstrong.com Git - genome.git/blobdiff - genome.cpp
add cxflags and debugging flags
[genome.git] / genome.cpp
index f46c661a24228092ef3ef14944d54f8689ca17f4..f50dd9285065da96bd346aa727e43f1cd3901a81 100644 (file)
@@ -51,6 +51,7 @@
 #include <map>\r
 #include <sstream>\r
 #include <stdio.h>\r
+#include <string.h>\r
 \r
 using namespace std;\r
 \r
@@ -76,7 +77,7 @@ static int BUFFER=1500;
 static int INCREMENT=1000;\r
 \r
 #define BLOCKSIZE   128\r
-#define SWAP(tmp,a,b)  tmp=a; a=b; b=tmp;\r
+#define SWAP(x,y) do {typeof(x) temp##x##y = x; x = y; y = temp##x##y; } while (0)\r
 \r
 static vector< vector< vector<bool> > > chromosome;\r
 static int * fragmentLength;\r
@@ -173,18 +174,15 @@ void FreeIntPtrMatrix(int *** & matrix, int rows){
    \r
 void NewGeneration(){\r
        \r
-   int *** ptrmatrix, * vector;\r
-   bool * boolvector;\r
-   \r
 //    for(int i=0;i<maxN;i++){\r
 //     if(parent_flags[i])printf("numBlock=%d parent=%d first=%d last=%d\n",numBLOCKs,i,parent_First[i],parent_Last[i]);   \r
 //    }\r
    \r
-   SWAP(ptrmatrix, children, parents);\r
-   SWAP(vector, child_First, parent_First);\r
-   SWAP(vector, child_Last, parent_Last);\r
-   SWAP(boolvector, child_flags, parent_flags);\r
-   SWAP(vector, cblocks, pblocks);\r
+   SWAP(children, parents);\r
+   SWAP(child_First, parent_First);\r
+   SWAP(child_Last, parent_Last);\r
+   SWAP(child_flags, parent_flags);\r
+   SWAP(cblocks, pblocks);\r
    \r
    if(!noChange){\r
           currentProfile++;\r
@@ -1084,7 +1082,7 @@ void genome(string popSize,                                               // effective population size of each populatio
                        \r
                     \r
                        if (parent == -1 ||\r
-                           distance > 0 && globalRandom.Next() > recombProb){\r
+                           (distance > 0 && globalRandom.Next() > recombProb)){\r
                                    parent = SampleParent(i, parent);\r
                         }\r
                             \r