Changeset ce3d2b for src


Ignore:
Timestamp:
Jul 2, 2010, 2:58:25 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:
c37386
Parents:
986ed3
git-author:
Tillmann Crueger <crueger@…> (07/02/10 13:45:20)
git-committer:
Tillmann Crueger <crueger@…> (07/02/10 14:58:25)
Message:

Added a "forward declaration" to the gsl_vector struct to avoid inclusion of the GSL-Headers in too many files

  • because the gsl structure does not allow for forward declarations a dumb object is used instead to simulate forwarding
Location:
src
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • src/Matrix.cpp

    r986ed3 rce3d2b  
    1212#include "Helpers/Assert.hpp"
    1313#include "vector.hpp"
     14#include "VectorContent.hpp"
    1415
    1516#include <gsl/gsl_blas.h>
     
    196197Vector operator*(const Matrix &mat,const Vector &vec){
    197198  gsl_vector *res = gsl_vector_calloc(NDIM);
    198   gsl_blas_dgemv( CblasNoTrans, 1.0, mat.content, vec.content, 0.0, res);
    199   return Vector(res);
     199  gsl_blas_dgemv( CblasNoTrans, 1.0, mat.content, vec.content->content, 0.0, res);
     200  VectorContent *content = new VectorContent();
     201  content->content = res;
     202  return Vector(content);
    200203}
    201204
  • src/gslvector.cpp

    r986ed3 rce3d2b  
    1414#include "defs.hpp"
    1515#include "vector.hpp"
     16#include "VectorContent.hpp"
    1617
    1718/** Constructor of class GSLVector.
     
    6970 */
    7071void GSLVector::SetFromVector(Vector &v){
    71   gsl_vector_memcpy (vector, v.get());
     72  gsl_vector_memcpy (vector, v.get()->content);
    7273}
    7374
  • src/vector.cpp

    r986ed3 rce3d2b  
    88
    99#include "vector.hpp"
     10#include "VectorContent.hpp"
    1011#include "verbose.hpp"
    1112#include "World.hpp"
     
    2728Vector::Vector()
    2829{
    29   content = gsl_vector_calloc (NDIM);
     30  content = new VectorContent();
     31  content->content = gsl_vector_calloc (NDIM);
    3032};
    3133
     
    3638Vector::Vector(const Vector& src)
    3739{
    38   content = gsl_vector_alloc(NDIM);
    39   gsl_vector_memcpy(content, src.content);
     40  content = new VectorContent();
     41  content->content = gsl_vector_alloc(NDIM);
     42  gsl_vector_memcpy(content->content, src.content->content);
    4043}
    4144
     
    4447Vector::Vector(const double x1, const double x2, const double x3)
    4548{
    46   content = gsl_vector_alloc(NDIM);
    47   gsl_vector_set(content,0,x1);
    48   gsl_vector_set(content,1,x2);
    49   gsl_vector_set(content,2,x3);
    50 };
    51 
    52 Vector::Vector(gsl_vector *_content) :
     49  content = new VectorContent();
     50  content->content = gsl_vector_alloc(NDIM);
     51  gsl_vector_set(content->content,0,x1);
     52  gsl_vector_set(content->content,1,x2);
     53  gsl_vector_set(content->content,2,x3);
     54};
     55
     56Vector::Vector(VectorContent *_content) :
    5357  content(_content)
    5458{}
     
    6064  // check for self assignment
    6165  if(&src!=this){
    62     gsl_vector_memcpy(content, src.content);
     66    gsl_vector_memcpy(content->content, src.content->content);
    6367  }
    6468  return *this;
     
    6872 */
    6973Vector::~Vector() {
    70   gsl_vector_free(content);
     74  gsl_vector_free(content->content);
     75  delete content;
    7176};
    7277
     
    104109{
    105110  double res = 0.;
    106   gsl_blas_ddot(content, y.content, &res);
     111  gsl_blas_ddot(content->content, y.content->content, &res);
    107112  return (res);
    108113};
     
    269274double& Vector::operator[](size_t i){
    270275  ASSERT(i<=NDIM && i>=0,"Vector Index out of Range");
    271   return *gsl_vector_ptr (content, i);
     276  return *gsl_vector_ptr (content->content, i);
    272277}
    273278
    274279const double& Vector::operator[](size_t i) const{
    275280  ASSERT(i<=NDIM && i>=0,"Vector Index out of Range");
    276   return *gsl_vector_ptr (content, i);
     281  return *gsl_vector_ptr (content->content, i);
    277282}
    278283
     
    285290}
    286291
    287 gsl_vector* Vector::get(){
     292VectorContent* Vector::get(){
    288293  return content;
    289294}
     
    405410
    406411void Vector::ScaleAll(const Vector &factor){
    407   gsl_vector_mul(content, factor.content);
     412  gsl_vector_mul(content->content, factor.content->content);
    408413}
    409414
     
    411416void Vector::Scale(const double factor)
    412417{
    413   gsl_vector_scale(content,factor);
     418  gsl_vector_scale(content->content,factor);
    414419};
    415420
     
    519524void Vector::AddVector(const Vector &y)
    520525{
    521   gsl_vector_add(content, y.content);
     526  gsl_vector_add(content->content, y.content->content);
    522527}
    523528
     
    527532void Vector::SubtractVector(const Vector &y)
    528533{
    529   gsl_vector_sub(content, y.content);
     534  gsl_vector_sub(content->content, y.content->content);
    530535}
    531536
  • src/vector.hpp

    r986ed3 rce3d2b  
    1212
    1313#include <iosfwd>
    14 #include <gsl/gsl_vector.h>
    1514
    1615#include <memory>
     
    2423class Vector;
    2524class Matrix;
     25struct VectorContent;
    2626
    2727typedef std::vector<Vector> pointset;
     
    7373
    7474  // Access to internal structure
    75   gsl_vector* get();
     75  VectorContent* get();
    7676
    7777  // Methods that are derived directly from other methods
     
    9898
    9999private:
    100   Vector(gsl_vector *);
    101   gsl_vector *content;
     100  Vector(VectorContent *);
     101  VectorContent *content;
    102102
    103103};
Note: See TracChangeset for help on using the changeset viewer.