Changeset a1d035 for src


Ignore:
Timestamp:
Apr 8, 2013, 11:56:18 AM (12 years ago)
Author:
Frederik Heber <heber@…>
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:
356ae4
Parents:
569e42
git-author:
Frederik Heber <heber@…> (03/04/13 17:11:03)
git-committer:
Frederik Heber <heber@…> (04/08/13 11:56:18)
Message:

Converted TouchedList from int* to std::vector<int> in PowerSetGenerator.

  • this is preparatory for removing use of local numbers from fragment KeySets.
Location:
src/Fragmentation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/PowerSetGenerator.cpp

    r569e42 ra1d035  
    6565/** Clears the touched list
    6666 * \param verbosity verbosity level
    67  * \param *&TouchedList touched list
     67 * \param &TouchedList touched list
    6868 * \param SubOrder current suborder
    6969 * \param TouchedIndex currently touched
    7070 */
    71 void PowerSetGenerator::ClearingTouched(int verbosity, int *&TouchedList, int SubOrder, int &TouchedIndex)
     71void PowerSetGenerator::ClearingTouched(int verbosity, TouchedList_t &TouchedList, int SubOrder, int &TouchedIndex)
    7272{
    7373  LOG(1+verbosity, "Clearing touched list.");
     74  TouchedList.resize(SubOrder+1, -1);
    7475  for (TouchedIndex=SubOrder+1;TouchedIndex--;)  // empty touched list
    7576    TouchedList[TouchedIndex] = -1;
    7677  TouchedIndex = 0;
    77 
    7878}
    7979
     
    8484 * \param *FragmentSet snake stack to remove from
    8585 * \param &BondsSet set of bonds
    86  * \param *&TouchedList touched list
     86 * \param &TouchedList touched list
    8787 * \param TouchedIndex currently touched
    8888 * \return number of set bits
    8989 */
    90 int PowerSetGenerator::AddPowersetToSnakeStack(int verbosity, int CurrentCombination, int SetDimension, KeySet *FragmentSet, std::vector<bond::ptr > &BondsSet, int *&TouchedList, int &TouchedIndex)
     90int PowerSetGenerator::AddPowersetToSnakeStack(int verbosity, int CurrentCombination, int SetDimension, KeySet *FragmentSet, std::vector<bond::ptr > &BondsSet, TouchedList_t &TouchedList, int &TouchedIndex)
    9191{
    9292  atom *OtherWalker = NULL;
     
    118118 * \param SetFirst begin iterator first bond
    119119 * \param SetLast end iterator
    120  * \param *&TouchedList touched list
     120 * \param &TouchedList touched list
    121121 * \param TouchedIndex currently touched
    122122 * \return number of elements
    123123 */
    124 int PowerSetGenerator::CountSetMembers(std::list<bond::ptr >::const_iterator SetFirst, std::list<bond::ptr >::const_iterator SetLast, int *&TouchedList, int TouchedIndex)
     124int PowerSetGenerator::CountSetMembers(std::list<bond::ptr >::const_iterator SetFirst, std::list<bond::ptr >::const_iterator SetLast, const TouchedList_t &TouchedList, int TouchedIndex)
    125125{
    126126  int SetDimension = 0;
     
    128128      Binder != SetLast;
    129129      ++Binder) {
    130     for (int k=TouchedIndex;k--;) {
    131       if ((*Binder)->Contains(TouchedList[k]))   // if we added this very endpiece
     130    for (TouchedList_t::const_iterator iter = TouchedList.begin();
     131        iter != TouchedList.end(); ++iter) {
     132      if ((*Binder)->Contains(*iter))   // if we added this very endpiece
    132133        SetDimension++;
    133134    }
     
    140141 * \param SetFirst begin iterator first bond
    141142 * \param SetLast end iterator
    142  * \param *&TouchedList touched list
     143 * \param &TouchedList touched list
    143144 * \param TouchedIndex currently touched
    144145 * \return number of elements
    145146 */
    146 int PowerSetGenerator::FillBondsList(std::vector<bond::ptr > &BondsList, std::list<bond::ptr >::const_iterator SetFirst, std::list<bond::ptr >::const_iterator SetLast, int *&TouchedList, int TouchedIndex)
     147int PowerSetGenerator::FillBondsList(std::vector<bond::ptr > &BondsList, std::list<bond::ptr >::const_iterator SetFirst, std::list<bond::ptr >::const_iterator SetLast, const TouchedList_t &TouchedList, int TouchedIndex)
    147148{
    148149  int SetDimension = 0;
     
    150151      Binder != SetLast;
    151152      ++Binder) {
    152     for (int k=0;k<TouchedIndex;k++) {
    153       if ((*Binder)->leftatom->getNr() == TouchedList[k])   // leftatom is always the closer one
     153    for (TouchedList_t::const_iterator iter = TouchedList.begin();
     154        iter != TouchedList.end(); ++iter) {
     155      if ((*Binder)->leftatom->getNr() == *iter)   // leftatom is always the closer one
    154156        BondsList[SetDimension++] = (*Binder);
    155157    }
     
    161163 * \param verbosity verbosity level
    162164 * \param *FragmentSet snake stack to remove from
    163  * \param *&TouchedList touched list
    164  * \param TouchedIndex currently touched
    165  */
    166 void PowerSetGenerator::RemoveAllTouchedFromSnakeStack(int verbosity, KeySet *FragmentSet, int *&TouchedList, int &TouchedIndex)
    167 {
    168   int Removal = 0;
    169   for(int j=0;j<TouchedIndex;j++) {
    170     Removal = TouchedList[j];
     165 * \param &TouchedList touched list
     166 * \param TouchedIndex currently touched
     167 */
     168void PowerSetGenerator::RemoveAllTouchedFromSnakeStack(int verbosity, KeySet *FragmentSet, TouchedList_t &TouchedList, int &TouchedIndex)
     169{
     170  for (TouchedList_t::iterator iter = TouchedList.begin();
     171      iter != TouchedList.end();++iter) {
     172    const int Removal = *iter;
    171173    LOG(2+verbosity, "Removing item nr. " << Removal << " from snake stack.");
    172174    FragmentSet->erase(Removal);
    173     TouchedList[j] = -1;
     175    (*iter) = -1;
    174176  }
    175177  std::stringstream output;
     
    261263  int TouchedIndex, SubSetDimension, Added;
    262264  int SpaceLeft;
    263   int *TouchedList = new int[SubOrder + 1];
     265  TouchedList_t TouchedList(SubOrder + 1, -1);
    264266  KeySetTestPair TestKeySetInsert;
    265267
     
    330332    }
    331333  }
    332   delete[](TouchedList);
    333334  LOG(1+verbosity, "End of SPFragmentGenerator, " << RootDistance << " away from Root " << *FragmentSearch->getRoot() << " and SubOrder is " << SubOrder << ".");
    334335};
  • src/Fragmentation/PowerSetGenerator.hpp

    r569e42 ra1d035  
    2929  ~PowerSetGenerator();
    3030
     31  typedef std::vector<int> TouchedList_t;
     32
    3133  void SPFragmentGenerator(int RootDistance, std::vector<bond::ptr > &BondsSet, int SetDimension, int SubOrder);
    3234  int operator()(KeySet &RestrictedKeySet, const enum HydrogenTreatment treatment);
    33   void RemoveAllTouchedFromSnakeStack(int verbosity, KeySet *FragmentSet, int *&TouchedList, int &TouchedIndex);
    34   int FillBondsList(std::vector<bond::ptr > &BondsList, std::list<bond::ptr >::const_iterator SetFirst, std::list<bond::ptr >::const_iterator SetLast, int *&TouchedList, int TouchedIndex);
    35   int CountSetMembers(std::list<bond::ptr >::const_iterator SetFirst, std::list<bond::ptr >::const_iterator SetLast, int *&TouchedList, int TouchedIndex);
    36   int AddPowersetToSnakeStack(int verbosity, int CurrentCombination, int SetDimension, KeySet *FragmentSet, std::vector<bond::ptr > &BondsSet, int *&TouchedList, int &TouchedIndex);
    37   void ClearingTouched(int verbosity, int *&TouchedList, int SubOrder, int &TouchedIndex);
     35  void RemoveAllTouchedFromSnakeStack(int verbosity, KeySet *FragmentSet, TouchedList_t &TouchedList, int &TouchedIndex);
     36  int FillBondsList(std::vector<bond::ptr > &BondsList, std::list<bond::ptr >::const_iterator SetFirst, std::list<bond::ptr >::const_iterator SetLast, const TouchedList_t &TouchedList, int TouchedIndex);
     37  int CountSetMembers(std::list<bond::ptr >::const_iterator SetFirst, std::list<bond::ptr >::const_iterator SetLast, const TouchedList_t &TouchedList, int TouchedIndex);
     38  int AddPowersetToSnakeStack(int verbosity, int CurrentCombination, int SetDimension, KeySet *FragmentSet, std::vector<bond::ptr > &BondsSet, TouchedList_t &TouchedList, int &TouchedIndex);
     39  void ClearingTouched(int verbosity, TouchedList_t &TouchedList, int SubOrder, int &TouchedIndex);
    3840
    3941private:
Note: See TracChangeset for help on using the changeset viewer.