Changeset 436f04


Ignore:
Timestamp:
Jun 26, 2010, 12:21:48 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
a679d1
Parents:
e3ffd3
Message:

Added a method that allows faster setting of matrix elements using direct access to the gsl_matrix_set() function

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Matrix.cpp

    re3ffd3 r436f04  
    2222Matrix::Matrix(const double* src){
    2323  content = gsl_matrix_alloc(NDIM, NDIM);
    24   this->at(0,0) = src[0];
    25   this->at(1,0) = src[1];
    26   this->at(2,0) = src[2];
     24  set(0,0, src[0]);
     25  set(1,0, src[1]);
     26  set(2,0, src[2]);
    2727
    28   this->at(0,1) = src[3];
    29   this->at(1,1) = src[4];
    30   this->at(2,1) = src[5];
     28  set(0,1, src[3]);
     29  set(1,1, src[4]);
     30  set(2,1, src[5]);
    3131
    32   this->at(0,2) = src[6];
    33   this->at(1,2) = src[7];
    34   this->at(2,2) = src[8];
     32  set(0,2, src[6]);
     33  set(1,2, src[7]);
     34  set(2,2, src[8]);
    3535}
    3636
     
    9595}
    9696
    97 const double &Matrix::at(size_t i, size_t j) const{
     97const double Matrix::at(size_t i, size_t j) const{
    9898  ASSERT(i>=0&&i<NDIM,"Index i for Matrix access out of range");
    9999  ASSERT(j>=0&&j<NDIM,"Index j for Matrix access out of range");
    100   return *gsl_matrix_ptr (content, i, j);
     100  return gsl_matrix_get(content, i, j);
     101}
     102
     103void Matrix::set(size_t i, size_t j, const double value){
     104  ASSERT(i>=0&&i<NDIM,"Index i for Matrix access out of range");
     105  ASSERT(j>=0&&j<NDIM,"Index j for Matrix access out of range");
     106  gsl_matrix_set(content,i,j,value);
    101107}
    102108
     
    118124  double detReci = 1./det;
    119125  Matrix res;
    120   res.at(0,0) =  detReci*RDET2(at(1,1),at(2,1),at(1,2),at(2,2));    // A_11
    121   res.at(1,0) = -detReci*RDET2(at(1,0),at(2,0),at(1,2),at(2,2));    // A_21
    122   res.at(2,0) =  detReci*RDET2(at(1,0),at(2,0),at(1,1),at(2,1));    // A_31
    123   res.at(0,1) = -detReci*RDET2(at(0,1),at(2,1),at(0,2),at(2,2));    // A_12
    124   res.at(1,1) =  detReci*RDET2(at(0,0),at(2,0),at(0,2),at(2,2));    // A_22
    125   res.at(2,1) = -detReci*RDET2(at(0,0),at(2,0),at(0,1),at(2,1));    // A_32
    126   res.at(0,2) =  detReci*RDET2(at(0,1),at(1,1),at(0,2),at(1,2));    // A_13
    127   res.at(1,2) = -detReci*RDET2(at(0,0),at(1,0),at(0,2),at(1,2));    // A_23
    128   res.at(2,2) =  detReci*RDET2(at(0,0),at(1,0),at(0,1),at(1,1));    // A_33
     126  res.set(0,0,  detReci*RDET2(at(1,1),at(2,1),at(1,2),at(2,2)));    // A_11
     127  res.set(1,0, -detReci*RDET2(at(1,0),at(2,0),at(1,2),at(2,2)));    // A_21
     128  res.set(2,0,  detReci*RDET2(at(1,0),at(2,0),at(1,1),at(2,1)));    // A_31
     129  res.set(0,1, -detReci*RDET2(at(0,1),at(2,1),at(0,2),at(2,2)));    // A_12
     130  res.set(1,1,  detReci*RDET2(at(0,0),at(2,0),at(0,2),at(2,2)));    // A_22
     131  res.set(2,1, -detReci*RDET2(at(0,0),at(2,0),at(0,1),at(2,1)));    // A_32
     132  res.set(0,2,  detReci*RDET2(at(0,1),at(1,1),at(0,2),at(1,2)));    // A_13
     133  res.set(1,2, -detReci*RDET2(at(0,0),at(1,0),at(0,2),at(1,2)));    // A_23
     134  res.set(2,2,  detReci*RDET2(at(0,0),at(1,0),at(0,1),at(1,1)));    // A_33
    129135  return res;
    130136}
     
    152158{
    153159  Matrix matrix;
    154   matrix.at(0,0) = symm[0];
    155   matrix.at(1,0) = symm[1];
    156   matrix.at(2,0) = symm[3];
    157   matrix.at(0,1) = symm[1];
    158   matrix.at(1,1) = symm[2];
    159   matrix.at(2,1) = symm[4];
    160   matrix.at(0,2) = symm[3];
    161   matrix.at(1,2) = symm[4];
    162   matrix.at(2,2) = symm[5];
     160  matrix.set(0,0, symm[0]);
     161  matrix.set(1,0, symm[1]);
     162  matrix.set(2,0, symm[3]);
     163  matrix.set(0,1, symm[1]);
     164  matrix.set(1,1, symm[2]);
     165  matrix.set(2,1, symm[4]);
     166  matrix.set(0,2, symm[3]);
     167  matrix.set(1,2, symm[4]);
     168  matrix.set(2,2, symm[5]);
    163169  return matrix;
    164170};
  • src/Matrix.hpp

    re3ffd3 r436f04  
    2424
    2525  double &at(size_t i, size_t j);
    26   const double &at(size_t i, size_t j) const;
     26  const double at(size_t i, size_t j) const;
     27
     28  void set(size_t i, size_t j, const double value);
    2729
    2830  double determinant() const;
Note: See TracChangeset for help on using the changeset viewer.