Changeset 54a746 for src/vector.cpp


Ignore:
Timestamp:
Aug 18, 2009, 8:48:06 AM (16 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:
658efb
Parents:
093645
git-author:
Frederik Heber <heber@…> (08/18/09 08:38:46)
git-committer:
Frederik Heber <heber@…> (08/18/09 08:48:06)
Message:

Incorporation of Unit test on class Vector.

  • new file leastsquaremin.[ch]pp has least square minimisation which is otherwise unclean between classes molecules and Vector

Unit test (later tests rely on good results of earlier ones)

changes to class Vector:

  • Vector::IsNull() -> IsZero()
  • new function Vector::IsOne() similar to IsZero()
  • BUGFIX: Vector::IsNULL() (thx to unit test :)
  • Tesselation::getAngle() changed due to above rename
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/vector.cpp

    r093645 r54a746  
    66
    77
    8 #include "molecules.hpp"
    9 
     8#include "defs.hpp"
     9#include "helpers.hpp"
     10#include "leastsquaremin.hpp"
     11#include "vector.hpp"
     12#include "verbose.hpp"
    1013
    1114/************************************ Functions for class vector ************************************/
     
    247250
    248251/** Calculates the intersection of the two lines that are both on the same plane.
    249  * Note that we do not check whether they are on the same plane.
     252 * Note that we do not check whether they are on the same plane. Vector is calculated with respecy to second line.
    250253 * \param *out output stream for debugging
    251254 * \param *Line1a first vector of first line
     
    276279  *out << Verbose(3) << "INFO: Normal of plane is " << *Normal << "." << endl;
    277280
    278   // create normal vector to one line
    279   Line.CopyVector(Line1b);
    280   Line.SubtractVector(Line1a);
    281   LineNormal.MakeNormalVector(&Line, Normal);
    282   *out << Verbose(3) << "INFO: Normal of first line is " << LineNormal << "." << endl;
    283 
    284281  // check if lines are parallel
    285282  helper.CopyVector(Line2b);
    286283  helper.SubtractVector(Line2a);
    287   if (fabs(helper.ScalarProduct(&LineNormal)) < MYEPSILON) {
     284  if (fabs(helper.ScalarProduct(Normal)) < MYEPSILON) {
    288285    *out << Verbose(1) << "Lines " << helper << " and " << Line << " are parallel, no cross point!" << endl;
    289286    result = false;
     
    291288    helper.CopyVector(Line2a);
    292289    helper.SubtractVector(Line1a);
    293     factor1 = helper.ScalarProduct(&LineNormal);
     290    factor1 = helper.ScalarProduct(Normal);
    294291    helper.CopyVector(Line2b);
    295292    helper.SubtractVector(Line1a);
    296     factor2 = helper.ScalarProduct(&LineNormal);
     293    factor2 = helper.ScalarProduct(Normal);
    297294    if (fabs(factor2) > MYEPSILON) {
    298295      CopyVector(Line2a);
     
    380377 * @return true - vector is zero, false - vector is not
    381378 */
    382 bool Vector::IsNull() const
    383 {
    384   return (fabs(x[0]+x[1]+x[2]) < MYEPSILON);
     379bool Vector::IsZero() const
     380{
     381  return (fabs(x[0])+fabs(x[1])+fabs(x[2]) < MYEPSILON);
     382};
     383
     384/** Checks whether vector has length of 1.
     385 * @return true - vector is normalized, false - vector is not
     386 */
     387bool Vector::IsOne() const
     388{
     389  return (fabs(Norm() - 1.) < MYEPSILON);
    385390};
    386391
     
    437442  return a;
    438443};
     444
     445/** Subtracts vector \a from this lhs component-wise.
     446 * \param a base vector
     447 * \param b vector components to add
     448 * \return lhs - a
     449 */
     450Vector& operator-=(Vector& a, const Vector& b)
     451{
     452  a.SubtractVector(&b);
     453  return a;
     454};
     455
    439456/** factor each component of \a a times a double \a m.
    440457 * \param a base vector
     
    461478};
    462479
     480/** Subtracts vector \a from \b component-wise.
     481 * \param a first vector
     482 * \param b second vector
     483 * \return a - b
     484 */
     485Vector& operator-(const Vector& a, const Vector& b)
     486{
     487  Vector *x = new Vector;
     488  x->CopyVector(&a);
     489  x->SubtractVector(&b);
     490  return *x;
     491};
     492
    463493/** Factors given vector \a a times \a m.
    464494 * \param a vector
    465495 * \param m factor
    466  * \return a + b
     496 * \return m * a
    467497 */
    468498Vector& operator*(const Vector& a, const double m)
     499{
     500  Vector *x = new Vector;
     501  x->CopyVector(&a);
     502  x->Scale(m);
     503  return *x;
     504};
     505
     506/** Factors given vector \a a times \a m.
     507 * \param m factor
     508 * \param a vector
     509 * \return m * a
     510 */
     511Vector& operator*(const double m, const Vector& a )
    469512{
    470513  Vector *x = new Vector;
Note: See TracChangeset for help on using the changeset viewer.