Changeset 64bdfd for src


Ignore:
Timestamp:
Feb 27, 2013, 12:43:29 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:
5c3ad5
Parents:
035c0d
git-author:
Frederik Heber <heber@…> (12/19/12 15:31:05)
git-committer:
Frederik Heber <heber@…> (02/27/13 12:43:29)
Message:

Changed Extractor's combineArguments() to neglect same arguments.

  • so far, we just add the two given argument vectors. Now, they are sorted and made unique.
Location:
src/FunctionApproximation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/FunctionApproximation/Extractors.cpp

    r035c0d r64bdfd  
    4040#include <vector>
    4141#include <boost/assign.hpp>
     42#include <boost/bind.hpp>
    4243#include <boost/foreach.hpp>
     44
     45#include "CodePatterns/Assert.hpp"
     46#include "CodePatterns/Log.hpp"
     47
     48#include "LinearAlgebra/Vector.hpp"
     49
     50#include "FunctionApproximation/Extractors.hpp"
     51#include "FunctionApproximation/FunctionArgument.hpp"
     52
     53using namespace boost::assign;
    4354
    4455#include "CodePatterns/Assert.hpp"
     
    596607  FunctionModel::arguments_t args(firstargs);
    597608  args.insert(args.end(), secondargs.begin(), secondargs.end());
     609//  return args;
     610  std::sort(args.begin(), args.end(),
     611      boost::bind(&argument_t::operator<, _1, _2));
     612  FunctionModel::arguments_t::iterator iter =
     613      std::unique(args.begin(), args.end(),
     614          boost::bind(&argument_t::operator==, _1, _2));
     615  args.erase(iter, args.end());
    598616  return args;
    599617}
     618
  • src/FunctionApproximation/FunctionArgument.hpp

    r035c0d r64bdfd  
    9898  }
    9999
     100  /** Comparator with respect to the pair of types.
     101   *
     102   * \note We'll have this as static function to allow usage in e.g. STL's sort.
     103   *
     104   * \param one first argument
     105   * \param other other argument to compare to \a one to
     106   * \return true - first type is less or if equal, second type is less, else
     107   */
     108  bool static TypeComparator(const argument_t &one, const argument_t &other)
     109  {
     110    if (one.types.first < other.types.first)
     111      return true;
     112    else if (one.types.first > other.types.first)
     113      return false;
     114    else
     115      return one.types.second < other.types.second;
     116  }
     117
    100118  /** Comparator with respect to the pair of indices.
    101119   *
     
    114132    else
    115133      return one.indices.second < other.indices.second;
     134  }
     135
     136  /** Less comparator for FunctionArgument.
     137   *
     138   * @param other other argument to compare to
     139   * @return true - this argument is less than \a other, false - else
     140   */
     141  bool operator<(const argument_t &other) const
     142  {
     143    if (types.first < other.types.first)
     144      return true;
     145    else if (types.first > other.types.first)
     146      return false;
     147    else if (types.second < other.types.second)
     148      return true;
     149    else if (types.second > other.types.second)
     150      return false;
     151    else {
     152      if (indices.first < other.indices.first)
     153        return true;
     154      else if (indices.first > other.indices.first)
     155        return false;
     156      else
     157        return indices.second < other.indices.second;
     158    }
     159  }
     160
     161  /** Equality operator for FunctionArgument.
     162   *
     163   * \note This compares only types and indices.
     164   *
     165   * @param other other argument to compare to
     166   * @return true - this argument is equal to \a other, false - else
     167   */
     168  bool operator==(const argument_t &other) const
     169  {
     170    if (types.first != other.types.first)
     171      return false;
     172    else if (types.second != other.types.second)
     173      return false;
     174    if (indices.first != other.indices.first)
     175      return false;
     176    else if (indices.second != other.indices.second)
     177      return false;
     178    else
     179      return true;
    116180  }
    117181
Note: See TracChangeset for help on using the changeset viewer.