Ignore:
Timestamp:
Oct 12, 2011, 2:10:56 PM (13 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, 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:
c2e567
Parents:
c5038e
git-author:
Frederik Heber <heber@…> (09/09/11 21:30:06)
git-committer:
Frederik Heber <heber@…> (10/12/11 14:10:56)
Message:

Added serialization capabilities to VectorContent and MatrixContent.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LinearAlgebra/src/LinearAlgebra/MatrixContent.hpp

    rc5038e r29cbe9  
    1515
    1616#include "CodePatterns/Assert.hpp"
     17
     18#include <boost/serialization/array.hpp>
     19#include <boost/serialization/split_member.hpp>
    1720
    1821/** MatrixContent is a wrapper for gsl_matrix.
     
    165168  void write(std::ostream &ost) const;
    166169
     170  bool operator!=(const MatrixContent &other) const {
     171    return !(*this == other);
     172  }
     173
     174private:
     175  MatrixContent();
     176  friend class boost::serialization::access;
     177  // serialization (due to gsl_vector separate versions needed)
     178  template<class Archive>
     179  void save(Archive & ar, const unsigned int version) const
     180  {
     181    ar & boost::serialization::base_object<MatrixDimension>(*this);
     182    ar & content->size1;
     183    ar & content->size2;
     184    ar & content->tda;
     185    ar & boost::serialization::make_array<double>(content->data, content->size1*content->tda);
     186  }
     187  template<class Archive>
     188  void load(Archive & ar, const unsigned int version)
     189  {
     190    ar & boost::serialization::base_object<MatrixDimension>(*this);
     191    content = gsl_matrix_calloc(getRows(), getColumns());
     192    ar & content->size1;
     193    ASSERT(getRows() == content->size1,
     194        "MatrixContent::load() - rows dimension mismatch: "
     195        +toString(getRows())+" != "+toString(content->size1)+".");
     196    ar & content->size2;
     197    ASSERT(getColumns() == content->size2,
     198        "MatrixContent::load() - columns dimension mismatch: "
     199        +toString(getColumns())+" != "+toString(content->size2)+".");
     200    size_t tda = 0;
     201    ar & tda;
     202    ASSERT(tda == content->tda,
     203        "MatrixContent::load() - trailing dimension mismatch: "
     204        +toString(tda)+" != "+toString(content->tda)+".");
     205    ar & boost::serialization::make_array<double>(content->data, content->size1*tda);
     206    // this is always a copy, hence always free
     207    free_content_on_exit = true;
     208  }
     209  BOOST_SERIALIZATION_SPLIT_MEMBER()
     210
    167211protected:
    168212  double *Pointer(size_t m, size_t n);
     
    174218  bool free_content_on_exit;
    175219};
     220//BOOST_CLASS_EXPORT_GUID(MatrixContent, "MatrixContent")
    176221
    177222std::ostream & operator<<(std::ostream &ost, const MatrixContent &mat);
Note: See TracChangeset for help on using the changeset viewer.