Ignore:
Timestamp:
Dec 5, 2010, 12:19:19 AM (15 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:
f03705
Parents:
589112 (diff), bbf1bd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'MatrixVectorContentRefactoring' into stable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/LinearAlgebra/VectorContent.hpp

    r589112 r6e06bd  
    1818 */
    1919
     20#include <iosfwd>
     21
    2022#include <gsl/gsl_vector.h>
    2123
     24class Vector;
     25
     26/** Dummy structure to create a unique signature.
     27 *
     28 */
    2229struct BaseCase{};
    2330
    24 struct VectorContent{
    25   VectorContent(){
    26     content =  gsl_vector_calloc (NDIM);
    27   }
    28   VectorContent(BaseCase){
     31class VectorContent{
     32  friend std::ostream & operator<< (std::ostream& ost, const VectorContent &m);
     33  friend VectorContent const operator*(const VectorContent& a, const double m);
     34  friend VectorContent const operator*(const double m, const VectorContent& a);
     35  friend VectorContent const operator+(const VectorContent& a, const VectorContent& b);
     36  friend VectorContent const operator-(const VectorContent& a, const VectorContent& b);
    2937
    30   }
    31   virtual ~VectorContent(){
    32     if(content){
    33       gsl_vector_free(content);
    34       content = 0;
    35     }
    36   }
     38public:
     39  explicit VectorContent(size_t _dim);
     40  VectorContent(BaseCase);
     41  VectorContent(const VectorContent * const src);
     42  VectorContent(const VectorContent & src);
     43  virtual ~VectorContent();
     44
     45  // Accessing
     46  double &at(size_t m);
     47  const double at(size_t m) const;
     48  double & operator[](size_t i);
     49  const double operator[](size_t i) const;
     50  double *Pointer(size_t m) const;
     51  const double *const_Pointer(size_t m) const;
     52
     53  // Assignment operator
     54  VectorContent &operator=(const VectorContent& src);
     55
     56  // Initializing
     57  void setFromDoubleArray(double * x);
     58  void setFromVector(Vector &v);
     59  void setValue(double x);
     60  void setZero();
     61  int setBasis(size_t m);
     62
     63  // Exchanging elements
     64  int SwapElements(size_t i, size_t j);
     65  int Reverse();
     66
     67  // checking state
     68  bool IsZero() const;
     69  bool IsOne() const;
     70
     71  // properties
     72  bool IsNormalTo(const Vector &normal) const;
     73  bool IsEqualTo(const Vector &a) const;
     74
     75  // properties relative to another VectorContent
     76  double DistanceSquared(const VectorContent &y) const;
     77  double ScalarProduct(const VectorContent &y) const;
     78  double Angle(const VectorContent &y) const;
     79
     80  // operators
     81  bool operator==(const VectorContent& b) const;
     82  const VectorContent& operator+=(const VectorContent& b);
     83  const VectorContent& operator-=(const VectorContent& b);
     84  const VectorContent& operator*=(const double m);
     85
     86  size_t dimension;
    3787  gsl_vector *content;
     88private:
    3889};
    3990
    40 struct VectorViewContent : public VectorContent{
     91std::ostream & operator << (std::ostream& ost, const VectorContent &m);
     92VectorContent const operator*(const VectorContent& a, const double m);
     93VectorContent const operator*(const double m, const VectorContent& a);
     94VectorContent const operator+(const VectorContent& a, const VectorContent& b);
     95VectorContent const operator-(const VectorContent& a, const VectorContent& b);
     96
     97/** Vector view.
     98 * Extension of VectorContent to contain not a gsl_vector but only a view on a
     99 * gsl_vector (or row/column in a gsl_matrix).
     100 *
     101 * We need the above BaseCase here:
     102 * content, i.e. the gsl_vector, must not be allocated, as it is just a view
     103 * with an internal gsl_vector_view. Hence, BaseCase is just dummy class to
     104 * give the constructor a unique signature.
     105 */
     106struct VectorViewContent : public VectorContent
     107{
    41108  VectorViewContent(gsl_vector_view _view) :
    42109    VectorContent(BaseCase()),
    43110    view(_view)
    44111  {
     112    dimension = _view.vector.size;
    45113    content=&view.vector;
    46114  }
    47   virtual ~VectorViewContent(){
     115  ~VectorViewContent(){
    48116    content=0;
    49117  }
Note: See TracChangeset for help on using the changeset viewer.