Changeset bbf1bd
- Timestamp:
- Dec 4, 2010, 11:54:32 PM (14 years ago)
- 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:
- 6e06bd, b4cf2b
- Parents:
- 5ada94
- git-author:
- Frederik Heber <heber@…> (11/15/10 20:00:30)
- git-committer:
- Frederik Heber <heber@…> (12/04/10 23:54:32)
- Location:
- src
- Files:
-
- 1 added
- 12 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
src/LinearAlgebra/Makefile.am
r5ada94 rbbf1bd 23 23 vector_ops.cpp \ 24 24 Vector.cpp \ 25 VectorContent.cpp \ 25 26 VectorInterface.cpp 26 27 -
src/LinearAlgebra/MatrixContent.cpp
r5ada94 rbbf1bd 475 475 Vector operator*(const MatrixContent &mat,const Vector &vec) 476 476 { 477 Vector res ;478 gsl_blas_dgemv( CblasNoTrans, 1.0, mat.content, vec.content->content, 0.0, res .content->content);479 return res ;480 } 477 Vector result; 478 gsl_blas_dgemv( CblasNoTrans, 1.0, mat.content, vec.content->content, 0.0, result.content->content); 479 return result; 480 } -
src/LinearAlgebra/MatrixContent.hpp
r5ada94 rbbf1bd 57 57 const double at(size_t i, size_t j) const; 58 58 void set(size_t i, size_t j, const double value); 59 60 // Initializing 59 61 void setFromDoubleArray(double * x); 62 void setIdentity(); 63 void setValue(double _value); 64 void setZero(); 60 65 61 66 // Exchanging elements … … 76 81 bool IsPositiveDefinite() const; 77 82 double Determinant() const; 78 79 // Initializing80 void setIdentity();81 void setZero();82 void setValue(double _value);83 83 84 84 // Operators -
src/LinearAlgebra/RealSpaceMatrix.cpp
r5ada94 rbbf1bd 87 87 VectorContent *rowContent = new VectorViewContent(gsl_matrix_row(content->content,i)); 88 88 rows_ptr[i] = new Vector(rowContent); 89 ASSERT(rowContent == NULL, "RealSpaceMatrix::createViews() - rowContent was not taken over as supposed to happen!"); 89 90 } 90 91 // create column views … … 92 93 VectorContent *columnContent = new VectorViewContent(gsl_matrix_column(content->content,i)); 93 94 columns_ptr[i] = new Vector(columnContent); 95 ASSERT(columnContent == NULL, "RealSpaceMatrix::createViews() - columnContent was not taken over as supposed to happen!"); 94 96 } 95 97 // create diagonal view 96 98 VectorContent *diagonalContent = new VectorViewContent(gsl_matrix_diagonal(content->content)); 97 99 diagonal_ptr = new Vector(diagonalContent); 100 ASSERT(diagonalContent == NULL, "RealSpaceMatrix::createViews() - diagonalContent was not taken over as supposed to happen!"); 98 101 } 99 102 -
src/LinearAlgebra/Vector.cpp
r5ada94 rbbf1bd 41 41 Vector::Vector() 42 42 { 43 content = new VectorContent(); 44 }; 45 46 /** 47 * Copy constructor 48 */ 49 43 content = new VectorContent((size_t) NDIM); 44 }; 45 46 /** Copy constructor. 47 * \param &src source Vector reference 48 */ 50 49 Vector::Vector(const Vector& src) 51 50 { 52 content = new VectorContent(); 53 gsl_vector_memcpy(content->content, src.content->content); 51 content = new VectorContent(*(src.content)); 54 52 } 55 53 56 54 /** Constructor of class vector. 55 * \param x1 first component 56 * \param x2 second component 57 * \param x3 third component 57 58 */ 58 59 Vector::Vector(const double x1, const double x2, const double x3) 59 60 { 60 content = new VectorContent( );61 gsl_vector_set(content->content,0,x1);62 gsl_vector_set(content->content,1,x2);63 gsl_vector_set(content->content,2,x3);61 content = new VectorContent((size_t) NDIM); 62 content->at(0) = x1; 63 content->at(1) = x2; 64 content->at(2) = x3; 64 65 }; 65 66 66 67 /** Constructor of class vector. 68 * \param x[3] three values to initialize Vector with 67 69 */ 68 70 Vector::Vector(const double x[3]) 69 71 { 70 content = new VectorContent(); 71 gsl_vector_set(content->content,0,x[0]); 72 gsl_vector_set(content->content,1,x[1]); 73 gsl_vector_set(content->content,2,x[2]); 74 }; 75 76 Vector::Vector(VectorContent *_content) : 77 content(_content) 78 {} 79 80 /** 81 * Assignment operator 72 content = new VectorContent((size_t) NDIM); 73 for (size_t i = NDIM; i--; ) 74 content->at(i) = x[i]; 75 }; 76 77 /** Copy constructor of class vector from VectorContent. 78 * \note This is destructive, i.e. we take over _content. 79 */ 80 Vector::Vector(VectorContent *&_content) : 81 content(_content) 82 { 83 _content = NULL; 84 } 85 86 /** Copy constructor of class vector from VectorContent. 87 * \note This is non-destructive, i.e. _content is copied. 88 */ 89 Vector::Vector(VectorContent &_content) 90 { 91 content = new VectorContent(_content); 92 } 93 94 /** Assignment operator. 95 * \param &src source vector to assign \a *this to 96 * \return reference to \a *this 82 97 */ 83 98 Vector& Vector::operator=(const Vector& src){ 84 99 // check for self assignment 85 100 if(&src!=this){ 86 gsl_vector_memcpy(content->content, src.content->content);101 *content = *(src.content); 87 102 } 88 103 return *this; … … 90 105 91 106 /** Desctructor of class vector. 107 * Vector::content is deleted. 92 108 */ 93 109 Vector::~Vector() { -
src/LinearAlgebra/Vector.hpp
r5ada94 rbbf1bd 33 33 class Vector : public Space{ 34 34 friend Vector operator*(const MatrixContent&,const Vector&); 35 friend class RealSpaceMatrix; 35 friend class RealSpaceMatrix; // needs access to Vector(VectorContent*&) due to views 36 36 public: 37 37 Vector(); … … 104 104 105 105 private: 106 Vector(VectorContent *); 106 explicit Vector(VectorContent *&); 107 explicit Vector(VectorContent &_content); 107 108 VectorContent *content; 108 109 -
src/LinearAlgebra/VectorContent.hpp
r5ada94 rbbf1bd 18 18 */ 19 19 20 #include <iosfwd> 21 20 22 #include <gsl/gsl_vector.h> 21 23 24 class Vector; 25 26 /** Dummy structure to create a unique signature. 27 * 28 */ 22 29 struct BaseCase{}; 23 30 24 struct VectorContent{ 25 VectorContent(){ 26 content = gsl_vector_calloc (NDIM); 27 } 28 VectorContent(BaseCase){ 31 class VectorContent{ 32 friend std::ostream & operator<< (std::ostream& ost, const VectorContent &m); 33 friend VectorContent const operator*(const VectorContent& a, const double m); 34 friend VectorContent const operator*(const double m, const VectorContent& a); 35 friend VectorContent const operator+(const VectorContent& a, const VectorContent& b); 36 friend VectorContent const operator-(const VectorContent& a, const VectorContent& b); 29 37 30 } 31 virtual ~VectorContent(){ 32 if(content){ 33 gsl_vector_free(content); 34 content = 0; 35 } 36 } 38 public: 39 explicit VectorContent(size_t _dim); 40 VectorContent(BaseCase); 41 VectorContent(const VectorContent * const src); 42 VectorContent(const VectorContent & src); 43 virtual ~VectorContent(); 44 45 // Accessing 46 double &at(size_t m); 47 const double at(size_t m) const; 48 double & operator[](size_t i); 49 const double operator[](size_t i) const; 50 double *Pointer(size_t m) const; 51 const double *const_Pointer(size_t m) const; 52 53 // Assignment operator 54 VectorContent &operator=(const VectorContent& src); 55 56 // Initializing 57 void setFromDoubleArray(double * x); 58 void setFromVector(Vector &v); 59 void setValue(double x); 60 void setZero(); 61 int setBasis(size_t m); 62 63 // Exchanging elements 64 int SwapElements(size_t i, size_t j); 65 int Reverse(); 66 67 // checking state 68 bool IsZero() const; 69 bool IsOne() const; 70 71 // properties 72 bool IsNormalTo(const Vector &normal) const; 73 bool IsEqualTo(const Vector &a) const; 74 75 // properties relative to another VectorContent 76 double DistanceSquared(const VectorContent &y) const; 77 double ScalarProduct(const VectorContent &y) const; 78 double Angle(const VectorContent &y) const; 79 80 // operators 81 bool operator==(const VectorContent& b) const; 82 const VectorContent& operator+=(const VectorContent& b); 83 const VectorContent& operator-=(const VectorContent& b); 84 const VectorContent& operator*=(const double m); 85 86 size_t dimension; 37 87 gsl_vector *content; 88 private: 38 89 }; 39 90 40 struct VectorViewContent : public VectorContent{ 91 std::ostream & operator << (std::ostream& ost, const VectorContent &m); 92 VectorContent const operator*(const VectorContent& a, const double m); 93 VectorContent const operator*(const double m, const VectorContent& a); 94 VectorContent const operator+(const VectorContent& a, const VectorContent& b); 95 VectorContent const operator-(const VectorContent& a, const VectorContent& b); 96 97 /** Vector view. 98 * Extension of VectorContent to contain not a gsl_vector but only a view on a 99 * gsl_vector (or row/column in a gsl_matrix). 100 * 101 * We need the above BaseCase here: 102 * content, i.e. the gsl_vector, must not be allocated, as it is just a view 103 * with an internal gsl_vector_view. Hence, BaseCase is just dummy class to 104 * give the constructor a unique signature. 105 */ 106 struct VectorViewContent : public VectorContent 107 { 41 108 VectorViewContent(gsl_vector_view _view) : 42 109 VectorContent(BaseCase()), 43 110 view(_view) 44 111 { 112 dimension = _view.vector.size; 45 113 content=&view.vector; 46 114 } 47 virtual~VectorViewContent(){115 ~VectorViewContent(){ 48 116 content=0; 49 117 } -
src/LinearAlgebra/linearsystemofequations.cpp
r5ada94 rbbf1bd 22 22 #include "defs.hpp" 23 23 #include "LinearAlgebra/MatrixContent.hpp" 24 #include "LinearAlgebra/ gslvector.hpp"24 #include "LinearAlgebra/VectorContent.hpp" 25 25 #include "LinearAlgebra/linearsystemofequations.hpp" 26 #include "Helpers/Assert.hpp" 26 27 #include "Helpers/logger.hpp" 27 28 #include "LinearAlgebra/Vector.hpp" 28 29 29 #include <cassert>30 30 #include <gsl/gsl_permutation.h> 31 31 … … 38 38 { 39 39 A = new MatrixContent(m, n); 40 b = new GSLVector(m);41 x = new GSLVector(n);40 b = new VectorContent(m); 41 x = new VectorContent(n); 42 42 }; 43 43 … … 58 58 bool LinearSystemOfEquations::SetSymmetric(bool symmetric) 59 59 { 60 assert (rows == columns &&"Rows and columns don't have equal size! Setting symmetric not possible.");60 ASSERT (rows == columns, "Rows and columns don't have equal size! Setting symmetric not possible."); 61 61 return (IsSymmetric = symmetric); 62 62 }; … … 67 67 void LinearSystemOfEquations::Setb(Vector *x) 68 68 { 69 assert ( columns == NDIM &&"Vector class is always three-dimensional, unlike this LEqS!");70 b-> SetFromVector(*x);69 ASSERT ( columns == NDIM, "Vector class is always three-dimensional, unlike this LEqS!"); 70 b->setFromVector(*x); 71 71 }; 72 72 … … 76 76 void LinearSystemOfEquations::Setb(double *x) 77 77 { 78 b-> SetFromDoubleArray(x);78 b->setFromDoubleArray(x); 79 79 }; 80 80 … … 98 98 // copy solution 99 99 for (size_t i=0;i<x->dimension;i++) { 100 array[i] = x-> Get(i);100 array[i] = x->at(i); 101 101 } 102 102 return status; … … 109 109 bool LinearSystemOfEquations::GetSolutionAsVector(Vector &v) 110 110 { 111 assert(rows == NDIM &&"Solution can only be returned as vector if number of columns is NDIM.");111 ASSERT (rows == NDIM, "Solution can only be returned as vector if number of columns is NDIM."); 112 112 bool status = Solve(); 113 113 114 114 // copy solution 115 115 for (size_t i=0;i<x->dimension;i++) 116 v[i] = x-> Get(i);116 v[i] = x->at(i); 117 117 return status; 118 118 }; … … 130 130 gsl_permutation * p = gsl_permutation_alloc (x->dimension); 131 131 gsl_linalg_LU_decomp (A->content, p, &s); 132 gsl_linalg_LU_solve (A->content, p, b-> vector, x->vector);132 gsl_linalg_LU_solve (A->content, p, b->content, x->content); 133 133 gsl_permutation_free (p); 134 134 } else { // use Householder 135 135 //MatrixContent *backup = new MatrixContent(rows,columns); 136 136 //*backup = *A; 137 gsl_linalg_HH_solve (A->content, b-> vector, x->vector);137 gsl_linalg_HH_solve (A->content, b->content, x->content); 138 138 //*A = *backup; 139 139 //delete(backup); -
src/LinearAlgebra/linearsystemofequations.hpp
r5ada94 rbbf1bd 22 22 class Vector; 23 23 class MatrixContent; 24 class GSLVector;24 class VectorContent; 25 25 26 26 /********************************************** declarations *******************************/ … … 44 44 bool GetSolutionAsVector(Vector &v); 45 45 46 GSLVector*b;47 GSLVector*x;46 VectorContent *b; 47 VectorContent *x; 48 48 MatrixContent *A; 49 49 -
src/unittests/Makefile.am
r5ada94 rbbf1bd 22 22 CountBondsUnitTest \ 23 23 FormulaUnittest \ 24 GSLVectorUnitTest \25 24 InfoUnitTest \ 26 25 LinearSystemOfEquationsUnitTest \ … … 46 45 Tesselation_BoundaryTriangleUnitTest \ 47 46 Tesselation_InOutsideUnitTest \ 47 VectorContentUnitTest \ 48 48 VectorUnitTest 49 49 … … 82 82 CountBondsUnitTest.cpp \ 83 83 FormulaUnittest.cpp \ 84 gslvectorunittest.cpp \85 84 infounittest.cpp \ 86 85 linearsystemofequationsunittest.cpp \ … … 106 105 tesselation_boundarytriangleunittest.cpp \ 107 106 tesselation_insideoutsideunittest.cpp \ 107 VectorContentUnittest.cpp \ 108 108 vectorunittest.cpp 109 109 … … 122 122 CountBondsUnitTest.hpp \ 123 123 FormulaUnittest.hpp \ 124 gslvectorunittest.hpp \125 124 infounittest.hpp \ 126 125 linearsystemofequationsunittest.hpp \ … … 145 144 tesselation_boundarytriangleunittest.hpp \ 146 145 tesselation_insideoutsideunittest.hpp \ 146 VectorContentUnittest.hpp \ 147 147 vectorunittest.hpp 148 148 … … 193 193 MatrixContentUnitTest_LDADD = ${ALLLIBS} 194 194 195 GSLVectorUnitTest_SOURCES = UnitTestMain.cpp gslvectorunittest.cpp gslvectorunittest.hpp196 GSLVectorUnitTest_LDADD = ${ALLLIBS}197 198 195 InfoUnitTest_SOURCES = UnitTestMain.cpp infounittest.cpp infounittest.hpp 199 196 InfoUnitTest_LDADD = ${ALLLIBS} … … 262 259 TestRunner_LDADD = ${UILIBS} ${ALLLIBS} 263 260 261 VectorContentUnitTest_SOURCES = UnitTestMain.cpp VectorContentUnittest.cpp VectorContentUnittest.hpp 262 VectorContentUnitTest_LDADD = ${ALLLIBS} 263 264 264 VectorUnitTest_SOURCES = UnitTestMain.cpp vectorunittest.cpp vectorunittest.hpp 265 265 VectorUnitTest_LDADD = ${ALLLIBS} -
src/unittests/MatrixContentSymmetricUnittest.cpp
r5ada94 rbbf1bd 230 230 res.transpose(); 231 231 CPPUNIT_ASSERT( *m == res ); 232 delete n; 232 233 }; 233 234 -
src/unittests/MatrixContentUnittest.cpp
r5ada94 rbbf1bd 234 234 MatrixContent res2 = ((const MatrixContent)res).transpose(); 235 235 CPPUNIT_ASSERT( *m == res2 ); 236 delete n; 236 237 }; 237 238 -
src/unittests/VectorContentUnittest.cpp
r5ada94 rbbf1bd 7 7 8 8 /* 9 * gslvectorunittest.cpp9 * VectorContentUnittest.cpp 10 10 * 11 11 * Created on: Jan 8, 2010 … … 24 24 #include <cppunit/ui/text/TestRunner.h> 25 25 26 #include " gslvectorunittest.hpp"26 #include "VectorContentUnittest.hpp" 27 27 28 28 #ifdef HAVE_TESTRUNNER … … 33 33 34 34 // Registers the fixture into the 'registry' 35 CPPUNIT_TEST_SUITE_REGISTRATION( GSLVectorTest );35 CPPUNIT_TEST_SUITE_REGISTRATION( VectorContentTest ); 36 36 37 37 38 void GSLVectorTest::setUp()38 void VectorContentTest::setUp() 39 39 { 40 v = new GSLVector(3);40 v = new VectorContent(3); 41 41 }; 42 42 43 void GSLVectorTest::tearDown()43 void VectorContentTest::tearDown() 44 44 { 45 45 delete(v); … … 49 49 * 50 50 */ 51 void GSLVectorTest::AccessTest()51 void VectorContentTest::AccessTest() 52 52 { 53 53 // set 54 54 for (int i=0;i<3;i++) 55 v-> Set(i,i);55 v->at(i) = (double)i; 56 56 57 57 // and check 58 58 double *ptr = NULL; 59 59 for (int i=0;i<3;i++) { 60 CPPUNIT_ASSERT_EQUAL( (double)i, v-> Get(i) );60 CPPUNIT_ASSERT_EQUAL( (double)i, v->at(i) ); 61 61 ptr = v->Pointer(i); 62 62 CPPUNIT_ASSERT_EQUAL( (double)i, *ptr ); … … 64 64 65 65 // out of bounds 66 //CPPUNIT_ASSERT_EQUAL(0., v-> Get(3) );67 //CPPUNIT_ASSERT_EQUAL(0., v-> Get(-1) );66 //CPPUNIT_ASSERT_EQUAL(0., v->at(3) ); 67 //CPPUNIT_ASSERT_EQUAL(0., v->at(-1) ); 68 68 }; 69 69 … … 72 72 * 73 73 */ 74 void GSLVectorTest::InitializaionTest()74 void VectorContentTest::InitializaionTest() 75 75 { 76 76 // set zero 77 v-> SetZero();77 v->setZero(); 78 78 for (int i=0;i<3;i++) 79 CPPUNIT_ASSERT_EQUAL( 0., v-> Get(i) );79 CPPUNIT_ASSERT_EQUAL( 0., v->at(i) ); 80 80 81 81 // set basis 82 82 for (int i=0;i<3;i++) { 83 v-> SetBasis(i);83 v->setBasis(i); 84 84 for (int j=0;j<3;j++) 85 CPPUNIT_ASSERT_EQUAL( i == j ? 1. : 0. , v-> Get(j) );85 CPPUNIT_ASSERT_EQUAL( i == j ? 1. : 0. , v->at(j) ); 86 86 } 87 87 88 88 // set all 89 v-> SetAll(1.5);89 v->setValue(1.5); 90 90 for (int i=0;i<3;i++) 91 CPPUNIT_ASSERT_EQUAL( 1.5, v-> Get(i) );91 CPPUNIT_ASSERT_EQUAL( 1.5, v->at(i) ); 92 92 }; 93 93 … … 95 95 * 96 96 */ 97 void GSLVectorTest::CopyTest()97 void VectorContentTest::CopyTest() 98 98 { 99 99 // set basis 100 GSLVector*dest = NULL;100 VectorContent *dest = NULL; 101 101 for (int i=0;i<3;i++) { 102 v-> SetBasis(i);103 dest = new GSLVector(v);102 v->setBasis(i); 103 dest = new VectorContent(v); 104 104 for (int j=0;j<3;j++) 105 CPPUNIT_ASSERT_EQUAL( v-> Get(j) , dest->Get(j) );105 CPPUNIT_ASSERT_EQUAL( v->at(j) , dest->at(j) ); 106 106 107 107 delete(dest); … … 112 112 * 113 113 */ 114 void GSLVectorTest::ExchangeTest()114 void VectorContentTest::ExchangeTest() 115 115 { 116 116 // set basis 117 117 for (int i=0;i<3;i++) { 118 v-> SetBasis(i);118 v->setBasis(i); 119 119 v->SwapElements((i)%3,(i+1)%3); 120 120 for (int j=0;j<3;j++) 121 CPPUNIT_ASSERT_EQUAL( (i+1)%3 == j ? 1. : 0. , v-> Get(j) );121 CPPUNIT_ASSERT_EQUAL( (i+1)%3 == j ? 1. : 0. , v->at(j) ); 122 122 } 123 123 124 124 // set to 1,2,3 and reverse 125 125 for (int i=0;i<3;i++) 126 v-> Set(i,i+1);126 v->at(i) = (double)(i+1); 127 127 v->Reverse(); 128 128 for (int j=0;j<3;j++) 129 CPPUNIT_ASSERT_EQUAL( (double)(3-j), v-> Get(j) );129 CPPUNIT_ASSERT_EQUAL( (double)(3-j), v->at(j) ); 130 130 }; 131 131 132 132 /** UnitTest for operators. 133 133 */ 134 void GSLVectorTest::OperatorIsTest()134 void VectorContentTest::OperatorIsTest() 135 135 { 136 GSLVectorzero(3);137 GSLVectorunit(3);138 zero. SetZero();139 unit. SetZero();140 unit .Set(1,1.);136 VectorContent zero(3); 137 VectorContent unit(3); 138 zero.setZero(); 139 unit.setZero(); 140 unit[1] = 1.; 141 141 // summation and scaling 142 142 CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() ); … … 148 148 /** UnitTest for operators. 149 149 */ 150 void GSLVectorTest::OperatorAlgebraTest()150 void VectorContentTest::OperatorAlgebraTest() 151 151 { 152 GSLVectorzero(3);153 GSLVectorunit(3);154 zero. SetZero();155 unit. SetZero();156 unit .Set(1,1.);152 VectorContent zero(3); 153 VectorContent unit(3); 154 zero.setZero(); 155 unit.setZero(); 156 unit[1] = 1.; 157 157 // summation and scaling 158 158 CPPUNIT_ASSERT_EQUAL( true, (zero+unit).IsOne() ); -
src/unittests/VectorContentUnittest.hpp
r5ada94 rbbf1bd 1 1 /* 2 * gslvectorunittest.hpp2 * VectorContentUnittest.hpp 3 3 * 4 4 * Created on: Jan 8, 2010 … … 6 6 */ 7 7 8 #ifndef GSLVECTORUNITTEST_HPP_9 #define GSLVECTORUNITTEST_HPP_8 #ifndef VECTORCONTENTUNITTEST_HPP_ 9 #define VECTORCONTENTUNITTEST_HPP_ 10 10 11 11 #include <cppunit/extensions/HelperMacros.h> 12 12 13 #include "LinearAlgebra/ gslvector.hpp"13 #include "LinearAlgebra/VectorContent.hpp" 14 14 15 15 /********************************************** Test classes **************************************/ 16 16 17 class GSLVectorTest : public CppUnit::TestFixture17 class VectorContentTest : public CppUnit::TestFixture 18 18 { 19 CPPUNIT_TEST_SUITE( GSLVectorTest) ;19 CPPUNIT_TEST_SUITE( VectorContentTest) ; 20 20 CPPUNIT_TEST (AccessTest ); 21 21 CPPUNIT_TEST (InitializaionTest ); … … 39 39 private: 40 40 41 GSLVector*v;41 VectorContent *v; 42 42 }; 43 43 44 44 45 #endif /* GSLVECTORUNITTEST_HPP_ */45 #endif /* VECTORCONTENTUNITTEST_HPP_ */
Note:
See TracChangeset
for help on using the changeset viewer.