Changeset f731ae
- Timestamp:
- Oct 18, 2008, 3:05:54 PM (16 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:
- b12a35, eeec8f
- Parents:
- 85d278
- Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/analyzer.cpp
r85d278 rf731ae 93 93 94 94 // ---------- Parse the TE Factors into an array ----------------- 95 if (!Energy. ParseIndices()) return 1;96 if (Hcorrected) Hcorrection. ParseIndices();95 if (!Energy.InitialiseIndices()) return 1; 96 if (Hcorrected) Hcorrection.InitialiseIndices(); 97 97 98 98 // ---------- Parse the Force indices into an array --------------- … … 132 132 output << endl << "Total Energy" << endl << "==============" << endl << Energy.Header << endl; 133 133 for(int j=0;j<Energy.RowCounter[Energy.MatrixCounter];j++) { 134 for(int k=0;k<Energy.ColumnCounter ;k++)134 for(int k=0;k<Energy.ColumnCounter[Energy.MatrixCounter];k++) 135 135 output << scientific << Energy.Matrix[ Energy.MatrixCounter ][j][k] << "\t"; 136 136 output << endl; … … 140 140 output << endl << "Total Forces" << endl << "===============" << endl << Force.Header << endl; 141 141 for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) { 142 for(int k=0;k<Force.ColumnCounter ;k++)142 for(int k=0;k<Force.ColumnCounter[Force.MatrixCounter];k++) 143 143 output << scientific << Force.Matrix[ Force.MatrixCounter ][j][k] << "\t"; 144 144 output << endl; … … 149 149 output << endl << "Total Shieldings" << endl << "===============" << endl << Shielding.Header << endl; 150 150 for(int j=0;j<Shielding.RowCounter[Shielding.MatrixCounter];j++) { 151 for(int k=0;k<Shielding.ColumnCounter ;k++)151 for(int k=0;k<Shielding.ColumnCounter[Shielding.MatrixCounter];k++) 152 152 output << scientific << Shielding.Matrix[ Shielding.MatrixCounter ][j][k] << "\t"; 153 153 output << endl; … … 157 157 output << endl << "Total Shieldings PAS" << endl << "===============" << endl << ShieldingPAS.Header << endl; 158 158 for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) { 159 for(int k=0;k<ShieldingPAS.ColumnCounter ;k++)159 for(int k=0;k<ShieldingPAS.ColumnCounter[ShieldingPAS.MatrixCounter];k++) 160 160 output << scientific << ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t"; 161 161 output << endl; … … 166 166 output << endl << "Total Times" << endl << "===============" << endl << Time.Header << endl; 167 167 for(int j=0;j<Time.RowCounter[Time.MatrixCounter];j++) { 168 for(int k=0;k<Time.ColumnCounter ;k++) {168 for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) { 169 169 output << scientific << Time.Matrix[ Time.MatrixCounter ][j][k] << "\t"; 170 170 } … … 173 173 output << endl; 174 174 output.close(); 175 for(int k=0;k<Time.ColumnCounter ;k++)175 for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) 176 176 Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k] = Time.Matrix[ Time.MatrixCounter ][Time.RowCounter[Time.MatrixCounter]-1][k]; 177 177 … … 187 187 if (!OpenOutputFile(output2, argv[3], "DeltaSimTime-Order.dat" )) return false; 188 188 for(int j=Time.RowCounter[Time.MatrixCounter];j--;) 189 for(int k=Time.ColumnCounter ;k--;) {189 for(int k=Time.ColumnCounter[Time.MatrixCounter];k--;) { 190 190 Time.Matrix[ Time.MatrixCounter ][j][k] = 0.; 191 191 } … … 196 196 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) 197 197 for(int j=Time.RowCounter[Time.MatrixCounter];j--;) 198 for(int k=Time.ColumnCounter ;k--;) {198 for(int k=Time.ColumnCounter[Time.MatrixCounter];k--;) { 199 199 Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 200 200 } … … 202 202 output << BondOrder+1 << "\t" << counter; 203 203 output2 << BondOrder+1 << "\t" << counter; 204 for(int k=0;k<Time.ColumnCounter ;k++) {204 for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) { 205 205 output << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k]; 206 206 if (fabs(Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k]) > MYEPSILON) … … 224 224 for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) { 225 225 output << j << "\t"; 226 for(int k=0;k<ShieldingPAS.ColumnCounter ;k++)226 for(int k=0;k<ShieldingPAS.ColumnCounter[ShieldingPAS.MatrixCounter];k++) 227 227 output << scientific << ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t"; //*(((k>1) && (k<6))? 1.e6 : 1.) << "\t"; 228 228 output << endl; … … 256 256 for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) { 257 257 output << j << "\t"; 258 for(int k=0;k<Force.ColumnCounter ;k++)258 for(int k=0;k<Force.ColumnCounter[Force.MatrixCounter];k++) 259 259 output << scientific << Force.Matrix[ Force.MatrixCounter ][j][k] << "\t"; 260 260 output << endl; -
src/datacreator.cpp
r85d278 rf731ae 67 67 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) { 68 68 for(int j=Fragments.RowCounter[ KeySet.OrderSet[BondOrder][i] ];j--;) 69 for(int k=Fragments.ColumnCounter ;k--;)69 for(int k=Fragments.ColumnCounter[ KeySet.OrderSet[BondOrder][i] ];k--;) 70 70 Fragments.Matrix[Fragments.MatrixCounter][j][k] += Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 71 71 } 72 72 output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder]; 73 for (int l=0;l<Fragments.ColumnCounter ;l++)73 for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++) 74 74 output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l]; 75 75 output << endl; … … 101 101 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) { 102 102 for(int j=Fragments.RowCounter[ KeySet.OrderSet[BondOrder][i] ];j--;) 103 for(int k=Fragments.ColumnCounter ;k--;)103 for(int k=Fragments.ColumnCounter[ KeySet.OrderSet[BondOrder][i] ];k--;) 104 104 Fragments.Matrix[Fragments.MatrixCounter][j][k] -= Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 105 105 } 106 106 output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder]; 107 for (int l=0;l<Fragments.ColumnCounter ;l++)107 for (int l=0;l<Fragments.ColumnCounter[Energy.MatrixCounter];l++) 108 108 if (fabs(Energy.Matrix[Energy.MatrixCounter][ Energy.RowCounter[Energy.MatrixCounter]-1 ][l]) < MYEPSILON) 109 109 output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l]; … … 139 139 output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder]; 140 140 CreateForce(Fragments, Fragments.MatrixCounter); 141 for (int l=0;l<Fragments.ColumnCounter ;l++)141 for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++) 142 142 output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter] ][l]; 143 143 output << endl; … … 171 171 output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder]; 172 172 CreateForce(Fragments, Fragments.MatrixCounter); 173 for (int l=0;l<Fragments.ColumnCounter ;l++)173 for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++) 174 174 output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter] ][l]; 175 175 output << endl; … … 207 207 for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { 208 208 output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t"; 209 for (int l=0;l<Fragments.ColumnCounter ;l++) {209 for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) { 210 210 if (((l+1) % 3) == 0) { 211 211 norm = 0.; … … 252 252 for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { 253 253 output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t"; 254 for (int l=0;l<Fragments.ColumnCounter ;l++)254 for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) 255 255 output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t"; 256 256 output << endl; … … 278 278 output << BondOrder+1 << "\t" << KeySet.OrderSet[BondOrder][i]+1; 279 279 CreateFragment(Fragment, KeySet.OrderSet[BondOrder][i]); 280 for (int l=0;l<Fragment.ColumnCounter ;l++)280 for (int l=0;l<Fragment.ColumnCounter[ KeySet.OrderSet[BondOrder][i] ];l++) 281 281 output << scientific << "\t" << Fragment.Matrix[ KeySet.OrderSet[BondOrder][i] ][ Fragment.RowCounter[ KeySet.OrderSet[BondOrder][i] ] ][l]; 282 282 output << endl; … … 297 297 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) { 298 298 if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < fabs(Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][1])) { 299 for (int k=Fragments.ColumnCounter ;k--;)299 for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;) 300 300 Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 301 301 } … … 314 314 int i=0; 315 315 do { // first get a minimum value unequal to 0 316 for (int k=Fragments.ColumnCounter ;k--;)316 for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;) 317 317 Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 318 318 i++; … … 320 320 for(;i<KeySet.FragmentsPerOrder[BondOrder];i++) { // then find lowest 321 321 if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) > fabs(Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][1])) { 322 for (int k=Fragments.ColumnCounter ;k--;)322 for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;) 323 323 Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 324 324 } … … 344 344 CreateFragmentOrder(Fragment, KeySet, BondOrder); 345 345 output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder]; 346 for (int l=0;l<Fragment.ColumnCounter ;l++)346 for (int l=0;l<Fragment.ColumnCounter[ Fragment.MatrixCounter ];l++) 347 347 output << scientific << "\t" << Fragment.Matrix[ Fragment.MatrixCounter ][ Fragment.RowCounter[ Fragment.MatrixCounter ]-1 ][l]; 348 348 output << endl; … … 358 358 void CreateEnergy(class MatrixContainer &Energy, int MatrixNumber) 359 359 { 360 for(int k=0;k<Energy.ColumnCounter ;k++)360 for(int k=0;k<Energy.ColumnCounter[MatrixNumber];k++) 361 361 Energy.Matrix[MatrixNumber][ Energy.RowCounter[MatrixNumber] ] [k] = Energy.Matrix[MatrixNumber][ Energy.RowCounter[MatrixNumber]-1 ] [k]; 362 362 }; … … 369 369 void CreateMinimumForce(class MatrixContainer &Force, int MatrixNumber) 370 370 { 371 for (int l=Force.ColumnCounter ;l--;)371 for (int l=Force.ColumnCounter[MatrixNumber];l--;) 372 372 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.; 373 for (int l=5;l<Force.ColumnCounter ;l+=3) {373 for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) { 374 374 double stored = 0; 375 375 int k=0; … … 404 404 { 405 405 int divisor = 0; 406 for (int l=Force.ColumnCounter ;l--;)406 for (int l=Force.ColumnCounter[MatrixNumber];l--;) 407 407 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.; 408 for (int l=5;l<Force.ColumnCounter ;l+=3) {408 for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) { 409 409 double tmp = 0; 410 410 for (int k=Force.RowCounter[MatrixNumber];k--;) { … … 428 428 void CreateMaximumForce(class MatrixContainer &Force, int MatrixNumber) 429 429 { 430 for (int l=5;l<Force.ColumnCounter ;l+=3) {430 for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) { 431 431 double stored = 0; 432 432 for (int k=Force.RowCounter[MatrixNumber];k--;) { … … 460 460 void CreateVectorSumForce(class MatrixContainer &Force, int MatrixNumber) 461 461 { 462 for (int l=Force.ColumnCounter ;l--;)462 for (int l=Force.ColumnCounter[MatrixNumber];l--;) 463 463 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.; 464 for (int l=0;l<Force.ColumnCounter ;l++) {464 for (int l=0;l<Force.ColumnCounter[MatrixNumber];l++) { 465 465 for (int k=Force.RowCounter[MatrixNumber];k--;) 466 466 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] += Force.Matrix[MatrixNumber][k][l]; … … 542 542 543 543 getline(line, token, '\t'); 544 for (int i=2; i<= Energy.ColumnCounter ;i++) {544 for (int i=2; i<= Energy.ColumnCounter[Energy.MatrixCounter];i++) { 545 545 getline(line, token, '\t'); 546 546 while (token[0] == ' ') // remove leading white spaces 547 547 token.erase(0,1); 548 548 output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(abs($" << i+2 << ")) " << uses; 549 if (i != (Energy.ColumnCounter ))549 if (i != (Energy.ColumnCounter[Energy.MatrixCounter])) 550 550 output << ", \\"; 551 551 output << endl; … … 566 566 567 567 getline(line, token, '\t'); 568 for (int i=1; i<= Energy.ColumnCounter ;i++) {568 for (int i=1; i<= Energy.ColumnCounter[Energy.MatrixCounter];i++) { 569 569 getline(line, token, '\t'); 570 570 while (token[0] == ' ') // remove leading white spaces 571 571 token.erase(0,1); 572 572 output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":" << i+2 << " " << uses; 573 if (i != (Energy.ColumnCounter ))573 if (i != (Energy.ColumnCounter[Energy.MatrixCounter])) 574 574 output << ", \\"; 575 575 output << endl; … … 594 594 getline(line, token, '\t'); 595 595 getline(line, token, '\t'); 596 for (int i=7; i< Force.ColumnCounter ;i+=NDIM) {596 for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) { 597 597 getline(line, token, '\t'); 598 598 while (token[0] == ' ') // remove leading white spaces … … 600 600 token.erase(token.length(), 1); // kill residual index char (the '0') 601 601 output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(sqrt($" << i+1 << "*$" << i+1 << "+$" << i+2 << "*$" << i+2 << "+$" << i+3 << "*$" << i+3 << ")) " << uses; 602 if (i != (Force.ColumnCounter -1))602 if (i != (Force.ColumnCounter[Force.MatrixCounter]-1)) 603 603 output << ", \\"; 604 604 output << endl; … … 625 625 getline(line, token, '\t'); 626 626 getline(line, token, '\t'); 627 for (int i=7; i< Force.ColumnCounter ;i+=NDIM) {627 for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) { 628 628 getline(line, token, '\t'); 629 629 while (token[0] == ' ') // remove leading white spaces … … 631 631 token.erase(token.length(), 1); // kill residual index char (the '0') 632 632 output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(abs($" << i+1 << ")) " << uses; 633 if (i != (Force.ColumnCounter -1))633 if (i != (Force.ColumnCounter[Force.MatrixCounter]-1)) 634 634 output << ", \\"; 635 635 output << endl; … … 657 657 getline(line, token, '\t'); 658 658 getline(line, token, '\t'); 659 for (int i=7; i< Force.ColumnCounter ;i+=NDIM) {659 for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) { 660 660 getline(line, token, '\t'); 661 661 while (token[0] == ' ') // remove leading white spaces … … 663 663 token.erase(token.length(), 1); // kill residual index char (the '0') 664 664 output << "'" << prefix << ".dat' title '" << token << "' using ($" << xargument << "+" << fixed << setprecision(1) << (double)((i-7)/3)*0.2 << "):(sqrt($" << i+1 << "*$" << i+1 << "+$" << i+2 << "*$" << i+2 << "+$" << i+3 << "*$" << i+3 << ")) " << uses << " " << fillcolor[(i-7)/3]; 665 if (i != (Force.ColumnCounter -1))665 if (i != (Force.ColumnCounter[Force.MatrixCounter]-1)) 666 666 output << ", \\"; 667 667 output << endl; … … 689 689 getline(line, token, '\t'); 690 690 getline(line, token, '\t'); 691 for (int i=7; i< Force.ColumnCounter ;i+=NDIM) {691 for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) { 692 692 getline(line, token, '\t'); 693 693 while (token[0] == ' ') // remove leading white spaces … … 695 695 token.erase(token.length(), 1); // kill residual index char (the '0') 696 696 output << "'" << prefix << ".dat' title '" << token << "' using ($" << xargument << "+" << fixed << setprecision(1) << (double)((i-7)/3)*0.2 << "):" << i+1 << " " << uses << " " << fillcolor[(i-7)/3]; 697 if (i != (Force.ColumnCounter -1))697 if (i != (Force.ColumnCounter[Force.MatrixCounter]-1)) 698 698 output << ", \\"; 699 699 output << endl; -
src/joiner.cpp
r85d278 rf731ae 80 80 81 81 // ---------- Parse the TE Factors into an array ----------------- 82 if (!Energy. ParseIndices()) return 1;83 if (Hcorrected) Hcorrection. ParseIndices();82 if (!Energy.InitialiseIndices()) return 1; 83 if (Hcorrected) Hcorrection.InitialiseIndices(); 84 84 85 85 // ---------- Parse the Force indices into an array --------------- … … 87 87 88 88 // ---------- Parse the Hessian (=force) indices into an array --------------- 89 if (!Hessian. ParseIndices(argv[1])) return 1;89 if (!Hessian.InitialiseIndices((class MatrixContainer *)&Force)) return 1; 90 90 91 91 // ---------- Parse the shielding indices into an array --------------- -
src/parser.cpp
r85d278 rf731ae 59 59 Matrix = (double ***) Malloc(sizeof(double **)*(1), "MatrixContainer::MatrixContainer: ***Matrix"); // one more each for the total molecule 60 60 RowCounter = (int *) Malloc(sizeof(int)*(1), "MatrixContainer::MatrixContainer: *RowCounter"); 61 ColumnCounter = (int *) Malloc(sizeof(int)*(1), "MatrixContainer::MatrixContainer: *ColumnCounter"); 61 62 Matrix[0] = NULL; 62 63 RowCounter[0] = -1; 63 64 MatrixCounter = 0; 64 ColumnCounter = 0;65 ColumnCounter[0] = -1; 65 66 }; 66 67 … … 70 71 if (Matrix != NULL) { 71 72 for(int i=MatrixCounter;i--;) { 72 if ( RowCounter != NULL) {73 if ((ColumnCounter != NULL) && (RowCounter != NULL)) { 73 74 for(int j=RowCounter[i]+1;j--;) 74 75 Free((void **)&Matrix[i][j], "MatrixContainer::~MatrixContainer: *Matrix[][]"); … … 76 77 } 77 78 } 78 if (( RowCounter != NULL) && (Matrix[MatrixCounter] != NULL))79 if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL)) 79 80 for(int j=RowCounter[MatrixCounter]+1;j--;) 80 81 Free((void **)&Matrix[MatrixCounter][j], "MatrixContainer::~MatrixContainer: *Matrix[MatrixCounter][]"); … … 91 92 Free((void **)&Header, "MatrixContainer::~MatrixContainer: *Header"); 92 93 Free((void **)&RowCounter, "MatrixContainer::~MatrixContainer: *RowCounter"); 93 }; 94 94 Free((void **)&ColumnCounter, "MatrixContainer::~MatrixContainer: *RowCounter"); 95 }; 96 97 /** Either copies index matrix from another MatrixContainer or initialises with trivial mapping if NULL. 98 * This either copies the index matrix or just maps 1 to 1, 2 to 2 and so on for all fragments. 99 * \param *Matrix pointer to other MatrixContainer 100 * \return true - copy/initialisation sucessful, false - dimension false for copying 101 */ 102 bool MatrixContainer::InitialiseIndices(class MatrixContainer *Matrix) 103 { 104 cout << "Initialising indices"; 105 if (Matrix == NULL) { 106 cout << " with trivial mapping." << endl; 107 Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "MatrixContainer::InitialiseIndices: **Indices"); 108 for(int i=MatrixCounter+1;i--;) { 109 Indices[i] = (int *) Malloc(sizeof(int)*RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]"); 110 for(int j=RowCounter[i];j--;) 111 Indices[i][j] = j; 112 } 113 } else { 114 cout << " from other MatrixContainer." << endl; 115 if (MatrixCounter != Matrix->MatrixCounter) 116 return false; 117 Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "MatrixContainer::InitialiseIndices: **Indices"); 118 for(int i=MatrixCounter+1;i--;) { 119 if (RowCounter[i] != Matrix->RowCounter[i]) 120 return false; 121 Indices[i] = (int *) Malloc(sizeof(int)*Matrix->RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]"); 122 for(int j=Matrix->RowCounter[i];j--;) 123 Indices[i][j] = Matrix->Indices[i][j]; 124 } 125 } 126 return true; 127 }; 95 128 96 129 /** Parsing a number of matrices. … … 130 163 line >> Header; 131 164 //cout << line.str() << endl; 132 ColumnCounter =0;165 ColumnCounter[MatrixNr]=0; 133 166 while ( getline(line,token, '\t') ) { 134 167 if (token.length() > 0) 135 ColumnCounter ++;168 ColumnCounter[MatrixNr]++; 136 169 } 137 170 //cout << line.str() << endl; 138 //cout << "ColumnCounter: " << ColumnCounter<< "." << endl;139 if (ColumnCounter == 0)140 cerr << "ColumnCounter : " << ColumnCounter<< " from file " << name << ", this is probably an error!" << endl;171 cout << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl; 172 if (ColumnCounter[MatrixNr] == 0) 173 cerr << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl; 141 174 142 175 // scan rest for number of rows/lines … … 150 183 } 151 184 } 152 //cout << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl;185 cout << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl; 153 186 if (RowCounter[MatrixNr] == 0) 154 187 cerr << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl; 155 188 156 189 // allocate matrix if it's not zero dimension in one direction 157 if ((ColumnCounter > 0) && (RowCounter[MatrixNr] > -1)) {190 if ((ColumnCounter[MatrixNr] > 0) && (RowCounter[MatrixNr] > -1)) { 158 191 Matrix[MatrixNr] = (double **) Malloc(sizeof(double *)*(RowCounter[MatrixNr]+1), "MatrixContainer::ParseFragmentMatrix: **Matrix[]"); 159 192 … … 168 201 strncpy(Header, line.str().c_str(), 1023); 169 202 for(int j=0;j<RowCounter[MatrixNr];j++) { 170 Matrix[MatrixNr][j] = (double *) Malloc(sizeof(double)*ColumnCounter , "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");203 Matrix[MatrixNr][j] = (double *) Malloc(sizeof(double)*ColumnCounter[MatrixNr], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]"); 171 204 input.getline(filename, 1023); 172 205 stringstream lines(filename); … … 174 207 for(int k=skipcolumns;k--;) 175 208 lines >> filename; 176 for(int k=0;(k<ColumnCounter ) && (!lines.eof());k++) {209 for(int k=0;(k<ColumnCounter[MatrixNr]) && (!lines.eof());k++) { 177 210 lines >> Matrix[MatrixNr][j][k]; 178 211 //cout << " " << setprecision(2) << Matrix[MatrixNr][j][k];; 179 212 } 180 213 //cout << endl; 181 Matrix[MatrixNr][ RowCounter[MatrixNr] ] = (double *) Malloc(sizeof(double)*ColumnCounter , "MatrixContainer::ParseFragmentMatrix: *Matrix[RowCounter[MatrixNr]][]");182 for(int j=ColumnCounter ;j--;)214 Matrix[MatrixNr][ RowCounter[MatrixNr] ] = (double *) Malloc(sizeof(double)*ColumnCounter[MatrixNr], "MatrixContainer::ParseFragmentMatrix: *Matrix[RowCounter[MatrixNr]][]"); 215 for(int j=ColumnCounter[MatrixNr];j--;) 183 216 Matrix[MatrixNr][ RowCounter[MatrixNr] ][j] = 0.; 184 217 } 185 218 } else { 186 cerr << "ERROR: Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!" << endl;219 cerr << "ERROR: Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter[MatrixNr] << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!" << endl; 187 220 } 188 221 input.close(); … … 235 268 Matrix = (double ***) ReAlloc(Matrix, sizeof(double **)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule 236 269 RowCounter = (int *) ReAlloc(RowCounter, sizeof(int)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: *RowCounter"); 270 ColumnCounter = (int *) ReAlloc(ColumnCounter, sizeof(int)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: *ColumnCounter"); 237 271 for(int i=MatrixCounter+1;i--;) { 238 272 Matrix[i] = NULL; 239 273 RowCounter[i] = -1; 274 ColumnCounter[i] = -1; 240 275 } 241 276 for(int i=0; i < MatrixCounter;i++) { … … 255 290 * \param MCounter number of matrices 256 291 * \param *RCounter number of rows for each matrix 257 * \param CCounter number of columns for allmatrices292 * \param *CCounter number of columns for each matrices 258 293 * \return Allocation successful 259 294 */ 260 bool MatrixContainer::AllocateMatrix(char *GivenHeader, int MCounter, int *RCounter, int CCounter)295 bool MatrixContainer::AllocateMatrix(char *GivenHeader, int MCounter, int *RCounter, int *CCounter) 261 296 { 262 297 Header = (char *) Malloc(sizeof(char)*1024, "MatrixContainer::ParseFragmentMatrix: *EnergyHeader"); … … 264 299 265 300 MatrixCounter = MCounter; 266 ColumnCounter = CCounter;267 301 Matrix = (double ***) Malloc(sizeof(double **)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule 268 302 RowCounter = (int *) Malloc(sizeof(int)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: *RowCounter"); 303 ColumnCounter = (int *) Malloc(sizeof(int)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: *ColumnCounter"); 269 304 for(int i=MatrixCounter+1;i--;) { 270 305 RowCounter[i] = RCounter[i]; 306 ColumnCounter[i] = CCounter[i]; 271 307 Matrix[i] = (double **) Malloc(sizeof(double *)*(RowCounter[i]+1), "MatrixContainer::ParseFragmentMatrix: **Matrix[]"); 272 308 for(int j=RowCounter[i]+1;j--;) { 273 Matrix[i][j] = (double *) Malloc(sizeof(double)*ColumnCounter , "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");274 for(int k=ColumnCounter ;k--;)309 Matrix[i][j] = (double *) Malloc(sizeof(double)*ColumnCounter[i], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]"); 310 for(int k=ColumnCounter[i];k--;) 275 311 Matrix[i][j][k] = 0.; 276 312 } … … 286 322 for(int i=MatrixCounter+1;i--;) 287 323 for(int j=RowCounter[i]+1;j--;) 288 for(int k=ColumnCounter ;k--;)324 for(int k=ColumnCounter[i];k--;) 289 325 Matrix[i][j][k] = 0.; 290 326 return true; … … 299 335 for(int i=MatrixCounter+1;i--;) 300 336 for(int j=RowCounter[i]+1;j--;) 301 for(int k=ColumnCounter ;k--;)337 for(int k=ColumnCounter[i];k--;) 302 338 if (fabs(Matrix[i][j][k]) > max) 303 339 max = fabs(Matrix[i][j][k]); … … 315 351 for(int i=MatrixCounter+1;i--;) 316 352 for(int j=RowCounter[i]+1;j--;) 317 for(int k=ColumnCounter ;k--;)353 for(int k=ColumnCounter[i];k--;) 318 354 if (fabs(Matrix[i][j][k]) < min) 319 355 min = fabs(Matrix[i][j][k]); … … 331 367 { 332 368 for(int j=RowCounter[MatrixCounter]+1;j--;) 333 for(int k=skipcolumns;k<ColumnCounter ;k++)369 for(int k=skipcolumns;k<ColumnCounter[MatrixCounter];k++) 334 370 Matrix[MatrixCounter][j][k] = value; 335 371 return true; … … 344 380 { 345 381 for(int j=RowCounter[MatrixCounter]+1;j--;) 346 for(int k=skipcolumns;k<ColumnCounter ;k++)382 for(int k=skipcolumns;k<ColumnCounter[MatrixCounter];k++) 347 383 Matrix[MatrixCounter][j][k] = values[j][k]; 348 384 return true; … … 351 387 /** Sums the energy with each factor and put into last element of \a ***Energies. 352 388 * Sums over "E"-terms to create the "F"-terms 353 * \param Matrix MatrixContainer with matrices (LevelCounter by ColumnCounter) with all the energies.389 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies. 354 390 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order 355 391 * \param Order bond order … … 384 420 } 385 421 if (Order == SubOrder) { // equal order is always copy from Energies 386 for(int l=ColumnCounter ;l--;) // then adds/subtract each column422 for(int l=ColumnCounter[ KeySet.OrderSet[SubOrder][j] ];l--;) // then adds/subtract each column 387 423 Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][m][l] += MatrixValues.Matrix[ KeySet.OrderSet[SubOrder][j] ][k][l]; 388 424 } else { 389 for(int l=ColumnCounter ;l--;)425 for(int l=ColumnCounter[ KeySet.OrderSet[SubOrder][j] ];l--;) 390 426 Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][m][l] -= Matrix[ KeySet.OrderSet[SubOrder][j] ][k][l]; 391 427 } 392 428 } 393 //if ((ColumnCounter >1) && (RowCounter[0]-1 >= 1))429 //if ((ColumnCounter[ KeySet.OrderSet[SubOrder][j] ]>1) && (RowCounter[0]-1 >= 1)) 394 430 //cout << "Fragments[ KeySet.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySet.OrderSet[Order][CurrentFragment] << " ][" << RowCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][RowCounter[0]-1][1] << endl; 395 431 } … … 428 464 output << Header << endl; 429 465 for(int j=0;j<RowCounter[i];j++) { 430 for(int k=0;k<ColumnCounter ;k++)466 for(int k=0;k<ColumnCounter[i];k++) 431 467 output << scientific << Matrix[i][j][k] << "\t"; 432 468 output << endl; … … 457 493 output << Header << endl; 458 494 for(int j=0;j<RowCounter[MatrixCounter];j++) { 459 for(int k=0;k<ColumnCounter ;k++)495 for(int k=0;k<ColumnCounter[MatrixCounter];k++) 460 496 output << scientific << Matrix[MatrixCounter][j][k] << "\t"; 461 497 output << endl; … … 467 503 // ======================================= CLASS EnergyMatrix ============================= 468 504 469 /** Create a trivial energy index mapping.470 * This just maps 1 to 1, 2 to 2 and so on for all fragments.471 * \return creation sucessful472 */473 bool EnergyMatrix::ParseIndices()474 {475 cout << "Parsing energy indices." << endl;476 Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "EnergyMatrix::ParseIndices: **Indices");477 for(int i=MatrixCounter+1;i--;) {478 Indices[i] = (int *) Malloc(sizeof(int)*RowCounter[i], "EnergyMatrix::ParseIndices: *Indices[]");479 for(int j=RowCounter[i];j--;)480 Indices[i][j] = j;481 }482 return true;483 };484 485 505 /** Sums the energy with each factor and put into last element of \a EnergyMatrix::Matrix. 486 506 * Sums over the "F"-terms in ANOVA decomposition. 487 * \param Matrix MatrixContainer with matrices (LevelCounter by ColumnCounter) with all the energies.507 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies. 488 508 * \param CorrectionFragments MatrixContainer with hydrogen saturation correction per fragments 489 509 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order … … 498 518 for(int i=KeySet.FragmentsPerOrder[Order];i--;) 499 519 for(int j=RowCounter[ KeySet.OrderSet[Order][i] ];j--;) 500 for(int k=ColumnCounter ;k--;)520 for(int k=ColumnCounter[ KeySet.OrderSet[Order][i] ];k--;) 501 521 Matrix[MatrixCounter][j][k] += sign*Fragments.Matrix[ KeySet.OrderSet[Order][i] ][j][k]; 502 522 else 503 523 for(int i=KeySet.FragmentsPerOrder[Order];i--;) 504 524 for(int j=RowCounter[ KeySet.OrderSet[Order][i] ];j--;) 505 for(int k=ColumnCounter ;k--;)525 for(int k=ColumnCounter[ KeySet.OrderSet[Order][i] ];k--;) 506 526 Matrix[MatrixCounter][j][k] += sign*(Fragments.Matrix[ KeySet.OrderSet[Order][i] ][j][k] + CorrectionFragments->Matrix[ KeySet.OrderSet[Order][i] ][j][k]); 507 527 return true; … … 524 544 // count maximum of columns 525 545 RowCounter[MatrixCounter] = 0; 526 for(int j=0; j < MatrixCounter;j++) // (energy matrix might be bigger than number of atoms in terms of rows) 546 ColumnCounter[MatrixCounter] = 0; 547 for(int j=0; j < MatrixCounter;j++) { // (energy matrix might be bigger than number of atoms in terms of rows) 527 548 if (RowCounter[j] > RowCounter[MatrixCounter]) 528 549 RowCounter[MatrixCounter] = RowCounter[j]; 550 if (ColumnCounter[j] > ColumnCounter[MatrixCounter]) // take maximum of all for last matrix 551 ColumnCounter[MatrixCounter] = ColumnCounter[j]; 552 } 529 553 // allocate last plus one matrix 530 cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter << " columns." << endl;554 cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl; 531 555 Matrix[MatrixCounter] = (double **) Malloc(sizeof(double *)*(RowCounter[MatrixCounter]+1), "MatrixContainer::ParseFragmentMatrix: **Matrix[]"); 532 556 for(int j=0;j<=RowCounter[MatrixCounter];j++) 533 Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter , "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");557 Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]"); 534 558 535 559 // try independently to parse global energysuffix file if present … … 589 613 590 614 /** Sums the forces and puts into last element of \a ForceMatrix::Matrix. 591 * \param Matrix MatrixContainer with matrices (LevelCounter by ColumnCounter) with all the energies.615 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies. 592 616 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order 593 617 * \param Order bond order … … 609 633 if (j != -1) { 610 634 //if (j == 0) cout << "Summing onto ion 0, type 0 from fragment " << FragmentNr << ", ion " << l << "." << endl; 611 for(int k=2;k<ColumnCounter ;k++)635 for(int k=2;k<ColumnCounter[MatrixCounter];k++) 612 636 Matrix[MatrixCounter][j][k] += sign*Fragments.Matrix[ FragmentNr ][l][k]; 613 637 } … … 655 679 RowCounter[MatrixCounter]++; // nr start at 0, count starts at 1 656 680 input.close(); 681 682 ColumnCounter[MatrixCounter] = 0; 683 for(int j=0; j < MatrixCounter;j++) { // (energy matrix might be bigger than number of atoms in terms of rows) 684 if (ColumnCounter[j] > ColumnCounter[MatrixCounter]) // take maximum of all for last matrix 685 ColumnCounter[MatrixCounter] = ColumnCounter[j]; 686 } 657 687 658 688 // allocate last plus one matrix 659 cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter << " columns." << endl;689 cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl; 660 690 Matrix[MatrixCounter] = (double **) Malloc(sizeof(double *)*(RowCounter[MatrixCounter]+1), "MatrixContainer::ParseFragmentMatrix: **Matrix[]"); 661 691 for(int j=0;j<=RowCounter[MatrixCounter];j++) 662 Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter , "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");692 Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]"); 663 693 664 694 // try independently to parse global forcesuffix file if present … … 686 716 stringstream line; 687 717 688 cout << "Parsing forceindices for " << MatrixCounter << " matrices." << endl;718 cout << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl; 689 719 Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "HessianMatrix::ParseIndices: **Indices"); 690 720 line << name << FRAGMENTPREFIX << FORCESFILE; … … 720 750 721 751 /** Sums the hessian entries and puts into last element of \a HessianMatrix::Matrix. 722 * \param Matrix MatrixContainer with matrices (LevelCounter by ColumnCounter) with all the energies.752 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies. 723 753 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order 724 754 * \param Order bond order … … 739 769 } 740 770 if (j != -1) { 741 //for(int m=0;m<ColumnCounter[ FragmentNr ];m++) { 742 for(int m=0;m<ColumnCounter;m++) { 771 for(int m=0;m<ColumnCounter[ FragmentNr ];m++) { 743 772 int k = Indices[ FragmentNr ][m]; 744 // if (k > ColumnCounter[MatrixCounter]) { 745 // cerr << "Current hessian index " << k << " is greater than " << ColumnCounter[MatrixCounter] << "!" << endl; 746 if (k > ColumnCounter) { 747 cerr << "Current hessian index " << k << " is greater than " << ColumnCounter << "!" << endl; 773 if (k > ColumnCounter[MatrixCounter]) { 774 cerr << "Current hessian index " << k << " is greater than " << ColumnCounter[MatrixCounter] << "!" << endl; 748 775 return false; 749 776 } … … 784 811 } 785 812 RowCounter[MatrixCounter] = 0; 813 ColumnCounter[MatrixCounter] = 0; 786 814 while (!input.eof()) { 787 815 input.getline(filename, 1023); … … 790 818 zeile >> nr; 791 819 //cout << "Current index: " << nr << "." << endl; 792 if (nr > RowCounter[MatrixCounter]) 820 if (nr > RowCounter[MatrixCounter]) { 793 821 RowCounter[MatrixCounter] = nr; 822 ColumnCounter[MatrixCounter] = nr; 823 } 794 824 } 795 825 } 796 826 RowCounter[MatrixCounter]++; // nr start at 0, count starts at 1 827 ColumnCounter[MatrixCounter]++; // nr start at 0, count starts at 1 797 828 input.close(); 798 829 799 830 // allocate last plus one matrix 800 cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter << " columns." << endl;831 cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl; 801 832 Matrix[MatrixCounter] = (double **) Malloc(sizeof(double *)*(RowCounter[MatrixCounter]+1), "MatrixContainer::ParseFragmentMatrix: **Matrix[]"); 802 833 for(int j=0;j<=RowCounter[MatrixCounter];j++) 803 Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter , "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");834 Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]"); 804 835 805 836 // try independently to parse global forcesuffix file if present -
src/parser.hpp
r85d278 rf731ae 48 48 int MatrixCounter; 49 49 int *RowCounter; 50 int ColumnCounter;50 int *ColumnCounter; 51 51 52 52 MatrixContainer(); 53 53 ~MatrixContainer(); 54 54 55 bool InitialiseIndices(class MatrixContainer *Matrix = NULL); 55 56 bool ParseMatrix(const char *name, int skiplines, int skipcolumns, int MatrixNr); 56 57 virtual bool ParseFragmentMatrix(char *name, char *prefix, string suffix, int skiplines, int skipcolumns); 57 bool AllocateMatrix(char *GivenHeader, int MCounter, int *RCounter, int CCounter);58 bool AllocateMatrix(char *GivenHeader, int MCounter, int *RCounter, int *CCounter); 58 59 bool ResetMatrix(); 59 60 double FindMinValue(); … … 72 73 class EnergyMatrix : public MatrixContainer { 73 74 public: 74 bool ParseIndices();75 75 bool SumSubEnergy(class EnergyMatrix &Fragments, class EnergyMatrix *CorrectionFragments, class KeySetsContainer &KeySet, int Order, double sign); 76 76 bool ParseFragmentMatrix(char *name, char *prefix, string suffix, int skiplines, int skipcolumns);
Note:
See TracChangeset
for help on using the changeset viewer.