Ignore:
Timestamp:
Oct 17, 2013, 7:14:21 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, Candidate_v1.7.0, 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:
58952a
Parents:
e0ae58d
git-author:
Frederik Heber <heber@…> (09/27/13 11:25:35)
git-committer:
Frederik Heber <heber@…> (10/17/13 07:14:21)
Message:

Added (in)equality operators to all SetValues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Summation/SetValues/SamplingGrid.cpp

    re0ae58d r955051  
    266266    const double value, const size_t axis) const
    267267{
    268   const double length = end[axis] - begin[axis];
     268  const double length = getTotalLengthPerAxis(axis);
    269269  if ((fabs(length) < std::numeric_limits<double>::epsilon()) || (getGridPointsPerAxis() == 0))
    270270    return begin[axis];
    271   if (value > end[axis])
     271  if ((value - end[axis]) > -std::numeric_limits<double>::epsilon()*1.e4)
    272272    return end[axis];
    273273  const double offset = value - begin[axis];
    274   if (offset < 0)
     274  if (offset < std::numeric_limits<double>::epsilon()*1.e4)
    275275    return begin[axis];
    276276  // modify value a little if value actually has been on a grid point but
     
    279279      floor((double)getGridPointsPerAxis()*(offset/length)
    280280          +std::numeric_limits<double>::epsilon()*1.e4);
    281   return factor*(length/(double)getGridPointsPerAxis());
     281  return begin[axis]+factor*getDeltaPerAxis(axis);
    282282}
    283283
     
    285285    const double value, const size_t axis) const
    286286{
    287   const double length = end[axis] - begin[axis];
     287  const double length = getTotalLengthPerAxis(axis);
    288288  if ((fabs(length) < std::numeric_limits<double>::epsilon()) || (getGridPointsPerAxis() == 0))
    289289    return end[axis];
    290   if (value > end[axis])
     290  if ((value - end[axis]) > -std::numeric_limits<double>::epsilon()*1.e4)
    291291    return end[axis];
    292292  const double offset = value - begin[axis];
    293   if (offset < 0)
     293  if (offset < std::numeric_limits<double>::epsilon()*1.e4)
    294294    return begin[axis];
    295295  // modify value a little if value actually has been on a grid point but
     
    298298      ceil((double)getGridPointsPerAxis()*(offset/length)
    299299          -std::numeric_limits<double>::epsilon()*1.e4);
    300   return factor*(length/(double)getGridPointsPerAxis());
     300  return begin[axis]+factor*getDeltaPerAxis(axis);
    301301}
    302302
     
    605605}
    606606
     607
     608bool SamplingGrid::operator==(const SamplingGrid &other) const
     609{
     610  bool status =
     611      static_cast<const SamplingGridProperties &>(*this)
     612      == static_cast<const SamplingGridProperties &>(other);
     613  // compare general properties
     614  if (status) {
     615    // compare windows
     616    for (size_t i=0; i<3; ++i) {
     617      status &= begin_window[i] == other.begin_window[i];
     618      status &= end_window[i] == other.end_window[i];
     619    }
     620    // compare grids
     621    if (status)
     622      status &= sampled_grid == other.sampled_grid;
     623  }
     624  return status;
     625}
     626
    607627std::ostream & operator<<(std::ostream &ost, const SamplingGrid& other)
    608628{
Note: See TracChangeset for help on using the changeset viewer.