| 1 | /* | 
|---|
| 2 | * gslvector.hpp | 
|---|
| 3 | * | 
|---|
| 4 | *  Created on: Jan 8, 2010 | 
|---|
| 5 | *      Author: heber | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef GSLVECTOR_HPP_ | 
|---|
| 9 | #define GSLVECTOR_HPP_ | 
|---|
| 10 |  | 
|---|
| 11 | using namespace std; | 
|---|
| 12 |  | 
|---|
| 13 | /*********************************************** includes ***********************************/ | 
|---|
| 14 |  | 
|---|
| 15 | // include config.h | 
|---|
| 16 | #ifdef HAVE_CONFIG_H | 
|---|
| 17 | #include <config.h> | 
|---|
| 18 | #endif | 
|---|
| 19 |  | 
|---|
| 20 | #include <iosfwd> | 
|---|
| 21 | #include <gsl/gsl_vector.h> | 
|---|
| 22 |  | 
|---|
| 23 | /****************************************** forward declarations *****************************/ | 
|---|
| 24 |  | 
|---|
| 25 | class GSLVector; | 
|---|
| 26 | class Vector; | 
|---|
| 27 |  | 
|---|
| 28 | /********************************************** declarations *******************************/ | 
|---|
| 29 |  | 
|---|
| 30 | class GSLVector { | 
|---|
| 31 | friend class LinearSystemOfEquations; | 
|---|
| 32 |  | 
|---|
| 33 | public: | 
|---|
| 34 | GSLVector(size_t m); | 
|---|
| 35 | GSLVector(const GSLVector * const src); | 
|---|
| 36 | GSLVector(const GSLVector & src); | 
|---|
| 37 | ~GSLVector(); | 
|---|
| 38 |  | 
|---|
| 39 | // Accessing | 
|---|
| 40 | void SetFromDoubleArray(double *x); | 
|---|
| 41 | void SetFromVector(Vector &v); | 
|---|
| 42 | double Get(size_t m) const; | 
|---|
| 43 | void Set(size_t m, double x); | 
|---|
| 44 | double *Pointer(size_t m) const; | 
|---|
| 45 | const double *const_Pointer(size_t m) const; | 
|---|
| 46 | size_t GetDimension() const; | 
|---|
| 47 |  | 
|---|
| 48 | // Initializing | 
|---|
| 49 | void SetAll(double x); | 
|---|
| 50 | void SetZero(); | 
|---|
| 51 | int SetBasis(size_t m); | 
|---|
| 52 |  | 
|---|
| 53 | // Exchanging elements | 
|---|
| 54 | int SwapElements(size_t i, size_t j); | 
|---|
| 55 | int Reverse(); | 
|---|
| 56 |  | 
|---|
| 57 | // checking state | 
|---|
| 58 | bool IsZero() const; | 
|---|
| 59 | bool IsOne() const; | 
|---|
| 60 |  | 
|---|
| 61 | private: | 
|---|
| 62 | gsl_vector *vector; | 
|---|
| 63 |  | 
|---|
| 64 | const size_t dimension; | 
|---|
| 65 | }; | 
|---|
| 66 |  | 
|---|
| 67 | ostream & operator << (ostream& ost, const GSLVector &m); | 
|---|
| 68 | bool operator==(const GSLVector& a, const GSLVector& b); | 
|---|
| 69 | const GSLVector& operator+=(GSLVector& a, const GSLVector& b); | 
|---|
| 70 | const GSLVector& operator-=(GSLVector& a, const GSLVector& b); | 
|---|
| 71 | const GSLVector& operator*=(GSLVector& a, const double m); | 
|---|
| 72 | GSLVector const operator*(const GSLVector& a, const double m); | 
|---|
| 73 | GSLVector const operator*(const double m, const GSLVector& a); | 
|---|
| 74 | GSLVector const operator+(const GSLVector& a, const GSLVector& b); | 
|---|
| 75 | GSLVector const operator-(const GSLVector& a, const GSLVector& b); | 
|---|
| 76 |  | 
|---|
| 77 |  | 
|---|
| 78 |  | 
|---|
| 79 |  | 
|---|
| 80 | #endif /* GSLVECTOR_HPP_ */ | 
|---|