source: src/LinearAlgebra/RealSpaceMatrix.hpp@ 8766e72

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
Last change on this file since 8766e72 was b81f1c, checked in by Frederik Heber <heber@…>, 14 years ago

Removed libMolecuilderRandomNumbers from LinearAlgebra.

  • added RealSpaceMatrix::setRotation() that accepts phi[NDIM].
  • moved RealSpaceMatrix::setRandomRotation() to boundary.cpp where it is solely used.
  • Property mode set to 100644
File size: 4.3 KB
RevLine 
[325390]1/*
[cca9ef]2 * RealSpaceMatrix.hpp
[325390]3 *
4 * Created on: Jun 25, 2010
5 * Author: crueger
6 */
7
[cca9ef]8#ifndef REALSPACEMATRIX_HPP_
9#define REALSPACEMATRIX_HPP_
[325390]10
[56f73b]11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16
[986ed3]17#include <iosfwd>
[06aedc]18
19#include "LinearAlgebra/defs.hpp"
20
[325390]21
[cd82ec]22/**
23 * Simple class to store matrices with a few extra functions
24 */
25
[325390]26class Vector;
[fee079]27class MatrixContent;
[325390]28
[cca9ef]29/** 3x3 Matrix class.
30 * This class has some specific features for 3D space such as rotations or
31 * hard-coded determinants.
32 */
33class RealSpaceMatrix
[325390]34{
[cca9ef]35 friend Vector operator*(const RealSpaceMatrix&,const Vector&);
[325390]36public:
[cca9ef]37 RealSpaceMatrix();
[cd82ec]38
39 /**
40 * construct a matrix from a 3x3 double array that contains all Elements.
41 *
42 * The elements are laid out in the following way:
43 * array -> matrix
44 * 0 -> (0,0)
45 * 1 -> (1,0)
46 * 2 -> (2,0)
47 * 3 -> (0,1)
48 * 4 -> (1,1)
49 * 5 -> (2,1)
50 * 6 -> (0,2)
51 * 7 -> (1,2)
52 * 8 -> (2,2)
53 *
54 */
[cca9ef]55 RealSpaceMatrix(const double*);
56 RealSpaceMatrix(const RealSpaceMatrix&);
57 RealSpaceMatrix(const MatrixContent&);
58 virtual ~RealSpaceMatrix();
[325390]59
[cd82ec]60 /**
61 * Set the matrix to a unit matrix.
62 */
[9eb7580]63 void setIdentity();
[1da5f5]64
[a439e5]65 /**
66 * Set all matrix entries to zero.
67 */
[9eb7580]68 void setZero();
[a439e5]69
[31fb1d]70 /**
71 * Sets all matrix corresponding to a rotation matrix,
72 * first around the x-, then the y-, finally the z-axis
73 * with given angles.
74 */
[9eb7580]75 void setRotation(const double x, const double y, const double z);
[31fb1d]76
[b81f1c]77 /**
78 * Sets all matrix corresponding to a rotation matrix,
79 * first around the x-, then the y-, finally the z-axis
80 * with given angles.
81 */
82 void setRotation(const double phi[NDIM]);
[cd82ec]83 /**
84 * Access the matrix at index (i,j)
85 */
[325390]86 double &at(size_t i, size_t j);
[cd82ec]87 /**
88 * Access the matrix at index (i,j)
89 */
[436f04]90 const double at(size_t i, size_t j) const;
91
[cd82ec]92 /**
93 * Set the matrix at index (i,j).
94 *
95 * Slightly faster than at(i,j)=x
96 */
[436f04]97 void set(size_t i, size_t j, const double value);
[325390]98
[3dbb9d]99 /**
100 * get the ith row of the matrix as a vector
101 */
102 Vector &row(size_t);
103 const Vector &row(size_t) const;
104
105 /**
106 * get the ith column of the matrix as a vector
107 */
108 Vector &column(size_t);
109 const Vector &column(size_t) const;
110
111 /**
112 * get the diagonal of the matrix as a vector
113 */
114 Vector &diagonal();
115 const Vector &diagonal() const;
116
[cd82ec]117 /**
118 * Calculate the determinant of the matrix
119 */
[cadbc1]120 double determinant() const;
[325390]121
[cd82ec]122 /**
123 * Calculate the inverse of the matrix.
124 *
125 * Rather costly, so use precomputation as often as possible.
126 */
[cca9ef]127 RealSpaceMatrix invert() const;
[325390]128
[a439e5]129 /**
130 * Diagonalizes a matrix and sets its rows to the resulting eigenvalues.
131 * The eigenvalues are returned as a vector.
132 *
133 * Rather costly, so use precomputation as often as possible.
134 */
135 Vector transformToEigenbasis();
136
137 /**
138 * Calculate the transpose of the matrix.
139 */
[cca9ef]140 RealSpaceMatrix transpose() const;
141 RealSpaceMatrix &transpose();
[a439e5]142
[325390]143 // operators
[cca9ef]144 RealSpaceMatrix &operator=(const RealSpaceMatrix&);
[325390]145
[cca9ef]146 const RealSpaceMatrix &operator+=(const RealSpaceMatrix&);
147 const RealSpaceMatrix &operator-=(const RealSpaceMatrix&);
148 const RealSpaceMatrix &operator*=(const RealSpaceMatrix&);
[325390]149
[cca9ef]150 const RealSpaceMatrix &operator*=(const double);
[325390]151
[cca9ef]152 const RealSpaceMatrix operator+(const RealSpaceMatrix&) const;
153 const RealSpaceMatrix operator-(const RealSpaceMatrix&) const;
154 const RealSpaceMatrix operator*(const RealSpaceMatrix&) const;
[325390]155
[cca9ef]156 bool operator==(const RealSpaceMatrix&) const;
[0eb2dc]157
[325390]158private:
[cca9ef]159 RealSpaceMatrix(MatrixContent*);
[3dbb9d]160 void createViews();
[fee079]161 MatrixContent *content;
[8e17d6]162 // we keep around some Vector views of the matrix, to return references
[3dbb9d]163 Vector* rows_ptr[NDIM];
164 Vector* columns_ptr[NDIM];
165 Vector* diagonal_ptr;
[325390]166};
167
[cca9ef]168const RealSpaceMatrix operator*(const double,const RealSpaceMatrix&);
169const RealSpaceMatrix operator*(const RealSpaceMatrix&,const double);
[325390]170
[cd82ec]171/**
172 * Takes a symmetric matrix that stores the lower diagonal and produces a
173 * full matrix.
174 *
175 * The array is laid out as follows:
176 *
177 * array -> matrix
178 * 0 -> (0,0)
179 * 1 -> (1,0);(0,1)
180 * 2 -> (1,1)
181 * 3 -> (2,0);(0,2)
182 * 4 -> (2,1);(1,2)
183 * 5 -> (2,2)
184 */
[cca9ef]185RealSpaceMatrix ReturnFullMatrixforSymmetric(const double * const cell_size);
[d10eb6]186
[cca9ef]187std::ostream &operator<<(std::ostream&,const RealSpaceMatrix&);
188Vector operator*(const RealSpaceMatrix&,const Vector&);
189Vector& operator*=(Vector&,const RealSpaceMatrix&);
[c49c96]190
[cca9ef]191#endif /* REALSPACEMATRIX_HPP_ */
Note: See TracBrowser for help on using the repository browser.