Changeset fee079


Ignore:
Timestamp:
Jul 2, 2010, 3:11:22 PM (14 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:
04ef48
Parents:
aafd77
Message:

Added a "forward declaration" of the gsl_matrix struct in file Matrix.hpp

Location:
src
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • src/Matrix.cpp

    raafd77 rfee079  
    1313#include "vector.hpp"
    1414#include "VectorContent.hpp"
     15#include "MatrixContent.hpp"
    1516
    1617#include <gsl/gsl_blas.h>
     
    2223Matrix::Matrix()
    2324{
    24   content = gsl_matrix_calloc(NDIM, NDIM);
     25  content = new MatrixContent();
     26  content->content = gsl_matrix_calloc(NDIM, NDIM);
    2527}
    2628
    2729Matrix::Matrix(const double* src){
    28   content = gsl_matrix_alloc(NDIM, NDIM);
     30  content = new MatrixContent();
     31  content->content = gsl_matrix_alloc(NDIM, NDIM);
    2932  set(0,0, src[0]);
    3033  set(1,0, src[1]);
     
    4144
    4245Matrix::Matrix(const Matrix &src){
    43   content = gsl_matrix_alloc(NDIM, NDIM);
    44   gsl_matrix_memcpy(content,src.content);
    45 }
    46 
    47 Matrix::Matrix(gsl_matrix* _content) :
     46  content = new MatrixContent();
     47  content->content = gsl_matrix_alloc(NDIM, NDIM);
     48  gsl_matrix_memcpy(content->content,src.content->content);
     49}
     50
     51Matrix::Matrix(MatrixContent* _content) :
    4852  content(_content)
    4953{}
     
    5155Matrix::~Matrix()
    5256{
    53   gsl_matrix_free(content);
     57  gsl_matrix_free(content->content);
     58  delete content;
    5459}
    5560
    5661void Matrix::one(){
    57   gsl_matrix_free(content);
    58   content = gsl_matrix_calloc(NDIM, NDIM);
     62  gsl_matrix_free(content->content);
     63  content->content = gsl_matrix_calloc(NDIM, NDIM);
    5964  for(int i = NDIM;i--;){
    6065    set(i,i,1.);
     
    6469Matrix &Matrix::operator=(const Matrix &src){
    6570  if(&src!=this){
    66     gsl_matrix_memcpy(content,src.content);
     71    gsl_matrix_memcpy(content->content,src.content->content);
    6772  }
    6873  return *this;
     
    7075
    7176Matrix &Matrix::operator+=(const Matrix &rhs){
    72   gsl_matrix_add(content, rhs.content);
     77  gsl_matrix_add(content->content, rhs.content->content);
    7378  return *this;
    7479}
    7580
    7681Matrix &Matrix::operator-=(const Matrix &rhs){
    77   gsl_matrix_sub(content, rhs.content);
     82  gsl_matrix_sub(content->content, rhs.content->content);
    7883  return *this;
    7984}
     
    98103Matrix Matrix::operator*(const Matrix &rhs) const{
    99104  gsl_matrix *res = gsl_matrix_alloc(NDIM, NDIM);
    100   gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1.0, this->content, rhs.content, 0.0, res);
    101   return Matrix(res);
     105  gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1.0, content->content, rhs.content->content, 0.0, res);
     106  MatrixContent *content= new MatrixContent();
     107  content->content = res;
     108  return Matrix(content);
    102109}
    103110
     
    105112  ASSERT(i>=0&&i<NDIM,"Index i for Matrix access out of range");
    106113  ASSERT(j>=0&&j<NDIM,"Index j for Matrix access out of range");
    107   return *gsl_matrix_ptr (content, i, j);
     114  return *gsl_matrix_ptr (content->content, i, j);
    108115}
    109116
     
    111118  ASSERT(i>=0&&i<NDIM,"Index i for Matrix access out of range");
    112119  ASSERT(j>=0&&j<NDIM,"Index j for Matrix access out of range");
    113   return gsl_matrix_get(content, i, j);
     120  return gsl_matrix_get(content->content, i, j);
    114121}
    115122
     
    117124  ASSERT(i>=0&&i<NDIM,"Index i for Matrix access out of range");
    118125  ASSERT(j>=0&&j<NDIM,"Index j for Matrix access out of range");
    119   gsl_matrix_set(content,i,j,value);
     126  gsl_matrix_set(content->content,i,j,value);
    120127}
    121128
     
    150157
    151158Matrix &Matrix::operator*=(const double factor){
    152   gsl_matrix_scale(content, factor);
     159  gsl_matrix_scale(content->content, factor);
    153160  return *this;
    154161}
     
    197204Vector operator*(const Matrix &mat,const Vector &vec){
    198205  gsl_vector *res = gsl_vector_calloc(NDIM);
    199   gsl_blas_dgemv( CblasNoTrans, 1.0, mat.content, vec.content->content, 0.0, res);
     206  gsl_blas_dgemv( CblasNoTrans, 1.0, mat.content->content, vec.content->content, 0.0, res);
    200207  VectorContent *content = new VectorContent();
    201208  content->content = res;
  • src/Matrix.hpp

    raafd77 rfee079  
    99#define MATRIX_HPP_
    1010
    11 #include <gsl/gsl_matrix.h>
    1211#include <iosfwd>
    1312#include "defs.hpp"
     
    1817
    1918class Vector;
     19class MatrixContent;
    2020
    2121class Matrix
     
    9292
    9393private:
    94   Matrix(gsl_matrix*);
    95   gsl_matrix *content;
     94  Matrix(MatrixContent*);
     95  MatrixContent *content;
    9696};
    9797
Note: See TracChangeset for help on using the changeset viewer.