Changeset c211f7 for src


Ignore:
Timestamp:
Feb 24, 2013, 12:58:53 PM (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:
63e786
Parents:
bc6705
git-author:
Frederik Heber <heber@…> (10/19/12 07:00:15)
git-committer:
Frederik Heber <heber@…> (02/24/13 12:58:53)
Message:

Refactored convertElementcountsToTargets() out of gatherDistanceOfTuples().

Location:
src/FunctionApproximation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/FunctionApproximation/Extractors.cpp

    rbc6705 rc211f7  
    117117}
    118118
    119 Fragment::positions_t
    120 Extractors::gatherDistanceOfTuples(
    121     const Fragment& fragment,
    122     const Fragment::charges_t elements
    123     ) {
    124   const Fragment::charges_t charges = fragment.getCharges();
    125   /// The main problem here is that we have to know how many same
    126   /// elements (but different atoms!) we are required to find. Hence,
    127   /// we first have to count same elements, then get different targets
    128   /// for each and then associated them in correct order back again.
    129 
    130   // 1. we have to make elements unique with counts, hence convert to map
    131   elementcounts_t elementcounts =
    132       Extractors::_detail::getElementCounts(elements);
    133 
    134   // 2. then for each element we need as many targets (chargeiters) as counts
     119Extractors::elementtargets_t
     120Extractors::_detail::convertElementcountsToTargets(
     121    const Fragment::charges_t &charges,
     122    const elementcounts_t &elementcounts
     123    )
     124{
    135125  elementtargets_t elementtargets;
    136126  for (elementcounts_t::const_iterator countiter = elementcounts.begin();
     
    155145        chargeiter = ++tempiter;
    156146      } else {
    157         ELOG(1, "Could not find desired number of elements " << elements << " in fragment.");
    158         return Fragment::positions_t();
     147        ELOG(1, "Could not find desired number of elements " << count << " in fragment.");
     148        return Extractors::elementtargets_t();
    159149      }
    160150    }
    161151  }
     152  return elementtargets;
     153}
     154
     155Fragment::positions_t
     156Extractors::gatherDistanceOfTuples(
     157    const Fragment& fragment,
     158    const Fragment::charges_t elements
     159    ) {
     160  const Fragment::charges_t charges = fragment.getCharges();
     161  /// The main problem here is that we have to know how many same
     162  /// elements (but different atoms!) we are required to find. Hence,
     163  /// we first have to count same elements, then get different targets
     164  /// for each and then associated them in correct order back again.
     165
     166  // 1. we have to make elements unique with counts, hence convert to map
     167  elementcounts_t elementcounts =
     168      Extractors::_detail::getElementCounts(elements);
     169
     170  // 2. then for each element we need as many targets (chargeiters) as counts
     171  elementtargets_t elementtargets =
     172      Extractors::_detail::convertElementcountsToTargets(charges, elementcounts);
    162173
    163174  // 3. we go again through elements and use one found target for each count
  • src/FunctionApproximation/Extractors.hpp

    rbc6705 rc211f7  
    7171        );
    7272
     73    /** Gather iterators to the elements related to the desired elementcounts.
     74     *
     75     * \param charges charges wherein to search for the elements
     76     * \param elementcounts number of desired hits per element
     77     * \return iterators equal to the initial vector of elements
     78     */
     79    elementtargets_t convertElementcountsToTargets(
     80        const Fragment::charges_t &charges,
     81        const elementcounts_t &elementcounts
     82        );
    7383  }
    7484
Note: See TracChangeset for help on using the changeset viewer.