Changeset a439e5
- Timestamp:
- Aug 6, 2010, 12:40:05 PM (14 years ago)
- 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:
- 6e5084
- Parents:
- 311d688
- git-author:
- Frederik Heber <heber@…> (08/05/10 14:27:34)
- git-committer:
- Frederik Heber <heber@…> (08/06/10 12:40:05)
- Location:
- src/LinearAlgebra
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/LinearAlgebra/Line.cpp
r311d688 ra439e5 11 11 12 12 #include <cmath> 13 #include <iostream> 13 14 14 15 #include "LinearAlgebra/Vector.hpp" -
src/LinearAlgebra/Matrix.cpp
r311d688 ra439e5 16 16 17 17 #include <gsl/gsl_blas.h> 18 #include <gsl/gsl_eigen.h> 19 #include <gsl/gsl_matrix.h> 20 #include <gsl/gsl_multimin.h> 21 #include <gsl/gsl_vector.h> 18 22 #include <cmath> 19 23 #include <iostream> … … 92 96 for(int j=NDIM;j--;){ 93 97 set(i,j,i==j); 98 } 99 } 100 } 101 102 void Matrix::zero(){ 103 for(int i=NDIM;i--;){ 104 for(int j=NDIM;j--;){ 105 set(i,j,0.); 94 106 } 95 107 } … … 192 204 - at(2,2)*at(1,0)*at(0,1); 193 205 } 206 207 Matrix Matrix::transpose() const 208 { 209 Matrix copy(*this); 210 copy.transpose(); 211 return copy; 212 } 213 214 215 void Matrix::transpose() 216 { 217 double tmp; 218 for (int i=0;i<NDIM;i++) 219 for (int j=i+1;j<NDIM;j++) { 220 tmp = at(j,i); 221 at(i,j) = tmp; 222 at(j,i) = tmp; 223 } 224 } 225 194 226 195 227 Matrix Matrix::invert() const{ … … 213 245 } 214 246 247 Vector Matrix::transformToEigenbasis() 248 { 249 gsl_eigen_symmv_workspace *T = gsl_eigen_symmv_alloc(NDIM); 250 gsl_vector *eval = gsl_vector_alloc(NDIM); 251 gsl_matrix *evec = gsl_matrix_alloc(NDIM, NDIM); 252 gsl_eigen_symmv(content->content, eval, evec, T); 253 gsl_eigen_symmv_free(T); 254 gsl_matrix_memcpy(content->content, evec); 255 Vector evalues(gsl_vector_get(eval,0), gsl_vector_get(eval,1), gsl_vector_get(eval,2)); 256 return evalues; 257 } 258 215 259 Matrix &Matrix::operator*=(const double factor){ 216 260 gsl_matrix_scale(content->content, factor); -
src/LinearAlgebra/Matrix.hpp
r311d688 ra439e5 51 51 52 52 /** 53 * Set all matrix entries to zero. 54 */ 55 void zero(); 56 57 /** 53 58 * Access the matrix at index (i,j) 54 59 */ … … 95 100 */ 96 101 Matrix invert() const; 102 103 /** 104 * Diagonalizes a matrix and sets its rows to the resulting eigenvalues. 105 * The eigenvalues are returned as a vector. 106 * 107 * Rather costly, so use precomputation as often as possible. 108 */ 109 Vector transformToEigenbasis(); 110 111 /** 112 * Calculate the transpose of the matrix. 113 */ 114 Matrix transpose() const; 115 void transpose(); 97 116 98 117 // operators -
src/LinearAlgebra/Vector.cpp
r311d688 ra439e5 17 17 #include <iostream> 18 18 #include <gsl/gsl_blas.h> 19 #include <gsl/gsl_vector.h> 19 20 20 21 … … 92 93 return (sqrt(DistanceSquared(y))); 93 94 }; 95 96 size_t Vector::GreatestComponent() const 97 { 98 int greatest = 0; 99 for (int i=1;i<NDIM;i++) { 100 if (at(i) > at(greatest)) 101 greatest = i; 102 } 103 return greatest; 104 } 105 106 size_t Vector::SmallestComponent() const 107 { 108 int smallest = 0; 109 for (int i=1;i<NDIM;i++) { 110 if (at(i) < at(smallest)) 111 smallest = i; 112 } 113 return smallest; 114 } 115 94 116 95 117 Vector Vector::getClosestPoint(const Vector &point) const{ -
src/LinearAlgebra/Vector.hpp
r311d688 ra439e5 63 63 std::pair<Vector,Vector> partition(const Vector&) const; 64 64 std::pair<pointset,Vector> partition(const pointset&) const; 65 size_t GreatestComponent() const; 66 size_t SmallestComponent() const; 65 67 66 68 // Accessors ussually come in pairs... and sometimes even more than that
Note:
See TracChangeset
for help on using the changeset viewer.