Changeset 1dd419


Ignore:
Timestamp:
Nov 8, 2012, 1:13:52 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:
e4048f
Parents:
22c4f57
git-author:
Frederik Heber <heber@…> (07/27/12 13:35:38)
git-committer:
Frederik Heber <heber@…> (11/08/12 13:13:52)
Message:

Added Histogram::getLowerEnd().

  • this function helps where to add new bins in superpositions.
Location:
src/Fragmentation/Histogram
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Histogram/Histogram.cpp

    r22c4f57 r1dd419  
    257257}
    258258
     259Histogram::BinLowerEnd Histogram::getLowerEnd(const double _value) const
     260{
     261  // we need just one bin, to have an offset
     262  const double offset = bins.begin()->first;
     263  BinLowerEnd start = _value - offset;
     264  // then divide by binwidth
     265  const int integral = floor(start/binwidth);
     266  //const double fraction = start - (double)integral;
     267  start = offset + binwidth*integral;
     268  return start;
     269}
     270
    259271double Histogram::area() const
    260272{
  • src/Fragmentation/Histogram/Histogram.hpp

    r22c4f57 r1dd419  
    100100   */
    101101  Bins_t::iterator getHigherEndBin(const double _value);
    102  
     102
     103  /** Returns the lower end regardless of whether such a bin exists.
     104   *
     105   * @param _value value to place into a bin
     106   * @return start of would-be bin to contain this \a _value
     107   */
     108  BinLowerEnd getLowerEnd(const double _value) const;
     109
    103110  /** Helper function that contains all the logic of how to superpose two
    104111   * histograms.
  • src/Fragmentation/Histogram/unittests/HistogramUnitTest.cpp

    r22c4f57 r1dd419  
    164164}
    165165
     166
     167/** UnitTest for getLowerEnd()
     168 */
     169void HistogramTest::getLowerEnd_Test()
     170{
     171  // create non-empty histogram and test
     172  Histogram::samples_t sampled_values;
     173  sampled_values += 1.,2.,3.,4.;
     174  histogram = new Histogram(sampled_values, 4);
     175
     176  // go through each bin and check against getLowerEnd()
     177  for (Histogram::Bins_t::const_iterator iter = histogram->bins.begin();
     178      iter != histogram->bins.end(); ++iter)
     179    CPPUNIT_ASSERT_EQUAL( iter->first, histogram->getLowerEnd(iter->first) );
     180
     181  CPPUNIT_ASSERT_EQUAL( 7., histogram->getLowerEnd(7.2) );
     182  CPPUNIT_ASSERT_EQUAL( -5., histogram->getLowerEnd(-4.5) );
     183  CPPUNIT_ASSERT_EQUAL( 4000., histogram->getLowerEnd(4000.1) );
     184  CPPUNIT_ASSERT_EQUAL( -4001., histogram->getLowerEnd(-4000.9) );
     185}
     186
    166187/** UnitTest for isEmpty()
    167188 */
  • src/Fragmentation/Histogram/unittests/HistogramUnitTest.hpp

    r22c4f57 r1dd419  
    2727    CPPUNIT_TEST ( getLowerEndBin_Test );
    2828    CPPUNIT_TEST ( getHigherEndBin_Test );
     29    CPPUNIT_TEST ( getLowerEnd_Test );
    2930    CPPUNIT_TEST ( isEmpty_Test );
    3031    CPPUNIT_TEST ( areaTest );
     
    4041      void getLowerEndBin_Test();
    4142      void getHigherEndBin_Test();
     43      void getLowerEnd_Test();
    4244      void isEmpty_Test();
    4345      void areaTest();
Note: See TracChangeset for help on using the changeset viewer.