Changeset 45f4f96
- Timestamp:
- Nov 8, 2012, 1:13:52 PM (12 years ago)
- 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:
- 22c4f57
- Parents:
- bb68c0
- git-author:
- Frederik Heber <heber@…> (07/27/12 12:35:40)
- git-committer:
- Frederik Heber <heber@…> (11/08/12 13:13:52)
- Location:
- src/Fragmentation/Histogram
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Histogram/Histogram.cpp
rbb68c0 r45f4f96 119 119 bins.insert(vectorbins.begin(), vectorbins.end()); 120 120 121 // 4. place each sample into bin 121 // 4. place each sample into bin (make count normalized, i.e. always equal to 122 // surface area of 1) 122 123 BOOST_FOREACH( double value, samples) { 123 124 const Bins_t::iterator biniter = getLowerEndBin(value); 124 125 ASSERT( biniter != bins.end(), 125 126 "Histogram::Histogram() - cannot find bin for value from given samples."); 126 biniter->second += 1. ;127 biniter->second += 1./binwidth; 127 128 } 128 129 LOG(2, "DEBUG: Bins are " << printBins() << "."); … … 189 190 return iter; 190 191 } 192 193 double Histogram::area() const 194 { 195 double area = 0.; 196 for(Bins_t::const_iterator iter = bins.begin(); iter != bins.end(); ++iter) 197 area += iter->second*binwidth; 198 return area; 199 } -
src/Fragmentation/Histogram/Histogram.hpp
rbb68c0 r45f4f96 56 56 /** Adding another histogram onto this one. 57 57 * 58 * \note The operation is area-conserving, i.e. the new area is the sum of 59 * both areas. 60 * 58 61 * @param other other histogram 59 62 * @return ref to this instance … … 62 65 63 66 /** Subtracting another histogram from this one. 67 * 68 * \note The operation is area-conserving, i.e. the new area is the 69 * difference of both areas. 64 70 * 65 71 * @param other other histogram … … 73 79 */ 74 80 bool isEmpty() const; 81 82 /** Sums all found weights times the Histogram::binwidth. 83 * 84 * @return sum over all weights times width. 85 */ 86 double area() const; 75 87 76 88 private: -
src/Fragmentation/Histogram/unittests/HistogramUnitTest.cpp
rbb68c0 r45f4f96 173 173 } 174 174 175 /** UnitTest for area() 176 */ 177 void HistogramTest::areaTest() 178 { 179 histogram = new Histogram(std::vector<double>()); 180 // test on empty histogramgram 181 CPPUNIT_ASSERT_EQUAL( 0., histogram->area() ); 182 183 // create non-empty histogram and sum up 184 Histogram::samples_t sampled_values; 185 sampled_values += 1.,2.,3.,4., 4.; 186 delete histogram; 187 histogram = new Histogram(sampled_values, 4); 188 CPPUNIT_ASSERT_EQUAL( 5., histogram->area() ); 189 Histogram::samples_t more_values; 190 more_values += 1.75,2.5,3.; 191 Histogram otherhistogram(more_values, 3); 192 CPPUNIT_ASSERT_EQUAL( 3., otherhistogram.area() ); 193 194 } 195 175 196 /** UnitTest for operator+=(), operator-=() 176 197 */ -
src/Fragmentation/Histogram/unittests/HistogramUnitTest.hpp
rbb68c0 r45f4f96 29 29 CPPUNIT_TEST ( isEmpty_Test ); 30 30 CPPUNIT_TEST ( operator_Test ); 31 CPPUNIT_TEST ( areaTest ); 31 32 CPPUNIT_TEST_SUITE_END(); 32 33 … … 39 40 void isEmpty_Test(); 40 41 void operator_Test(); 42 void areaTest(); 41 43 42 44 private:
Note:
See TracChangeset
for help on using the changeset viewer.