Changeset 455 for cpp/frams/_demos
- Timestamp:
- 12/05/15 18:31:38 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/_demos/simil_test.cpp
r451 r455 71 71 72 72 // prepare output parameters from .gen file 73 vector<Geno *> *pvGenos = newvector<Geno *>();74 vector<char *> *pvNames = newvector<char *>();73 vector<Geno *> pvGenos = vector<Geno *>(); 74 vector<char *> pvNames = vector<char *>(); 75 75 76 76 // check if there is a switch … … 138 138 if ((pNextGenotype != NULL) && (pNextGenotype->isValid())) 139 139 { 140 pvGenos ->push_back(pNextGenotype);140 pvGenos.push_back(pNextGenotype); 141 141 char *szNewName = new char [ loaded->name.len() + 1]; 142 142 strcpy(szNewName, loaded->name.c_str()); 143 pvNames ->push_back(szNewName);143 pvNames.push_back(szNewName); 144 144 } 145 145 else … … 157 157 158 158 // create the empty array of similarities 159 aaSimil = new pDouble [pvGenos ->size()];160 for (unsigned int k = 0; k < pvGenos ->size(); k++)161 { 162 aaSimil[k] = new double [pvGenos ->size()];163 for (unsigned int l = 0; l < pvGenos ->size(); l++)159 aaSimil = new pDouble [pvGenos.size()]; 160 for (unsigned int k = 0; k < pvGenos.size(); k++) 161 { 162 aaSimil[k] = new double [pvGenos.size()]; 163 for (unsigned int l = 0; l < pvGenos.size(); l++) 164 164 aaSimil[k][l] = 0.0; 165 165 } 166 166 167 167 // compute and remember similarities 168 for (unsigned int i = 0; i < pvGenos ->size(); i++)169 { 170 for (unsigned int j = 0; j < pvGenos ->size(); j++)171 { 172 dSimilarity = M.EvaluateDistance(pvGenos ->operator[](i), pvGenos->operator[](j));168 for (unsigned int i = 0; i < pvGenos.size(); i++) 169 { 170 for (unsigned int j = 0; j < pvGenos.size(); j++) 171 { 172 dSimilarity = M.EvaluateDistance(pvGenos.operator[](i), pvGenos.operator[](j)); 173 173 aaSimil[i][j] = dSimilarity; 174 174 } … … 179 179 // if "-names" switch was given, 180 180 // print the number of genotypes and their names 181 printf("%li\n", pvGenos ->size());182 for (unsigned int iGen = 0; iGen < pvNames ->size(); iGen++)183 { 184 printf("%s\n", pvNames ->at(iGen));181 printf("%li\n", pvGenos.size()); 182 for (unsigned int iGen = 0; iGen < pvNames.size(); iGen++) 183 { 184 printf("%s\n", pvNames.at(iGen)); 185 185 } 186 186 } 187 187 188 188 // print out the matrix of similarities 189 for (unsigned int i = 0; i < pvGenos ->size(); i++)190 { 191 for (unsigned int j = 0; j < pvGenos ->size(); j++)189 for (unsigned int i = 0; i < pvGenos.size(); i++) 190 { 191 for (unsigned int j = 0; j < pvGenos.size(); j++) 192 192 { 193 193 printf("%.2lf\t", aaSimil[i][j]); … … 197 197 198 198 // delete vectors and arrays 199 for (unsigned int i = 0; i < pvGenos ->size(); i++)200 { 201 delete pvGenos ->operator[](i);202 delete [] pvNames ->operator[](i);199 for (unsigned int i = 0; i < pvGenos.size(); i++) 200 { 201 delete pvGenos.operator[](i); 202 delete [] pvNames.operator[](i); 203 203 delete [] aaSimil[i]; 204 204 } 205 205 206 delete pvGenos;207 delete pvNames;208 206 delete [] aaSimil; 209 207
Note: See TracChangeset
for help on using the changeset viewer.