Changeset 7f3b9d
- Timestamp:
- May 23, 2008, 9:17:19 AM (17 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 040f93
- Parents:
- 6097ea
- Location:
- src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
src/analyzer.cpp
r6097ea r7f3b9d 93 93 output << endl << "Total Times" << endl << "===============" << endl << Time.Header << endl; 94 94 Time.SetLastMatrix(0., 0); 95 for (int BondOrder= 0;BondOrder<KeySet.Order;BondOrder++)96 for(int i= 0;i<KeySet.FragmentsPerOrder[BondOrder];i++)97 for(int j= 0;j<Time.RowCounter[Time.MatrixCounter];j++)98 for(int k= 0;k<Time.ColumnCounter;k++) {95 for (int BondOrder=KeySet.Order;BondOrder--;) 96 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) 97 for(int j=Time.RowCounter[Time.MatrixCounter];j--;) 98 for(int k=Time.ColumnCounter;k--;) { 99 99 Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 100 100 } … … 118 118 output << "#Order\tFrag.No.\t" << Time.Header << endl; 119 119 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 120 for(int i= 0;i<KeySet.FragmentsPerOrder[BondOrder];i++)121 for(int j= 0;j<Time.RowCounter[Time.MatrixCounter];j++)122 for(int k= 0;k<Time.ColumnCounter;k++) {120 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) 121 for(int j=Time.RowCounter[Time.MatrixCounter];j--;) 122 for(int k=Time.ColumnCounter;k--;) { 123 123 Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 124 124 } -
src/builder.cpp
r6097ea r7f3b9d 59 59 * \param *mol the molecule to add to 60 60 */ 61 void AddAtoms(periodentafel *periode, molecule *mol)61 static void AddAtoms(periodentafel *periode, molecule *mol) 62 62 { 63 63 atom *first, *second, *third, *fourth; … … 113 113 cout << Verbose(0) << "Enter relative coordinates." << endl; 114 114 first->x.AskPosition(mol->cell_size, false); 115 for (int i= 0;i<3;i++) {115 for (int i=NDIM;i--;) { 116 116 first->x.x[i] += second->x.x[i]; 117 117 } … … 227 227 atoms = new (vector*[128]); 228 228 valid = true; 229 for(int i= 0;i<128;i++)229 for(int i=128;i--;) 230 230 atoms[i] = NULL; 231 231 int i=0, j=0; … … 256 256 * \param *mol the molecule with all the atoms 257 257 */ 258 void CenterAtoms(molecule *mol)258 static void CenterAtoms(molecule *mol) 259 259 { 260 260 vector x, y; … … 285 285 case 'c': 286 286 cout << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl; 287 for (int i=0;i< 3;i++) {287 for (int i=0;i<NDIM;i++) { 288 288 cout << Verbose(0) << "Enter axis " << i << " boundary: "; 289 289 cin >> y.x[i]; … … 295 295 case 'd': 296 296 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl; 297 for (int i=0;i< 3;i++) {297 for (int i=0;i<NDIM;i++) { 298 298 cout << Verbose(0) << "Enter axis " << i << " boundary: "; 299 299 cin >> x.x[i]; … … 311 311 * \param *mol the molecule with all the atoms 312 312 */ 313 void AlignAtoms(periodentafel *periode, molecule *mol)313 static void AlignAtoms(periodentafel *periode, molecule *mol) 314 314 { 315 315 atom *first, *second, *third; … … 359 359 cout << Verbose(0) << "Element is " << param.type->name << endl; 360 360 mol->GetAlignVector(¶m); 361 for (int i= 0;i<3;i++) {361 for (int i=NDIM;i--;) { 362 362 x.x[i] = gsl_vector_get(param.x,i); 363 n.x[i] = gsl_vector_get(param.x,i+ 3);363 n.x[i] = gsl_vector_get(param.x,i+NDIM); 364 364 } 365 365 gsl_vector_free(param.x); … … 379 379 * \param *mol the molecule with all the atoms 380 380 */ 381 void MirrorAtoms(molecule *mol)381 static void MirrorAtoms(molecule *mol) 382 382 { 383 383 atom *first, *second, *third; … … 426 426 * \param *mol the molecule with all the atoms 427 427 */ 428 void RemoveAtoms(molecule *mol)428 static void RemoveAtoms(molecule *mol) 429 429 { 430 430 atom *first, *second; … … 484 484 * \param *mol the molecule with all the atoms 485 485 */ 486 void MeasureAtoms(periodentafel *periode, molecule *mol)486 static void MeasureAtoms(periodentafel *periode, molecule *mol) 487 487 { 488 488 atom *first, *second, *third; … … 507 507 case 'a': 508 508 first = mol->AskAtom("Enter first atom: "); 509 for (int i= 0;i<256;i++)509 for (int i=MAX_ELEMENTS;i--;) 510 510 min[i] = 0.; 511 511 … … 523 523 //cout << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl; 524 524 } 525 for (int i= 0;i<256;i++)525 for (int i=MAX_ELEMENTS;i--;) 526 526 if (min[i] != 0.) cout << Verbose(0) << "Minimum Bond length between " << first->type->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl; 527 527 break; … … 530 530 first = mol->AskAtom("Enter first atom: "); 531 531 second = mol->AskAtom("Enter second atom: "); 532 for (int i= 0;i<NDIM;i++)532 for (int i=NDIM;i--;) 533 533 min[i] = 0.; 534 534 x.CopyVector((const vector *)&first->x); … … 560 560 * \param *configuration configuration structure for the to be written config files of all fragments 561 561 */ 562 void FragmentAtoms(molecule *mol, config *configuration)562 static void FragmentAtoms(molecule *mol, config *configuration) 563 563 { 564 564 int Order1; … … 581 581 /** Is called always as option 'T' in the menu. 582 582 */ 583 void testroutine(molecule *mol)583 static void testroutine(molecule *mol) 584 584 { 585 585 // the current test routine checks the functionality of the KeySet&Graph concept: … … 654 654 * \param *mol pointer to molecule structure with all the atoms and coordinates 655 655 */ 656 void SaveConfig(char *ConfigFileName, config *configuration, periodentafel *periode, molecule *mol)656 static void SaveConfig(char *ConfigFileName, config *configuration, periodentafel *periode, molecule *mol) 657 657 { 658 658 char filename[MAXSTRINGSIZE]; … … 709 709 * \return exit code (0 - successful, all else - something's wrong) 710 710 */ 711 int ParseCommandLineOptions(int argc, char **argv, molecule *&mol, periodentafel *&periode, config& configuration, char *&ConfigFileName, char *&ElementsFileName)711 static int ParseCommandLineOptions(int argc, char **argv, molecule *&mol, periodentafel *&periode, config& configuration, char *&ConfigFileName, char *&ElementsFileName) 712 712 { 713 713 element *finder; … … 846 846 ExitFlag = 1; 847 847 cout << Verbose(1) << "Translating all ions to new origin." << endl; 848 for (int i= 0;i<3;i++)848 for (int i=NDIM;i--;) 849 849 x.x[i] = atof(argv[argptr+i]); 850 850 mol->Translate((const vector *)&x); … … 855 855 cout << Verbose(1) << "Adding new atom." << endl; 856 856 first = new atom; 857 for (int i= 0;i<3;i++)857 for (int i=NDIM;i--;) 858 858 first->x.x[i] = atof(argv[argptr+1+i]); 859 859 finder = periode->start; … … 872 872 j = -1; 873 873 cout << Verbose(1) << "Scaling all ion positions by factor." << endl; 874 factor = (double *) Malloc(sizeof(double)*NDIM, "main: *factor");874 factor = new double[NDIM]; 875 875 factor[0] = atof(argv[argptr]); 876 876 if (argc > argptr+1) … … 881 881 factor[2] = atof(argv[argptr]); 882 882 mol->Scale(&factor); 883 for (int i=0;i< 3;i++) {883 for (int i=0;i<NDIM;i++) { 884 884 j += i+1; 885 x.x[i] = atof(argv[ 3+i]);885 x.x[i] = atof(argv[NDIM+i]); 886 886 mol->cell_size[j]*=factor[i]; 887 887 } 888 Free((void **)&factor, "main: *factor");888 delete[](factor); 889 889 argptr+=1; 890 890 break; … … 894 894 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl; 895 895 j=-1; 896 for (int i=0;i< 3;i++) {896 for (int i=0;i<NDIM;i++) { 897 897 j += i+1; 898 898 x.x[i] = atof(argv[argptr++]); … … 914 914 // translate each coordinate by boundary 915 915 j=-1; 916 for (int i=0;i< 3;i++) {916 for (int i=0;i<NDIM;i++) { 917 917 j += i+1; 918 918 x.x[i] = atof(argv[argptr++]); … … 1056 1056 second = mol->AskAtom("Enter second (shifting) atom: "); 1057 1057 min_bond = 0.; 1058 for (int i= 0;i<3;i++)1058 for (int i=NDIM;i--;) 1059 1059 min_bond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]); 1060 1060 min_bond = sqrt(min_bond); … … 1062 1062 cout << Verbose(0) << "Enter new bond length [a.u.]: "; 1063 1063 cin >> bond; 1064 for (int i= 0;i<3;i++) {1064 for (int i=NDIM;i--;) { 1065 1065 second->x.x[i] -= (second->x.x[i]-first->x.x[i])/min_bond*(min_bond-bond); 1066 1066 } … … 1107 1107 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times 1108 1108 x.AddVector(&y); // per factor one cell width further 1109 for (int k= 0;k<count;k++) { // go through every atom of the original cell1109 for (int k=count;k--;) { // go through every atom of the original cell 1110 1110 first = new atom(); // create a new body 1111 1111 first->x.CopyVector(Vectors[k]); // use coordinate of original atom -
src/config.cpp
r6097ea r7f3b9d 282 282 case 'j': // BoxLength 283 283 cout << Verbose(0) << "enter lower triadiagonalo form of basis matrix" << endl << endl; 284 for (int i= 0;i<6;i++) {284 for (int i=6;i--;) { 285 285 cout << Verbose(0) << "Cell size" << i << ": "; 286 286 cin >> mol->cell_size[i]; … … 408 408 409 409 /** Retrieves the path in the given config file name. 410 * \param *filename config file string410 * \param filename config file string 411 411 */ 412 void config::RetrieveConfigPathAndName( char *filename)412 void config::RetrieveConfigPathAndName(string filename) 413 413 { 414 414 char *ptr = NULL; 415 char *buffer = new char[MAXSTRINGSIZE]; 416 strncpy(buffer, filename.c_str(), MAXSTRINGSIZE); 415 417 int last = -1; 416 for(int i=0;i<MAXSTRINGSIZE;i++) { 417 if (filename[i] == '/') 418 last = i; 419 if (filename[i] == '\0') 418 for(last=MAXSTRINGSIZE;last--;) { 419 if (buffer[last] == '/') 420 420 break; 421 421 } 422 if (last == -1) { // no path in front, set to local directory.422 if (last == 0) { // no path in front, set to local directory. 423 423 strcpy(configpath, "./"); 424 ptr = filename;424 ptr = buffer; 425 425 } else { 426 strncpy(configpath, filename, last+1);427 ptr = & filename[last+1];426 strncpy(configpath, buffer, last+1); 427 ptr = &buffer[last+1]; 428 428 if (last < 254) 429 429 configpath[last+1]='\0'; … … 431 431 strcpy(configname, ptr); 432 432 cout << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl; 433 delete[](buffer); 433 434 }; 434 435 … … 824 825 825 826 826 for (i=0;i<128;i++) elementhash[i] = NULL; 827 for (i=MAX_ELEMENTS;i--;) 828 elementhash[i] = NULL; 827 829 cout << Verbose(0) << "Parsing Ions ..." << endl; 828 830 No=0; -
src/datacreator.cpp
r6097ea r7f3b9d 48 48 output << "#Order\tFrag.No.\t" << Energy.Header << endl; 49 49 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 50 for(int i= 0;i<KeySet.FragmentsPerOrder[BondOrder];i++) {51 for(int j= 0;j<Energy.RowCounter[ KeySet.OrderSet[BondOrder][i] ];j++)52 for(int k= 0;k<Energy.ColumnCounter;k++)50 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) { 51 for(int j=Energy.RowCounter[ KeySet.OrderSet[BondOrder][i] ];j--;) 52 for(int k=Energy.ColumnCounter;k--;) 53 53 Energy.Matrix[Energy.MatrixCounter][j][k] -= EnergyFragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 54 54 } … … 89 89 } 90 90 if (j != -1) 91 for(int k= 0;k<Force.ColumnCounter;k++) {91 for(int k=Force.ColumnCounter;k--;) { 92 92 Force.Matrix[Force.MatrixCounter][j][k] += ForceFragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][l][k]; 93 93 } … … 136 136 void CreateMaxFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySet, int BondOrder) 137 137 { 138 for(int j= 0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {139 for(int i= 0;i<KeySet.FragmentsPerOrder[BondOrder];i++) {138 for(int j=Fragments.RowCounter[ Fragments.MatrixCounter ];j--;) { 139 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) { 140 140 if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < fabs(Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][1])) { 141 for (int k= 0;k<Fragments.ColumnCounter;k++)141 for (int k=Fragments.ColumnCounter;k--;) 142 142 Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 143 143 } … … 156 156 int i=0; 157 157 do { // first get a minimum value unequal to 0 158 for (int k= 0;k<Fragments.ColumnCounter;k++)158 for (int k=Fragments.ColumnCounter;k--;) 159 159 Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 160 160 i++; … … 162 162 for(;i<KeySet.FragmentsPerOrder[BondOrder];i++) { // then find lowest 163 163 if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) > fabs(Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][1])) { 164 for (int k= 0;k<Fragments.ColumnCounter;k++)164 for (int k=Fragments.ColumnCounter;k--;) 165 165 Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 166 166 } … … 211 211 void CreateMinimumForce(class MatrixContainer &Force, int MatrixNumber) 212 212 { 213 for (int l= 0;l<Force.ColumnCounter;l++)213 for (int l=Force.ColumnCounter;l--;) 214 214 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.; 215 215 for (int l=5;l<Force.ColumnCounter;l+=3) { … … 217 217 int k=0; 218 218 do { 219 for (int m= 0;m<3;m++) {219 for (int m=NDIM;m--;) { 220 220 stored += Force.Matrix[MatrixNumber][ k ][l+m] 221 221 * Force.Matrix[MatrixNumber][ k ][l+m]; … … 226 226 for (;k<Force.RowCounter[MatrixNumber];k++) { 227 227 double tmp = 0; 228 for (int m= 0;m<3;m++)228 for (int m=NDIM;m--;) 229 229 tmp += Force.Matrix[MatrixNumber][ k ][l+m] 230 230 * Force.Matrix[MatrixNumber][ k ][l+m]; 231 231 if ((fabs(tmp) > MYEPSILON) && (tmp < stored)) { // current force is greater than stored 232 for (int m= 0;m<3;m++)232 for (int m=NDIM;m--;) 233 233 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m] = Force.Matrix[MatrixNumber][ k ][l+m]; 234 234 stored = tmp; … … 246 246 { 247 247 int divisor = 0; 248 for (int l= 0;l<Force.ColumnCounter;l++)248 for (int l=Force.ColumnCounter;l--;) 249 249 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.; 250 250 for (int l=5;l<Force.ColumnCounter;l+=3) { 251 251 double tmp = 0; 252 for (int k= 0;k<Force.RowCounter[MatrixNumber];k++) {252 for (int k=Force.RowCounter[MatrixNumber];k--;) { 253 253 double norm = 0.; 254 for (int m= 0;m<3;m++)254 for (int m=NDIM;m--;) 255 255 norm += Force.Matrix[MatrixNumber][ k ][l+m] 256 256 * Force.Matrix[MatrixNumber][ k ][l+m]; … … 272 272 for (int l=5;l<Force.ColumnCounter;l+=3) { 273 273 double stored = 0; 274 for (int k= 0;k<Force.RowCounter[MatrixNumber];k++) {274 for (int k=Force.RowCounter[MatrixNumber];k--;) { 275 275 double tmp = 0; 276 for (int m= 0;m<3;m++)276 for (int m=NDIM;m--;) 277 277 tmp += Force.Matrix[MatrixNumber][ k ][l+m] 278 278 * Force.Matrix[MatrixNumber][ k ][l+m]; 279 279 if (tmp > stored) { // current force is greater than stored 280 for (int m= 0;m<3;m++)280 for (int m=NDIM;m--;) 281 281 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m] = Force.Matrix[MatrixNumber][ k ][l+m]; 282 282 stored = tmp; … … 293 293 void CreateVectorSumForce(class MatrixContainer &Force, int MatrixNumber) 294 294 { 295 for (int l= 0;l<Force.ColumnCounter;l++)295 for (int l=Force.ColumnCounter;l--;) 296 296 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.; 297 297 for (int l=5;l<Force.ColumnCounter;l++) { 298 for (int k= 0;k<Force.RowCounter[MatrixNumber];k++)298 for (int k=Force.RowCounter[MatrixNumber];k--;) 299 299 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] += Force.Matrix[MatrixNumber][k][l]; 300 300 } … … 423 423 line >> item; 424 424 line >> item; 425 for (int i=7; i< Force.ColumnCounter;i+= 3) {425 for (int i=7; i< Force.ColumnCounter;i+=NDIM) { 426 426 line >> item; 427 427 item[strlen(item)-1] = '\0'; // kill residual index char (the '0') … … 452 452 line >> item; 453 453 line >> item; 454 for (int i=7; i< Force.ColumnCounter;i+= 3) {454 for (int i=7; i< Force.ColumnCounter;i+=NDIM) { 455 455 line >> item; 456 456 item[strlen(item)-1] = '\0'; // kill residual index char (the '0') … … 482 482 line >> item; 483 483 line >> item; 484 for (int i=7; i< Force.ColumnCounter;i+= 3) {484 for (int i=7; i< Force.ColumnCounter;i+=NDIM) { 485 485 line >> item; 486 486 item[strlen(item)-1] = '\0'; // kill residual index char (the '0') … … 512 512 line >> item; 513 513 line >> item; 514 for (int i=7; i< Force.ColumnCounter;i+= 3) {514 for (int i=7; i< Force.ColumnCounter;i+=NDIM) { 515 515 line >> item; 516 516 item[strlen(item)-1] = '\0'; // kill residual index char (the '0') -
src/helpers.cpp
r6097ea r7f3b9d 106 106 if (buffer == NULL) 107 107 cout << Verbose(0) << output << endl; 108 for (i= 0;i<size;i++) // reset108 for (i=size;i--;) // reset 109 109 buffer[i] = i % 2 == 0 ? 'p': 'c'; 110 110 buffer[size] = '\0'; // and set length marker on its end … … 147 147 int res = 1; 148 148 int j; 149 for (j= 0;j<n;j++)149 for (j=n;j--;) 150 150 res *= base; 151 151 return res; … … 172 172 returnstring[order] = '\0'; 173 173 number = digits; 174 for (int i=order-1;i >=0;i--){174 for (int i=order-1;i--;){ 175 175 returnstring[i] = '0' + (char)(number % 10); 176 176 number = (int)floor(((double)number / 10.)); -
src/helpers.hpp
r6097ea r7f3b9d 266 266 int i; 267 267 if (ptr != NULL) { 268 for(i= 0;i<dim;i++)268 for(i=dim;i--;) 269 269 if (ptr[i] != NULL) 270 270 free(ptr[i]); -
src/moleculelist.cpp
r6097ea r7f3b9d 22 22 { 23 23 ListOfMolecules = (molecule **) Malloc(sizeof(molecule *)*NumMolecules, "MoleculeListClass:MoleculeListClass: **ListOfMolecules"); 24 for (int i= 0;i<NumMolecules;i++)24 for (int i=NumMolecules;i--;) 25 25 ListOfMolecules[i] = NULL; 26 26 NumberOfMolecules = NumMolecules; … … 34 34 { 35 35 cout << Verbose(3) << this << ": Freeing ListOfMolcules." << endl; 36 for (int i= 0;i<NumberOfMolecules;i++) {36 for (int i=NumberOfMolecules;i--;) { 37 37 if (ListOfMolecules[i] != NULL) { // if NULL don't free 38 38 cout << Verbose(4) << "ListOfMolecules: Freeing " << ListOfMolecules[i] << "." << endl; … … 66 66 else { 67 67 Count = (**(molecule **)a).AtomCount; 68 aList = (int *) Malloc(sizeof(int)*Count, "MolCompare: *aList");69 bList = (int *) Malloc(sizeof(int)*Count, "MolCompare: *bList");68 aList = new int[Count]; 69 bList = new int[Count]; 70 70 71 71 // fill the lists … … 114 114 } 115 115 } 116 Free((void **)&aList, "MolCompare: *aList");117 Free((void **)&bList, "MolCompare: *bList");116 delete[](aList); 117 delete[](bList); 118 118 return flag; 119 119 } … … 244 244 ListOfMolecules[i]->SetBoxDimension(&BoxDimension); // update Box of atoms by boundary 245 245 int j = -1; 246 for (int k=0;k< 3;k++) {246 for (int k=0;k<NDIM;k++) { 247 247 j += k+1; 248 248 BoxDimension.x[k] = 5.; … … 268 268 outputFragment.close(); 269 269 outputFragment.clear(); 270 Free((void **)&FragmentNumber, "MoleculeListClass::OutputConfigForListOfFragments: *FragmentNumber"); 270 delete(FragmentNumber); 271 //Free((void **)&FragmentNumber, "MoleculeListClass::OutputConfigForListOfFragments: *FragmentNumber"); 271 272 } 272 273 cout << " done." << endl; … … 461 462 ListOfLocalAtoms = (atom ***) Malloc(sizeof(atom **)*Counter, "MoleculeLeafClass::FillBondStructureFromReference - ***ListOfLocalAtoms"); 462 463 if (ListOfLocalAtoms != NULL) { 463 for (int i= 0;i<Counter;i++)464 for (int i=Counter;i--;) 464 465 ListOfLocalAtoms[i] = NULL; 465 466 FreeList = FreeList && true; … … 501 502 KeySetCounter = Count(); 502 503 FragmentList = (Graph **) Malloc(sizeof(Graph *)*KeySetCounter, "MoleculeLeafClass::AssignKeySetsToFragment - **FragmentList"); 503 for(int i= 0;i<KeySetCounter;i++)504 for(int i=KeySetCounter;i--;) 504 505 FragmentList[i] = NULL; 505 506 KeySetCounter = 0; -
src/molecules.cpp
r6097ea r7f3b9d 21 21 int num = par->num; 22 22 23 for (int i= 0;i<num;i++) {24 for(int j= 0;j<NDIM;j++)23 for (int i=num;i--;) { 24 for(int j=NDIM;j--;) 25 25 sum += (gsl_vector_get(x,j) - (vectors[i])->x[j])*(gsl_vector_get(x,j) - (vectors[i])->x[j]); 26 26 } … … 57 57 NumberOfBondsPerAtom = NULL; 58 58 ElementCount = 0; 59 for(int i= 0;i<MAX_ELEMENTS;i++)59 for(int i=MAX_ELEMENTS;i--;) 60 60 ElementsInMolecule[i] = 0; 61 61 cell_size[0] = cell_size[2] = cell_size[5]= 20.; … … 69 69 { 70 70 if (ListOfBondsPerAtom != NULL) 71 for(int i= 0;i<AtomCount;i++)71 for(int i=AtomCount;i--;) 72 72 Free((void **)&ListOfBondsPerAtom[i], "molecule::~molecule: ListOfBondsPerAtom[i]"); 73 73 Free((void **)&ListOfBondsPerAtom, "molecule::~molecule: ListOfBondsPerAtom"); … … 200 200 // *out << endl; 201 201 OrthoVector1.Zero(); 202 for (int i= 0;i<NDIM;i++) {202 for (int i=NDIM;i--;) { 203 203 l = TopReplacement->x.x[i] - TopOrigin->x.x[i]; 204 204 if (fabs(l) > BondDistance) { // is component greater than bond distance … … 312 312 FirstOtherAtom->x.Zero(); 313 313 SecondOtherAtom->x.Zero(); 314 for(i= 0;i<NDIM;i++) { // rotate by half the bond angle in both directions (InBondVector is bondangle = 0 direction)314 for(i=NDIM;i--;) { // rotate by half the bond angle in both directions (InBondVector is bondangle = 0 direction) 315 315 FirstOtherAtom->x.x[i] = InBondVector.x[i] * cos(bondangle) + OrthoVector1.x[i] * (sin(bondangle)); 316 316 SecondOtherAtom->x.x[i] = InBondVector.x[i] * cos(bondangle) + OrthoVector1.x[i] * (-sin(bondangle)); … … 319 319 SecondOtherAtom->x.Scale(&BondRescale); 320 320 //*out << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl; 321 for(i= 0;i<NDIM;i++) { // and make relative to origin atom321 for(i=NDIM;i--;) { // and make relative to origin atom 322 322 FirstOtherAtom->x.x[i] += TopOrigin->x.x[i]; 323 323 SecondOtherAtom->x.x[i] += TopOrigin->x.x[i]; … … 471 471 first->type = elemente->FindElement(1); 472 472 } 473 for(j= 0;j<NDIM;j++)473 for(j=NDIM;j--;) 474 474 first->x.x[j] = x[j]; 475 475 AddAtom(first); // add to molecule … … 612 612 ptr = start->next; // start at first in list 613 613 if (ptr != end) { //list not empty? 614 for (int i= 0;i<NDIM;i++) {614 for (int i=NDIM;i--;) { 615 615 max->x[i] = ptr->x.x[i]; 616 616 min->x[i] = ptr->x.x[i]; … … 619 619 ptr = ptr->next; 620 620 //ptr->Output(1,1,out); 621 for (int i= 0;i<NDIM;i++) {621 for (int i=NDIM;i--;) { 622 622 max->x[i] = (max->x[i] < ptr->x.x[i]) ? ptr->x.x[i] : max->x[i]; 623 623 min->x[i] = (min->x[i] > ptr->x.x[i]) ? ptr->x.x[i] : min->x[i]; … … 626 626 } 627 627 // sanity check 628 for(int i= 0;i<NDIM;i++) {628 for(int i=NDIM;i--;) { 629 629 if (max->x[i] - min->x[i] > BoxLengths->x[i]) 630 630 status = false; … … 637 637 while (ptr->next != end) { 638 638 ptr = ptr->next; 639 for (int i= 0;i<NDIM;i++)639 for (int i=NDIM;i--;) 640 640 ptr->x.x[i] += -(max->x[i] + min->x[i])/2. + BoxLengths->x[i]/2.; // first term centers molecule at (0,0,0), second shifts to center of new box 641 641 } … … 659 659 atom *ptr = start->next; // start at first in list 660 660 if (ptr != end) { //list not empty? 661 for (int i= 0;i<NDIM;i++) {661 for (int i=NDIM;i--;) { 662 662 max->x[i] = ptr->x.x[i]; 663 663 min->x[i] = ptr->x.x[i]; … … 666 666 ptr = ptr->next; 667 667 //ptr->Output(1,1,out); 668 for (int i= 0;i<NDIM;i++) {668 for (int i=NDIM;i--;) { 669 669 max->x[i] = (max->x[i] < ptr->x.x[i]) ? ptr->x.x[i] : max->x[i]; 670 670 min->x[i] = (min->x[i] > ptr->x.x[i]) ? ptr->x.x[i] : min->x[i]; … … 677 677 // *out << endl; 678 678 679 for (int i= 0;i<NDIM;i++) {679 for (int i=NDIM;i--;) { 680 680 min->x[i] *= -1.; 681 681 max->x[i] += min->x[i]; … … 696 696 atom *ptr = start->next; // start at first in list 697 697 698 for(int i= 0;i<NDIM;i++) // zero center vector698 for(int i=NDIM;i--;) // zero center vector 699 699 center->x[i] = 0.; 700 700 … … 720 720 vector tmp; 721 721 722 for(int i= 0;i<NDIM;i++) // zero center vector722 for(int i=NDIM;i--;) // zero center vector 723 723 center->x[i] = 0.; 724 724 … … 957 957 bool result = true; 958 958 int j =-1; 959 for (int i=0;i< 3;i++) {959 for (int i=0;i<NDIM;i++) { 960 960 j += i+1; 961 961 result = result && ((x->x[i] >= 0) && (x->x[i] < cell_size[j])); … … 1207 1207 { 1208 1208 int i = 0; 1209 for(i= 0;i<MAX_ELEMENTS;i++)1209 for(i=MAX_ELEMENTS;i--;) 1210 1210 ElementsInMolecule[i] = 0; 1211 1211 ElementCount = 0; … … 1217 1217 i++; 1218 1218 } 1219 for(i= 0;i<MAX_ELEMENTS;i++)1219 for(i=MAX_ELEMENTS;i--;) 1220 1220 ElementCount += (ElementsInMolecule[i] != 0 ? 1 : 0); 1221 1221 }; … … 1282 1282 { 1283 1283 configuration.MaxPsiDouble = configuration.PsiMaxNoDown = configuration.PsiMaxNoUp = configuration.PsiType = 0; 1284 for(int i= 0;i<MAX_ELEMENTS;i++) {1284 for(int i=MAX_ELEMENTS;i--;) { 1285 1285 if (ElementsInMolecule[i] != 0) { 1286 1286 //cout << "CalculateOrbitals: " << elemente->FindElement(i)->name << " has a valence of " << (int)elemente->FindElement(i)->Valence << " and there are " << ElementsInMolecule[i] << " of it." << endl; … … 1352 1352 *out << Verbose(1) << "Allocating " << NumberCells << " cells." << endl; 1353 1353 CellList = (molecule **) Malloc(sizeof(molecule *)*NumberCells, "molecule::CreateAdjacencyList - ** CellList"); 1354 for (int i= 0;i<NumberCells;i++)1354 for (int i=NumberCells;i--;) 1355 1355 CellList[i] = NULL; 1356 1356 … … 1382 1382 1383 1383 // 3a. go through every cell 1384 for (N[0]= 0;N[0]<divisor[0];N[0]++)1385 for (N[1]= 0;N[1]<divisor[1];N[1]++)1386 for (N[2]= 0;N[2]<divisor[2];N[2]++) {1384 for (N[0]=divisor[0];N[0]--;) 1385 for (N[1]=divisor[1];N[1]--;) 1386 for (N[2]=divisor[2];N[2]--;) { 1387 1387 Index = N[2] + (N[1] + N[0] * divisor[1]) * divisor[2]; 1388 1388 if (CellList[Index] != NULL) { // if there atoms in this cell … … 1424 1424 } 1425 1425 // 4. free the cell again 1426 for (int i= 0;i<NumberCells;i++)1426 for (int i=NumberCells;i--;) 1427 1427 if (CellList[i] != NULL) { 1428 1428 delete(CellList[i]); … … 1696 1696 1697 1697 // initialise each vertex as white with no predecessor, empty queue, color Root lightgray 1698 for (int i= 0;i<AtomCount;i++) {1698 for (int i=AtomCount;i--;) { 1699 1699 PredecessorList[i] = NULL; 1700 1700 ShortestPathList[i] = -1; … … 1702 1702 } 1703 1703 MinimumRingSize = new int[AtomCount]; 1704 for(int i= 0;i<AtomCount;i++)1704 for(int i=AtomCount;i--;) 1705 1705 MinimumRingSize[i] = AtomCount; 1706 1706 … … 1891 1891 Free((void **)&Walker->ComponentNr, "molecule::InitComponentNumbers: **Walker->ComponentNr"); 1892 1892 Walker->ComponentNr = (int *) Malloc(sizeof(int)*NumberOfBondsPerAtom[Walker->nr], "molecule::InitComponentNumbers: *Walker->ComponentNr"); 1893 for (int i= 0;i<NumberOfBondsPerAtom[Walker->nr];i++)1893 for (int i=NumberOfBondsPerAtom[Walker->nr];i--;) 1894 1894 Walker->ComponentNr[i] = -1; 1895 1895 } … … 2261 2261 2262 2262 // initialize mask list 2263 for(int i= 0;i<AtomCount;i++)2263 for(int i=AtomCount;i--;) 2264 2264 AtomMask[i] = false; 2265 2265 … … 2414 2414 } 2415 2415 SortIndex = (int *) Malloc(sizeof(int)*AtomCount, "molecule::FragmentMolecule: *SortIndex"); 2416 for(int i= 0;i<AtomCount;i++)2416 for(int i=AtomCount;i--;) 2417 2417 SortIndex[i] = -1; 2418 2418 while (runner->next != elemente->end) { // go through every element … … 2533 2533 2534 2534 // free the index lookup list 2535 for (int i= 0;i<FragmentCounter;i++)2535 for (int i=FragmentCounter;i--;) 2536 2536 Free((void **)&ListOfLocalAtoms[i], "molecule::FragmentMolecule - *ListOfLocalAtoms[]"); 2537 2537 Free((void **)&ListOfLocalAtoms, "molecule::FragmentMolecule - **ListOfLocalAtoms"); … … 2649 2649 2650 2650 *out << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl; 2651 for(int i= 0;i<AtomCount;i++)2651 for(int i=AtomCount;i--;) 2652 2652 OrderArray[i] = 0; 2653 2653 line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE; 2654 2654 file.open(line.str().c_str()); 2655 2655 if (file != NULL) { 2656 for (int i= 0;i<AtomCount;i++) // initialise with 02656 for (int i=AtomCount;i--;) // initialise with 0 2657 2657 OrderArray[i] = 0; 2658 2658 while (!file.eof()) { // parse from file … … 2697 2697 *out << Verbose(2) << "(Re-)Allocating memory." << endl; 2698 2698 if (ListOfBondsPerAtom != NULL) { 2699 for(int i= 0;i<AtomCount;i++)2699 for(int i=AtomCount;i--;) 2700 2700 Free((void **)&ListOfBondsPerAtom[i], "molecule::CreateListOfBondsPerAtom: ListOfBondsPerAtom[i]"); 2701 2701 Free((void **)&ListOfBondsPerAtom, "molecule::CreateListOfBondsPerAtom: ListOfBondsPerAtom"); … … 2707 2707 2708 2708 // reset bond counts per atom 2709 for(int i= 0;i<AtomCount;i++)2709 for(int i=AtomCount;i--;) 2710 2710 NumberOfBondsPerAtom[i] = 0; 2711 2711 // count bonds per atom … … 2716 2716 NumberOfBondsPerAtom[Binder->rightatom->nr]++; 2717 2717 } 2718 // allocate list of bonds per atom2719 for(int i=0;i<AtomCount;i++)2718 for(int i=AtomCount;i--;) { 2719 // allocate list of bonds per atom 2720 2720 ListOfBondsPerAtom[i] = (bond **) Malloc(sizeof(bond *)*NumberOfBondsPerAtom[i], "molecule::CreateListOfBondsPerAtom: **ListOfBondsPerAtom[]"); 2721 // clear the list again, now each NumberOfBondsPerAtom marks current free field 2722 for(int i=0;i<AtomCount;i++) 2721 // clear the list again, now each NumberOfBondsPerAtom marks current free field 2723 2722 NumberOfBondsPerAtom[i] = 0; 2723 } 2724 2724 // fill the list 2725 2725 Binder = first; … … 2774 2774 2775 2775 // initialise each vertex as white with no predecessor, empty queue, color Root lightgray 2776 for (int i= 0;i<AtomCount;i++) {2776 for (int i=AtomCount;i--;) { 2777 2777 PredecessorList[i] = NULL; 2778 2778 ShortestPathList[i] = -1; … … 2890 2890 // reset parent list 2891 2891 *out << Verbose(3) << "Resetting ParentList." << endl; 2892 for (int i= 0;i<Father->AtomCount;i++)2892 for (int i=Father->AtomCount;i--;) 2893 2893 ParentList[i] = NULL; 2894 2894 … … 2972 2972 2973 2973 Leaf->BondDistance = BondDistance; 2974 for(int i= 0;i<NDIM*2;i++)2974 for(int i=NDIM*2;i--;) 2975 2975 Leaf->cell_size[i] = cell_size[i]; 2976 2976 2977 2977 // initialise SonList (indicates when we need to replace a bond with hydrogen instead) 2978 for(int i= 0;i<AtomCount;i++)2978 for(int i=AtomCount;i--;) 2979 2979 SonList[i] = NULL; 2980 2980 … … 3298 3298 // initialised touched list (stores added atoms on this level) 3299 3299 *out << Verbose(1+verbosity) << "Clearing touched list." << endl; 3300 for (TouchedIndex= 0;TouchedIndex<=SubOrder;TouchedIndex++) // empty touched list3300 for (TouchedIndex=SubOrder+1;TouchedIndex--;) // empty touched list 3301 3301 TouchedList[TouchedIndex] = -1; 3302 3302 TouchedIndex = 0; … … 3307 3307 // count the set bit of i 3308 3308 bits = 0; 3309 for (int j= 0;j<SetDimension;j++)3309 for (int j=SetDimension;j--;) 3310 3310 bits += (i & (1 << j)) >> j; 3311 3311 … … 3339 3339 while (Binder->next != FragmentSearch->BondsPerSPList[2*SP+1]) { // compare to end node of this level 3340 3340 Binder = Binder->next; 3341 for (int k= 0;k<TouchedIndex;k++) {3341 for (int k=TouchedIndex;k--;) { 3342 3342 if (Binder->Contains(TouchedList[k])) // if we added this very endpiece 3343 3343 SubSetDimension++; … … 3419 3419 int Counter = FragmentSearch.FragmentCounter; 3420 3420 3421 for (int i= 0;i<AtomCount;i++) {3421 for (int i=AtomCount;i--;) { 3422 3422 PredecessorList[i] = NULL; 3423 3423 } … … 3431 3431 FragmentSearch.ShortestPathList[RootKeyNr] = 0; 3432 3432 // prepare the atom stack counters (number of atoms with certain SP on stack) 3433 for (int i= 0;i<Order;i++)3433 for (int i=Order;i--;) 3434 3434 NumberOfAtomsSPLevel[i] = 0; 3435 3435 NumberOfAtomsSPLevel[0] = 1; // for root … … 3528 3528 } 3529 3529 3530 // creating fragments with the found edge sets 3530 // creating fragments with the found edge sets (may be done in reverse order, faster) 3531 3531 SP = 0; 3532 for(int i= 0;i<Order;i++) { // sum up all found edges3532 for(int i=Order;i--;) { // sum up all found edges 3533 3533 Binder = FragmentSearch.BondsPerSPList[2*i]; 3534 3534 while (Binder->next != FragmentSearch.BondsPerSPList[2*i+1]) { … … 3576 3576 // free'ing the bonds lists 3577 3577 *out << Verbose(0) << "Free'ing all found lists. and resetting index lists" << endl; 3578 for(int i= 0;i<Order;i++) {3578 for(int i=Order;i--;) { 3579 3579 *out << Verbose(1) << "Current SP level is " << i << ": "; 3580 3580 Binder = FragmentSearch.BondsPerSPList[2*i]; … … 3625 3625 while (flag) { 3626 3626 // remove bonds that are beyond bonddistance 3627 for(int i= 0;i<NDIM;i++)3627 for(int i=NDIM;i--;) 3628 3628 TranslationVector.x[i] = 0.; 3629 3629 // scan all bonds … … 3632 3632 while ((!flag) && (Binder->next != last)) { 3633 3633 Binder = Binder->next; 3634 for (int i= 0;i<NDIM;i++) {3634 for (int i=NDIM;i--;) { 3635 3635 tmp = fabs(Binder->leftatom->x.x[i] - Binder->rightatom->x.x[i]); 3636 3636 //*out << Verbose(3) << "Checking " << i << "th distance of " << *Binder->leftatom << " to " << *Binder->rightatom << ": " << tmp << "." << endl; … … 3646 3646 if (flag) { 3647 3647 // create translation vector from their periodically modified distance 3648 for (int i= 0;i<NDIM;i++) {3648 for (int i=NDIM;i--;) { 3649 3649 tmp = Binder->leftatom->x.x[i] - Binder->rightatom->x.x[i]; 3650 3650 if (fabs(tmp) > BondDistance) … … 3656 3656 //*out << endl; 3657 3657 // apply to all atoms of first component via BFS 3658 for (int i= 0;i<AtomCount;i++)3658 for (int i=AtomCount;i--;) 3659 3659 ColorList[i] = white; 3660 3660 AtomStack->Push(Binder->leftatom); … … 3832 3832 FragmentSearch.FragmentSet = new KeySet; 3833 3833 FragmentSearch.Root = FindAtom(RootKeyNr); 3834 for (int i= 0;i<AtomCount;i++) {3834 for (int i=AtomCount;i--;) { 3835 3835 FragmentSearch.Labels[i] = -1; 3836 3836 FragmentSearch.ShortestPathList[i] = -1; … … 3865 3865 FragmentSearch.BondsPerSPList = (bond **) Malloc(sizeof(bond *)*Order*2, "molecule::PowerSetGenerator: ***BondsPerSPList"); 3866 3866 FragmentSearch.BondsPerSPCount = (int *) Malloc(sizeof(int)*Order, "molecule::PowerSetGenerator: *BondsPerSPCount"); 3867 for (int i= 0;i<Order;i++) {3867 for (int i=Order;i--;) { 3868 3868 FragmentSearch.BondsPerSPList[2*i] = new bond(); // start node 3869 3869 FragmentSearch.BondsPerSPList[2*i+1] = new bond(); // end node … … 3933 3933 // free Order-dependent entries of UniqueFragments structure for next loop cycle 3934 3934 Free((void **)&FragmentSearch.BondsPerSPCount, "molecule::PowerSetGenerator: *BondsPerSPCount"); 3935 for (int i= 0;i<Order;i++) {3935 for (int i=Order;i--;) { 3936 3936 delete(FragmentSearch.BondsPerSPList[2*i]); 3937 3937 delete(FragmentSearch.BondsPerSPList[2*i+1]); … … 3989 3989 * \return <0, \a *a less than \a *b, ==0 if equal, >0 \a *a greater than \a *b 3990 3990 */ 3991 in t CompareDoubles (const void * a, const void * b)3991 inline int CompareDoubles (const void * a, const void * b) 3992 3992 { 3993 3993 if (*(double *)a > *(double *)b) … … 4040 4040 /// -# ElementsInMolecule 4041 4041 if (result) { 4042 for (flag= 0;flag<MAX_ELEMENTS;flag++) {4042 for (flag=MAX_ELEMENTS;flag--;) { 4043 4043 //*out << Verbose(5) << "Element " << flag << ": " << ElementsInMolecule[flag] << " <-> " << OtherMolecule->ElementsInMolecule[flag] << "." << endl; 4044 4044 if (ElementsInMolecule[flag] != OtherMolecule->ElementsInMolecule[flag]) … … 4074 4074 while (Walker->next != end) { 4075 4075 Walker = Walker->next; 4076 //for (i=0;i<AtomCount;i++) {4077 4076 Distances[Walker->nr] = CenterOfGravity.Distance(&Walker->x); 4078 4077 } … … 4091 4090 PermutationMap = (int *) Malloc(sizeof(int)*AtomCount, "molecule::IsEqualToWithinThreshold: *PermutationMap"); 4092 4091 *out << Verbose(5) << "Combining Permutation Maps" << endl; 4093 for(int i= 0;i<AtomCount;i++)4092 for(int i=AtomCount;i--;) 4094 4093 PermutationMap[PermMap[i]] = (int) OtherPermMap[i]; 4095 4094 … … 4136 4135 *out << Verbose(3) << "Begin of GetFatherAtomicMap." << endl; 4137 4136 int *AtomicMap = (int *) Malloc(sizeof(int)*AtomCount, "molecule::GetAtomicMap: *AtomicMap"); //Calloc 4138 for (int i= 0;i<AtomCount;i++)4137 for (int i=AtomCount;i--;) 4139 4138 AtomicMap[i] = -1; 4140 4139 if (OtherMolecule == this) { // same molecule 4141 for (int i= 0;i<AtomCount;i++) // no need as -1 means already that there is trivial correspondence4140 for (int i=AtomCount;i--;) // no need as -1 means already that there is trivial correspondence 4142 4141 AtomicMap[i] = i; 4143 4142 *out << Verbose(4) << "Map is trivial." << endl; -
src/molecules.hpp
r6097ea r7f3b9d 457 457 void Load(char *filename, periodentafel *periode, molecule *mol); 458 458 void LoadOld(char *filename, periodentafel *periode, molecule *mol); 459 void RetrieveConfigPathAndName( char *filename);459 void RetrieveConfigPathAndName(string filename); 460 460 bool Save(ofstream *file, periodentafel *periode, molecule *mol) const; 461 461 void Edit(molecule *mol); -
src/parser.cpp
r6097ea r7f3b9d 64 64 MatrixContainer::~MatrixContainer() { 65 65 if (Matrix != NULL) { 66 for(int i= 0;i<MatrixCounter;i++) {66 for(int i=MatrixCounter;i--;) { 67 67 if (RowCounter != NULL) { 68 for(int j= 0;j<=RowCounter[i];j++)68 for(int j=RowCounter[i]+1;j--;) 69 69 Free((void **)&Matrix[i][j], "MatrixContainer::~MatrixContainer: *Matrix[][]"); 70 70 Free((void **)&Matrix[i], "MatrixContainer::~MatrixContainer: **Matrix[]"); … … 72 72 } 73 73 if ((RowCounter != NULL) && (Matrix[MatrixCounter] != NULL)) 74 for(int j= 0;j<=RowCounter[MatrixCounter];j++)74 for(int j=RowCounter[MatrixCounter]+1;j--;) 75 75 Free((void **)&Matrix[MatrixCounter][j], "MatrixContainer::~MatrixContainer: *Matrix[MatrixCounter][]"); 76 76 if (MatrixCounter != 0) … … 79 79 } 80 80 if (Indices != NULL) 81 for(int i= 0;i<=MatrixCounter;i++) {81 for(int i=MatrixCounter+1;i--;) { 82 82 Free((void **)&Indices[i], "MatrixContainer::~MatrixContainer: *Indices[]"); 83 83 } … … 123 123 Matrix = (double ***) Malloc(sizeof(double **)*(MatrixCounter+1), "MatrixContainer::ParseMatrix: ***Matrix"); // one more each for the total molecule 124 124 RowCounter = (int *) Malloc(sizeof(int)*(MatrixCounter+1), "MatrixContainer::ParseMatrix: *RowCounter"); 125 for(int i= 0;i<=MatrixCounter;i++) {125 for(int i=MatrixCounter+1;i--;) { 126 126 Matrix[i] = NULL; 127 127 RowCounter[i] = -1; 128 128 } 129 for(int i= 0;i<=MatrixCounter;i++) {129 for(int i=MatrixCounter+1;i--;) { 130 130 // open matrix file 131 131 stringstream line; … … 143 143 } 144 144 // skip some initial lines 145 for (int m= 0;m<=skiplines;m++)145 for (int m=skiplines+1;m--;) 146 146 input.getline(Header, 1023); 147 147 // scan header for number of columns 148 148 line.str(Header); 149 for(int k= 0;k<skipcolumns;k++)149 for(int k=skipcolumns;k--;) 150 150 line >> Header; 151 151 //cout << line.str() << endl; … … 173 173 input.clear(); 174 174 input.seekg(ios::beg); 175 for (int m= 0;m<=skiplines;m++)175 for (int m=skiplines+1;m--;) 176 176 input.getline(Header, 1023); // skip header 177 177 line.str(Header); 178 for(int k= 0;k<skipcolumns;k++) // skip columns in header too178 for(int k=skipcolumns;k--;) // skip columns in header too 179 179 line >> filename; 180 180 strncpy(Header, line.str().c_str(), 1023); … … 184 184 stringstream line(filename); 185 185 //cout << "Matrix at level " << j << ":";// << filename << endl; 186 for(int k= 0;k<skipcolumns;k++)186 for(int k=skipcolumns;k--;) 187 187 line >> filename; 188 188 for(int k=0;(k<ColumnCounter) && (!line.eof());k++) { … … 193 193 } 194 194 Matrix[i][ RowCounter[i] ] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseMatrix: *Matrix[RowCounter[i]][]"); 195 for(int j= 0;j<ColumnCounter;j++)195 for(int j=ColumnCounter;j--;) 196 196 Matrix[i][ RowCounter[i] ][j] = 0.; 197 197 input.close(); … … 216 216 Matrix = (double ***) Malloc(sizeof(double **)*(MatrixCounter+1), "MatrixContainer::ParseMatrix: ***Matrix"); // one more each for the total molecule 217 217 RowCounter = (int *) Malloc(sizeof(int)*(MatrixCounter+1), "MatrixContainer::ParseMatrix: *RowCounter"); 218 for(int i= 0;i<=MatrixCounter;i++) {218 for(int i=MatrixCounter+1;i--;) { 219 219 RowCounter[i] = RCounter[i]; 220 220 Matrix[i] = (double **) Malloc(sizeof(double *)*(RowCounter[i]+1), "MatrixContainer::ParseMatrix: **Matrix[]"); 221 for(int j= 0;j<=RowCounter[i];j++) {221 for(int j=RowCounter[i]+1;j--;) { 222 222 Matrix[i][j] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseMatrix: *Matrix[][]"); 223 for(int k= 0;k<ColumnCounter;k++)223 for(int k=ColumnCounter;k--;) 224 224 Matrix[i][j][k] = 0.; 225 225 } … … 233 233 bool MatrixContainer::ResetMatrix() 234 234 { 235 for(int i= 0;i<=MatrixCounter;i++)236 for(int j= 0;j<=RowCounter[i];j++)237 for(int k= 0;k<ColumnCounter;k++)235 for(int i=MatrixCounter+1;i--;) 236 for(int j=RowCounter[i]+1;j--;) 237 for(int k=ColumnCounter;k--;) 238 238 Matrix[i][j][k] = 0.; 239 239 return true; … … 247 247 bool MatrixContainer::SetLastMatrix(double value, int skipcolumns) 248 248 { 249 for(int j= 0;j<=RowCounter[MatrixCounter];j++)249 for(int j=RowCounter[MatrixCounter]+1;j--;) 250 250 for(int k=skipcolumns;k<ColumnCounter;k++) 251 251 Matrix[MatrixCounter][j][k] = value; … … 260 260 bool MatrixContainer::SetLastMatrix(double **values, int skipcolumns) 261 261 { 262 for(int j= 0;j<=RowCounter[MatrixCounter];j++)262 for(int j=RowCounter[MatrixCounter]+1;j--;) 263 263 for(int k=skipcolumns;k<ColumnCounter;k++) 264 264 Matrix[MatrixCounter][j][k] = values[j][k]; … … 301 301 } 302 302 if (Order == SubOrder) { // equal order is always copy from Energies 303 for(int l= 0;l<ColumnCounter;l++) // then adds/subtract each column303 for(int l=ColumnCounter;l--;) // then adds/subtract each column 304 304 Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][m][l] += MatrixValues.Matrix[ KeySet.OrderSet[SubOrder][j] ][k][l]; 305 305 } else { 306 for(int l= 0;l<ColumnCounter;l++)306 for(int l=ColumnCounter;l--;) 307 307 Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][m][l] -= Matrix[ KeySet.OrderSet[SubOrder][j] ][k][l]; 308 308 } … … 392 392 cout << "Parsing energy indices." << endl; 393 393 Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "EnergyMatrix::ParseIndices: **Indices"); 394 for(int i= 0;i<=MatrixCounter;i++) {394 for(int i=MatrixCounter+1;i--;) { 395 395 Indices[i] = (int *) Malloc(sizeof(int)*RowCounter[i], "EnergyMatrix::ParseIndices: *Indices[]"); 396 for(int j= 0;j<RowCounter[i];j++)396 for(int j=RowCounter[i];j--;) 397 397 Indices[i][j] = j; 398 398 } … … 410 410 { 411 411 // sum energy 412 for(int i= 0;i<KeySet.FragmentsPerOrder[Order];i++)413 for(int j= 0;j<RowCounter[ KeySet.OrderSet[Order][i] ];j++)414 for(int k= 0;k<ColumnCounter;k++)412 for(int i=KeySet.FragmentsPerOrder[Order];i--;) 413 for(int j=RowCounter[ KeySet.OrderSet[Order][i] ];j--;) 414 for(int k=ColumnCounter;k--;) 415 415 Matrix[MatrixCounter][j][k] += Fragments.Matrix[ KeySet.OrderSet[Order][i] ][j][k]; 416 416 return true; … … 455 455 } 456 456 Indices[MatrixCounter] = (int *) Malloc(sizeof(int)*RowCounter[MatrixCounter], "ForceMatrix::ParseIndices: *Indices[]"); 457 for(int j= 0;j<RowCounter[MatrixCounter];j++) {457 for(int j=RowCounter[MatrixCounter];j--;) { 458 458 Indices[MatrixCounter][j] = j; 459 459 } … … 503 503 */ 504 504 KeySetsContainer::~KeySetsContainer() { 505 for(int i= 0;i<FragmentCounter;i++)505 for(int i=FragmentCounter;i--;) 506 506 Free((void **)&KeySets[i], "KeySetsContainer::~KeySetsContainer: *KeySets[]"); 507 for(int i= 0;i<Order;i++)507 for(int i=Order;i--;) 508 508 Free((void **)&OrderSet[i], "KeySetsContainer::~KeySetsContainer: *OrderSet[]"); 509 509 Free((void **)&KeySets, "KeySetsContainer::~KeySetsContainer: **KeySets"); … … 528 528 cout << "Parsing key sets." << endl; 529 529 KeySets = (int **) Malloc(sizeof(int *)*FragmentCounter, "KeySetsContainer::ParseKeySets: **KeySets"); 530 for(int i= 0;i<FragmentCounter;i++)530 for(int i=FragmentCounter;i--;) 531 531 KeySets[i] = NULL; 532 532 line << name << FRAGMENTPREFIX << KEYSETFILE; … … 543 543 // parse the values 544 544 KeySets[i] = (int *) Malloc(sizeof(int)*AtomCounter[i], "KeySetsContainer::ParseKeySets: *KeySets[]"); 545 for(int j= 0;j<AtomCounter[i];j++)545 for(int j=AtomCounter[i];j--;) 546 546 KeySets[i][j] = -1; 547 547 FragmentNumber = FixedDigitNumber(FragmentCounter, i); … … 570 570 // scan through all to determine order 571 571 Order=0; 572 for(int i= 0;i<FragmentCounter;i++) {572 for(int i=FragmentCounter;i--;) { 573 573 Counter=0; 574 for(int j= 0;j<AtomCounter[i];j++)574 for(int j=AtomCounter[i];j--;) 575 575 if (KeySets[i][j] != -1) 576 576 Counter++; … … 582 582 // scan through all to determine fragments per order 583 583 FragmentsPerOrder = (int *) Malloc(sizeof(int)*Order, "KeySetsContainer::ParseManyBodyTerms: *FragmentsPerOrder"); 584 for(int i= 0;i<Order;i++)584 for(int i=Order;i--;) 585 585 FragmentsPerOrder[i] = 0; 586 for(int i= 0;i<FragmentCounter;i++) {586 for(int i=FragmentCounter;i--;) { 587 587 Counter=0; 588 for(int j= 0;j<AtomCounter[i];j++)588 for(int j=AtomCounter[i];j--;) 589 589 if (KeySets[i][j] != -1) 590 590 Counter++; … … 596 596 // scan through all to gather indices to each order set 597 597 OrderSet = (int **) Malloc(sizeof(int *)*Order, "KeySetsContainer::ParseManyBodyTerms: **OrderSet"); 598 for(int i= 0;i<Order;i++)598 for(int i=Order;i--;) 599 599 OrderSet[i] = (int *) Malloc(sizeof(int)*FragmentsPerOrder[i], "KeySetsContainer::ParseManyBodyTermsKeySetsContainer::ParseManyBodyTerms: *OrderSet[]"); 600 for(int i= 0;i<Order;i++)600 for(int i=Order;i--;) 601 601 FragmentsPerOrder[i] = 0; 602 for(int i= 0;i<FragmentCounter;i++) {602 for(int i=FragmentCounter;i--;) { 603 603 Counter=0; 604 for(int j= 0;j<AtomCounter[i];j++)604 for(int j=AtomCounter[i];j--;) 605 605 if (KeySets[i][j] != -1) 606 606 Counter++; … … 632 632 if ((GreaterSet < 0) || (SmallerSet < 0) || (GreaterSet > FragmentCounter) || (SmallerSet > FragmentCounter)) // index out of bounds 633 633 return false; 634 for(int i= 0;i<AtomCounter[SmallerSet];i++) {634 for(int i=AtomCounter[SmallerSet];i--;) { 635 635 intermediate = false; 636 for (int j= 0;j<AtomCounter[GreaterSet];j++)636 for (int j=AtomCounter[GreaterSet];j--;) 637 637 intermediate = (intermediate || ((KeySets[SmallerSet][i] == KeySets[GreaterSet][j]) || (KeySets[SmallerSet][i] == -1))); 638 638 result = result && intermediate; -
src/stackclass.hpp
r6097ea r7f3b9d 251 251 template <typename T> void StackClass<T>::ClearStack() 252 252 { 253 for(int i= 0;i<EntryCount; i++)253 for(int i=EntryCount; i--;) 254 254 StackList[i] = NULL; 255 255 CurrentFirstEntry = 0; -
src/vector.cpp
r6097ea r7f3b9d 25 25 { 26 26 double res = 0.; 27 for (int i= 0;i<NDIM;i++)27 for (int i=NDIM;i--;) 28 28 res += (x[i]-y->x[i])*(x[i]-y->x[i]); 29 29 return (res); … … 55 55 // create the translation vector 56 56 TranslationVector.Zero(); 57 for (int i= 0;i<NDIM;i++)57 for (int i=NDIM;i--;) 58 58 TranslationVector.x[i] = (double)N[i]; 59 59 TranslationVector.MatrixMultiplication(matrix); … … 84 84 TestVector.CopyVector(this); 85 85 TestVector.InverseMatrixMultiplication(matrix); 86 for(int i= 0;i<NDIM;i++) { // correct periodically86 for(int i=NDIM;i--;) { // correct periodically 87 87 if (TestVector.x[i] < 0) { // get every coefficient into the interval [0,1) 88 88 TestVector.x[i] += ceil(TestVector.x[i]); … … 106 106 { 107 107 double res = 0.; 108 for (int i= 0;i<NDIM;i++)108 for (int i=NDIM;i--;) 109 109 res += x[i]*y->x[i]; 110 110 return (res); … … 126 126 { 127 127 double res = 0.; 128 for (int i= 0;i<NDIM;i++)128 for (int i=NDIM;i--;) 129 129 res += this->x[i]*this->x[i]; 130 130 return (sqrt(res)); … … 136 136 { 137 137 double res = 0.; 138 for (int i= 0;i<NDIM;i++)138 for (int i=NDIM;i--;) 139 139 res += this->x[i]*this->x[i]; 140 140 res = 1./sqrt(res); … … 146 146 void vector::Zero() 147 147 { 148 for (int i= 0;i<NDIM;i++)148 for (int i=NDIM;i--;) 149 149 this->x[i] = 0.; 150 150 }; … … 259 259 void vector::Scale(double **factor) 260 260 { 261 for (int i= 0;i<NDIM;i++)261 for (int i=NDIM;i--;) 262 262 x[i] *= (*factor)[i]; 263 263 }; … … 265 265 void vector::Scale(double *factor) 266 266 { 267 for (int i= 0;i<NDIM;i++)267 for (int i=NDIM;i--;) 268 268 x[i] *= *factor; 269 269 }; … … 271 271 void vector::Scale(double factor) 272 272 { 273 for (int i= 0;i<NDIM;i++)273 for (int i=NDIM;i--;) 274 274 x[i] *= factor; 275 275 }; … … 280 280 void vector::Translate(const vector *trans) 281 281 { 282 for (int i= 0;i<NDIM;i++)282 for (int i=NDIM;i--;) 283 283 x[i] += trans->x[i]; 284 284 }; … … 295 295 C.x[2] = M[2]*x[0]+M[5]*x[1]+M[8]*x[2]; 296 296 // transfer the result into this 297 for (int i= 0;i<NDIM;i++)297 for (int i=NDIM;i--;) 298 298 x[i] = C.x[i]; 299 299 }; … … 327 327 C.x[2] = B[2]*x[0]+B[5]*x[1]+B[8]*x[2]; 328 328 // transfer the result into this 329 for (int i= 0;i<NDIM;i++)329 for (int i=NDIM;i--;) 330 330 x[i] = C.x[i]; 331 331 } else { … … 344 344 void vector::LinearCombinationOfVectors(const vector *x1, const vector *x2, const vector *x3, double *factors) 345 345 { 346 for(int i= 0;i<NDIM;i++)346 for(int i=NDIM;i--;) 347 347 x[i] = factors[0]*x1->x[i] + factors[1]*x2->x[i] + factors[2]*x3->x[i]; 348 348 }; … … 359 359 Output((ofstream *)&cout); 360 360 cout << "\t"; 361 for (int i= 0;i<NDIM;i++)361 for (int i=NDIM;i--;) 362 362 x[i] -= 2.*projection*n->x[i]; 363 363 cout << "Projected vector: "; … … 446 446 x1.Scale(x1.Projection(this)); 447 447 SubtractVector(&x1); 448 for (int i= 0;i<NDIM;i++)448 for (int i=NDIM;i--;) 449 449 result = result || (fabs(x[i]) > MYEPSILON); 450 450 … … 468 468 vector->Output((ofstream *)&cout); 469 469 cout << endl; 470 for (j= 0;j<NDIM;j++)470 for (j=NDIM;j--;) 471 471 Components[j] = -1; 472 472 // find two components != 0 … … 537 537 par.num = num; 538 538 539 for (i= 0;i<NDIM;i++)539 for (i=NDIM;i--;) 540 540 gsl_vector_set(x, i, (vectors[0]->x[i] - vectors[1]->x[i])/2.); 541 541 … … 573 573 while (status == GSL_CONTINUE && iter < 100); 574 574 575 for (i= 0;i<(size_t)np;i++)575 for (i=(size_t)np;i--;) 576 576 this->x[i] = gsl_vector_get(s->x, i); 577 577 gsl_vector_free(x); … … 587 587 void vector::AddVector(const vector *y) 588 588 { 589 for (int i= 0;i<NDIM;i++)589 for (int i=NDIM;i--;) 590 590 this->x[i] += y->x[i]; 591 591 } … … 596 596 void vector::SubtractVector(const vector *y) 597 597 { 598 for (int i= 0;i<NDIM;i++)598 for (int i=NDIM;i--;) 599 599 this->x[i] -= y->x[i]; 600 600 } … … 605 605 void vector::CopyVector(const vector *y) 606 606 { 607 for (int i= 0;i<NDIM;i++)607 for (int i=NDIM;i--;) 608 608 this->x[i] = y->x[i]; 609 609 } … … 783 783 cout << Verbose(2) << i << ": sign matrix is " << sign[0] << "\t" << sign[1] << "\t" << sign[2] << "\n"; 784 784 // apply sign matrix 785 for (j= 0;j<NDIM;j++)785 for (j=NDIM;j--;) 786 786 x[j] *= sign[j]; 787 787 // calculate angle and check … … 792 792 } 793 793 // unapply sign matrix (is its own inverse) 794 for (j= 0;j<NDIM;j++)794 for (j=NDIM;j--;) 795 795 x[j] *= sign[j]; 796 796 } -
src/verbose.cpp
r6097ea r7f3b9d 7 7 ostream& Verbose::print (ostream &ost) const 8 8 { 9 for (int i= 0;i<Verbosity;i++)9 for (int i=Verbosity;i--;) 10 10 ost.put('\t'); 11 11 //cout << "Verbose(.) called." << endl;
Note:
See TracChangeset
for help on using the changeset viewer.