Changeset 9fd44f


Ignore:
Timestamp:
Aug 14, 2014, 2:49:51 PM (10 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:
06804b
Parents:
74d179
git-author:
Frederik Heber <heber@…> (07/10/14 17:06:56)
git-committer:
Frederik Heber <heber@…> (08/14/14 14:49:51)
Message:

Vector::Is...() functions extended for numeric threshold.

  • if none given we use LINALG_MYEPSILON(), otherwise given to function.
  • this allows for rounding-sensible IsEqualTo() checking and more.
Location:
LinearAlgebra/src/LinearAlgebra
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • LinearAlgebra/src/LinearAlgebra/Vector.cpp

    r74d179 r9fd44f  
    290290
    291291/** Checks whether vector has all components zero.
     292 * @param epsilon numerical tolerance for equality
    292293 * @return true - vector is zero, false - vector is not
    293294 */
    294 bool Vector::IsZero() const
    295 {
    296   return (fabs(at(0))+fabs(at(1))+fabs(at(2)) < LINALG_MYEPSILON());
     295bool Vector::IsZero(const double _epsilon) const
     296{
     297  return (fabs(at(0))+fabs(at(1))+fabs(at(2)) < _epsilon);
    297298};
    298299
    299300/** Checks whether vector has length of 1.
     301 * @param epsilon numerical tolerance for equality
    300302 * @return true - vector is normalized, false - vector is not
    301303 */
    302 bool Vector::IsOne() const
    303 {
    304   return (fabs(Norm() - 1.) < LINALG_MYEPSILON());
     304bool Vector::IsOne(const double _epsilon) const
     305{
     306  return (fabs(Norm() - 1.) < _epsilon);
    305307};
    306308
    307309/** Checks whether vector is normal to \a *normal.
     310 * @param normal other supposedly normal vector
     311 * @param epsilon numerical tolerance for equality
    308312 * @return true - vector is normalized, false - vector is not
    309313 */
    310 bool Vector::IsNormalTo(const Vector &normal) const
    311 {
    312   if (ScalarProduct(normal) < LINALG_MYEPSILON())
     314bool Vector::IsNormalTo(const Vector &normal, const double _epsilon) const
     315{
     316  if (ScalarProduct(normal) < _epsilon)
    313317    return true;
    314318  else
     
    317321
    318322/** Checks whether vector is normal to \a *normal.
     323 * @param a other vector
     324 * @param epsilon numerical tolerance for equality
    319325 * @return true - vector is normalized, false - vector is not
    320326 */
    321 bool Vector::IsEqualTo(const Vector &a) const
     327bool Vector::IsEqualTo(const Vector &a, const double _epsilon) const
    322328{
    323329  bool status = true;
    324330  for (int i=0;i<NDIM;i++) {
    325     if (fabs(at(i) - a[i]) > LINALG_MYEPSILON())
     331    if (fabs(at(i) - a[i]) > _epsilon)
    326332      status = false;
    327333  }
  • LinearAlgebra/src/LinearAlgebra/Vector.hpp

    r74d179 r9fd44f  
    4646  double ScalarProduct(const Vector &y) const;
    4747  double Angle(const Vector &y) const;
    48   bool IsZero() const;
    49   bool IsOne() const;
    50   bool IsNormalTo(const Vector &normal) const;
    51   bool IsEqualTo(const Vector &a) const;
     48  bool IsZero(const double epsilon = LINALG_MYEPSILON()) const;
     49  bool IsOne(const double epsilon = LINALG_MYEPSILON()) const;
     50  bool IsNormalTo(const Vector &normal, const double epsilon = LINALG_MYEPSILON()) const;
     51  bool IsEqualTo(const Vector &a, const double epsilon = LINALG_MYEPSILON()) const;
    5252
    5353  void AddVector(const Vector &y);
Note: See TracChangeset for help on using the changeset viewer.