Changeset c94eeb for src/vector.cpp


Ignore:
Timestamp:
Jun 25, 2010, 3:27:35 PM (16 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, 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:
33d774
Parents:
325390
Message:

Replaced several double* that were used as Matrixes with actuall matrix objects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/vector.cpp

    r325390 rc94eeb  
    105105double Vector::PeriodicDistance(const Vector &y, const double * const cell_size) const
    106106{
    107   double res = distance(y), tmp, matrix[NDIM*NDIM];
     107  double res = distance(y), tmp;
     108  Matrix matrix;
    108109    Vector Shiftedy, TranslationVector;
    109110    int N[NDIM];
    110     matrix[0] = cell_size[0];
    111     matrix[1] = cell_size[1];
    112     matrix[2] = cell_size[3];
    113     matrix[3] = cell_size[1];
    114     matrix[4] = cell_size[2];
    115     matrix[5] = cell_size[4];
    116     matrix[6] = cell_size[3];
    117     matrix[7] = cell_size[4];
    118     matrix[8] = cell_size[5];
     111    matrix.at(0,0) = cell_size[0];
     112    matrix.at(1,0) = cell_size[1];
     113    matrix.at(2,0) = cell_size[3];
     114    matrix.at(0,1) = cell_size[1];
     115    matrix.at(1,1) = cell_size[2];
     116    matrix.at(2,1) = cell_size[4];
     117    matrix.at(0,2) = cell_size[3];
     118    matrix.at(1,2) = cell_size[4];
     119    matrix.at(2,2) = cell_size[5];
    119120    // in order to check the periodic distance, translate one of the vectors into each of the 27 neighbouring cells
    120121    for (N[0]=-1;N[0]<=1;N[0]++)
     
    142143double Vector::PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const
    143144{
    144   double res = DistanceSquared(y), tmp, matrix[NDIM*NDIM];
     145  double res = DistanceSquared(y), tmp;
     146  Matrix matrix;
    145147    Vector Shiftedy, TranslationVector;
    146148    int N[NDIM];
    147     matrix[0] = cell_size[0];
    148     matrix[1] = cell_size[1];
    149     matrix[2] = cell_size[3];
    150     matrix[3] = cell_size[1];
    151     matrix[4] = cell_size[2];
    152     matrix[5] = cell_size[4];
    153     matrix[6] = cell_size[3];
    154     matrix[7] = cell_size[4];
    155     matrix[8] = cell_size[5];
     149    matrix.at(0,0) = cell_size[0];
     150    matrix.at(1,0) = cell_size[1];
     151    matrix.at(2,0) = cell_size[3];
     152    matrix.at(0,1) = cell_size[1];
     153    matrix.at(1,1) = cell_size[2];
     154    matrix.at(2,1) = cell_size[4];
     155    matrix.at(0,2) = cell_size[3];
     156    matrix.at(1,2) = cell_size[4];
     157    matrix.at(2,2) = cell_size[5];
    156158    // in order to check the periodic distance, translate one of the vectors into each of the 27 neighbouring cells
    157159    for (N[0]=-1;N[0]<=1;N[0]++)
     
    176178 * Tries to translate a vector into each adjacent neighbouring cell.
    177179 */
    178 void Vector::KeepPeriodic(const double * const matrix)
    179 {
     180void Vector::KeepPeriodic(const double * const _matrix)
     181{
     182  Matrix matrix = Matrix(_matrix);
    180183  //  int N[NDIM];
    181184  //  bool flag = false;
     
    185188  //  Output(out);
    186189  //  Log() << Verbose(0) << endl;
    187     InverseMatrixMultiplication(matrix);
     190    MatrixMultiplication(matrix.invert());
    188191    for(int i=NDIM;i--;) { // correct periodically
    189192      if (at(i) < 0) {  // get every coefficient into the interval [0,1)
     
    530533 * \param *Minv inverse matrix
    531534 */
    532 void Vector::WrapPeriodically(const double * const M, const double * const Minv)
    533 {
     535void Vector::WrapPeriodically(const double * const _M, const double * const _Minv)
     536{
     537  Matrix M = Matrix(_M);
     538  Matrix Minv = Matrix(_Minv);
    534539  MatrixMultiplication(Minv);
    535540  // truncate to [0,1] for each axis
     
    564569 * \param *matrix NDIM_NDIM array
    565570 */
    566 void Vector::MatrixMultiplication(const double * const M)
    567 {
    568   (*this) *= Matrix(M);
     571void Vector::MatrixMultiplication(const Matrix &M)
     572{
     573  (*this) *= M;
    569574};
    570575
Note: See TracChangeset for help on using the changeset viewer.