Ignore:
Timestamp:
Sep 14, 2016, 6:42:53 PM (8 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, 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_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes, stable
Children:
6a5eb2
Parents:
91e7658
git-author:
Frederik Heber <heber@…> (05/26/16 15:36:26)
git-committer:
Frederik Heber <heber@…> (09/14/16 18:42:53)
Message:

Added padWithZerosForEvenNumberedSamples(), required by downsample().

  • added unit test function.
File:
1 edited

Legend:

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

    r91e7658 rd56e21  
    780780}
    781781
     782void SamplingGrid::padWithZerosForEvenNumberedSamples()
     783{
     784  size_t wbegin_index[NDIM];
     785  size_t wend_index[NDIM];
     786  size_t wlength_index[NDIM];
     787  getDiscreteWindowIndices(wbegin_index, wlength_index, wend_index);
     788
     789  // calculate new window (always extend it such that both indices are even)
     790  bool changed = false;
     791  size_t wnewbegin_index[NDIM];
     792  size_t wnewend_index[NDIM];
     793  for(size_t i=0;i<NDIM;++i) {
     794    // We require begin and end of window on even indices (and inside grid).
     795    wnewbegin_index[i] = wbegin_index[i];
     796    if ((wnewbegin_index[i] % (size_t)2) != 0) {
     797      if (wnewbegin_index[i] > 0)
     798        --wnewbegin_index[i];
     799      else
     800        wnewbegin_index[i] = 0;
     801      changed = true;
     802    }
     803    wnewend_index[i] = wend_index[i];
     804    if ((wnewend_index[i] % (size_t)2) != 0) {
     805      if (wnewend_index[i] < getGridPointsPerAxis())
     806        ++wnewend_index[i];
     807      else
     808        wnewend_index[i] = getGridPointsPerAxis();
     809      changed = true;
     810    }
     811    ASSERT( (wbegin_index[i] >= 0) && (wend_index[i] <= getGridPointsPerAxis()),
     812        "SamplingGrid::padWithZerosForEvenNumberedSamples() - indices "
     813        +toString(wbegin_index[i])+" and "+toString(wend_index[i])+" larger than grid "
     814        +toString(getGridPointsPerAxis())+".");
     815  }
     816  if (changed) {
     817    double begin_newwindow[NDIM];
     818    double end_newwindow[NDIM];
     819    for(size_t i=0;i<NDIM;++i) {
     820      const double delta = getDeltaPerAxis(i);
     821      begin_newwindow[i] = begin[i]+delta*wnewbegin_index[i];
     822      end_newwindow[i] = begin[i]+delta*wnewend_index[i];
     823    }
     824    // extend window
     825    extendWindow(begin_newwindow, end_newwindow);
     826  }
     827  ASSERT( getWindowGridPoints() % (size_t)8 == 0,
     828      "SamplingGrid::padWithZerosForEvenNumberedSamples() - new size "
     829      +toString(getWindowGridPoints())+" is still not divisible by 8.");
     830}
     831
    782832void SamplingGrid::downsample(
    783833    SamplingGrid& instance,
Note: See TracChangeset for help on using the changeset viewer.