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/MatrixContent.hpp

    r589112 r6e06bd  
    99#define MATRIXCONTENT_HPP_
    1010
    11 /**
    12  * !file
    13  * The way GSL works does not allow for forward definitions of the structures.
    14  * Because of this the pointer to the gsl_matrix struct is wrapped inside another
    15  * (dumb) object that allows for forward definitions. All methods of this class
    16  * are empty, to allow for a maximum of flexibility.
     11/** MatrixContent is a wrapper for gsl_matrix.
     12 *
     13 * The GNU Scientific Library contaisn some very well written routines for
     14 * linear algebra problems. However, it's syntax is C and hence it does not
     15 * lend itself to readable written code, i.e. C = A * B, where A, B, and C
     16 * are all matrices. Writing code this way is very convenient, concise and
     17 * also in the same manner as one would type in MatLab.
     18 * However, with C++ and its feature to overload functions and its operator
     19 * functions such syntax is easy to create.
     20 *
     21 * Hence, this class is a C++ wrapper to gsl_matrix. There already some other
     22 * libraries, however they fall short for the following reasons:
     23 * -# gslwrap: not very well written and uses floats instead of doubles
     24 * -# gslcpp: last change is from 2007 and only very few commits
     25 * -# o2scl: basically, the same functionality as gsl only written in C++,
     26 *    however it uses GPLv3 license which is inconvenient for MoleCuilder.
     27 *
     28 * <h1>Howto use MatrixContent</h1>
     29 *
     30 * One should not use MatrixContent directly but either have it as a member
     31 * variable in a specialized class or inherit from it.
     32 *
    1733 */
    1834
    1935#include <gsl/gsl_matrix.h>
    2036
    21 struct MatrixContent{
     37class Vector;
     38
     39class MatrixContent
     40{
     41  friend Vector operator*(const MatrixContent &mat,const Vector &vec);
     42  friend class RealSpaceMatrix;
     43  friend class LinearSystemOfEquations;
     44
     45  friend class MatrixContentTest;
     46  friend class MatrixContentSymmetricTest;
     47public:
     48  MatrixContent(size_t rows, size_t columns);
     49  MatrixContent(size_t rows, size_t columns, const double *src);
     50  MatrixContent(gsl_matrix *&src);
     51  MatrixContent(const MatrixContent &src);
     52  MatrixContent(const MatrixContent *src);
     53  ~MatrixContent();
     54
     55  // Accessing
     56  double &at(size_t i, size_t j);
     57  const double at(size_t i, size_t j) const;
     58  void set(size_t i, size_t j, const double value);
     59
     60  // Initializing
     61  void setFromDoubleArray(double * x);
     62  void setIdentity();
     63  void setValue(double _value);
     64  void setZero();
     65
     66  // Exchanging elements
     67  bool SwapRows(size_t i, size_t j);
     68  bool SwapColumns(size_t i, size_t j);
     69  bool SwapRowColumn(size_t i, size_t j);
     70
     71  // Transformations
     72  MatrixContent transpose() const;
     73  MatrixContent &transpose();
     74  gsl_vector* transformToEigenbasis();
     75
     76  // Properties
     77  bool IsNull() const;
     78  bool IsPositive() const;
     79  bool IsNegative() const;
     80  bool IsNonNegative() const;
     81  bool IsPositiveDefinite() const;
     82  double Determinant() const;
     83
     84  // Operators
     85  MatrixContent &operator=(const MatrixContent &src);
     86  const MatrixContent &operator+=(const MatrixContent &rhs);
     87  const MatrixContent &operator-=(const MatrixContent &rhs);
     88  const MatrixContent &operator*=(const MatrixContent &rhs);
     89  const MatrixContent operator*(const MatrixContent &rhs) const;
     90  const MatrixContent &operator*=(const double factor);
     91  bool operator==(const MatrixContent &rhs) const;
     92
     93protected:
     94  double *Pointer(size_t m, size_t n);
     95  const double *const_Pointer(size_t m, size_t n) const;
     96
     97private:
    2298  gsl_matrix * content;
     99  const size_t rows;      // store for internal purposes
     100  const size_t columns;  // store for internal purposes
    23101};
    24102
     103const MatrixContent operator*(const double factor,const MatrixContent& mat);
     104const MatrixContent operator*(const MatrixContent &mat,const double factor);
     105Vector operator*(const MatrixContent &mat,const Vector &vec);
     106
    25107#endif /* MATRIXCONTENT_HPP_ */
Note: See TracChangeset for help on using the changeset viewer.