Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

gsl::vector Class Reference

#include <vector_double.h>

Inheritance diagram for gsl::vector::

gsl::vector_view List of all members.

Public Methods

 vector ()
 vector (const vector &other)
template<class oclass>  vector (const oclass &other)
 ~vector ()
 vector (const size_t &n, bool clear=true)
 vector (const int &n, bool clear=true)
void resize (size_t n)
template<class oclass> void copy (const oclass &other)
void copy (const vector &other)
size_t size () const
gsl_vector* gslobj ()
const gsl_vector* gslobj () const
double get (size_t i) const
void set (size_t i, double x)
double& operator[] (size_t i)
const double& operator[] (size_t i) const
double& operator() (size_t i)
const double& operator() (size_t i) const
void set_all (double x)
void set_zero ()
int set_basis (size_t i)
int fwrite (FILE *stream) const
int fread (FILE *stream)
int fprintf (FILE *stream, const char *format) const
int fscanf (FILE *stream)
vector_view subvector (size_t offset, size_t n)
const vector_view subvector (size_t offset, size_t n) const
vector& operator= (const vector &other)
int swap_elements (size_t i, size_t j)
int reverse ()
int operator+= (const vector &other)
int operator-= (const vector &other)
int operator *= (const vector &other)
int operator/= (const vector &other)
int operator *= (double x)
int operator+= (double x)
int operator/= (double x)
bool operator== (const vector &other) const
bool operator!= (const vector &other) const
double sum () const
double norm2 () const

Static Public Methods

vector_view create_vector_view (const gsl_vector_view &other)

Protected Methods

void free ()
void alloc (size_t n)
void calloc (size_t n)

Protected Attributes

gsl_vector* gsldata

Constructor & Destructor Documentation

gsl::vector::vector ( ) [inline]
 

Definition at line 40 of file vector_double.h.

00040 : gsldata(NULL) {;}

gsl::vector::vector ( const vector & other ) [inline]
 

Definition at line 41 of file vector_double.h.

00041 :gsldata(NULL) {copy(other);}

template<class oclass>
gsl::vector::vector ( const oclass & other ) [inline]
 

Definition at line 43 of file vector_double.h.

00043 :gsldata(NULL) {copy(other);}

gsl::vector::~vector ( ) [inline]
 

Definition at line 44 of file vector_double.h.

00044 {free();}

gsl::vector::vector ( const size_t & n,
bool clear = true ) [inline]
 

Definition at line 45 of file vector_double.h.

00046         {
00047                 if(clear){this->calloc(n);}
00048                 else     {this->alloc(n);}
00049         }

gsl::vector::vector ( const int & n,
bool clear = true ) [inline]
 

Definition at line 50 of file vector_double.h.

00051         {
00052                 if(clear){this->calloc(n);}
00053                 else     {this->alloc(n);}
00054         }


Member Function Documentation

void gsl::vector::alloc ( size_t n ) [inline, protected]
 

Definition at line 37 of file vector_double.h.

Referenced by resize(), and vector().

00037 {gsldata=gsl_vector_alloc(n);}

void gsl::vector::calloc ( size_t n ) [inline, protected]
 

Definition at line 38 of file vector_double.h.

Referenced by vector().

00038 {gsldata=gsl_vector_calloc(n);}

void gsl::vector::copy ( const vector & other )
 

Definition at line 58 of file vector_double.cc.

00059 {
00060                 resize(other.size());
00061                 gsl_vector_memcpy (gsldata,other.gsldata);
00062 }

template<class oclass>
void gsl::vector::copy ( const oclass & other ) [inline]
 

Definition at line 59 of file vector_double.h.

Referenced by operator=(), and vector().

00060                 {
00061                         resize(other.size());
00062                         for (size_t i=0;i<size();i++)
00063                         {
00064                                 gsl_vector_set(gsldata, i, (double)other[i]);
00065                         }
00066                 }

vector_view gsl::vector::create_vector_view ( const gsl_vector_view & other ) [static]
 

Definition at line 30 of file vector_double.cc.

00031 {
00032         vector view;
00033         view.gsldata = (gsl_vector*)malloc(sizeof(gsl_vector));
00034         *(view.gslobj()) = other.vector;
00035         view.gslobj()->owner = 0;
00036         return view;
00037 }

int gsl::vector::fprintf ( FILE * stream,
const char * format ) const [inline]
 

Definition at line 122 of file vector_double.h.

00122 {return gsl_vector_fprintf (stream, gsldata,format) ;}

int gsl::vector::fread ( FILE * stream ) [inline]
 

Definition at line 119 of file vector_double.h.

00119 {return gsl_vector_fread (stream, gsldata);}

void gsl::vector::free ( ) [inline, protected]
 

Definition at line 36 of file vector_double.h.

Referenced by gsl::vector_view::init(), resize(), and ~vector().

00036 {if(gsldata) gsl_vector_free(gsldata);gsldata=NULL;}

int gsl::vector::fscanf ( FILE * stream ) [inline]
 

Definition at line 125 of file vector_double.h.

00125 {return gsl_vector_fscanf (stream, gsldata); }

int gsl::vector::fwrite ( FILE * stream ) const [inline]
 

Definition at line 116 of file vector_double.h.

00116 {return gsl_vector_fwrite (stream, gsldata);}

double gsl::vector::get ( size_t i ) const [inline]
 

Definition at line 86 of file vector_double.h.

00086 {return gsl_vector_get(gsldata,i);}

const gsl_vector * gsl::vector::gslobj ( ) const [inline]
 

Definition at line 74 of file vector_double.h.

00074 {if (!gsldata){cout << "vector::gslobj ERROR, data not initialized!! " << endl; exit(-1);}return gsldata;}

gsl_vector * gsl::vector::gslobj ( ) [inline]
 

for interfacing with gsl c

Definition at line 73 of file vector_double.h.

Referenced by gsl_function_call_test().

00073 {if (!gsldata){cout << "vector::gslobj ERROR, data not initialized!! " << endl; exit(-1);}return gsldata;}

double gsl::vector::norm2 ( ) const
 

Definition at line 107 of file vector_double.cc.

00108 {
00109         vector t=*this;
00110         return gsl_blas_dnrm2(t.gslobj());
00111 }

int gsl::vector::operator *= ( double x ) [inline]
 

Definition at line 281 of file vector_double.h.

00281 {return gsl_vector_scale (gsldata, x);}

int gsl::vector::operator *= ( const vector & other ) [inline]
 

Definition at line 275 of file vector_double.h.

00275 {return gsl_vector_mul (gsldata, other.gsldata);}

bool gsl::vector::operator!= ( const vector & other ) const [inline]
 

Definition at line 292 of file vector_double.h.

00292 { return (!((*this)==other));}

const double & gsl::vector::operator() ( size_t i ) const [inline]
 

Definition at line 96 of file vector_double.h.

00096 { return *gsl_vector_ptr(gsldata,i);}

double & gsl::vector::operator() ( size_t i ) [inline]
 

Definition at line 95 of file vector_double.h.

00095 { return *gsl_vector_ptr(gsldata,i);}

int gsl::vector::operator+= ( double x ) [inline]
 

Definition at line 285 of file vector_double.h.

00285 {return gsl_vector_add_constant (gsldata,x);}

int gsl::vector::operator+= ( const vector & other ) [inline]
 

Definition at line 268 of file vector_double.h.

00268 {return gsl_vector_add (gsldata, other.gsldata);}

int gsl::vector::operator-= ( const vector & other ) [inline]
 

Definition at line 271 of file vector_double.h.

00271 {return gsl_vector_sub (gsldata, other.gsldata);}

int gsl::vector::operator/= ( double x ) [inline]
 

Definition at line 288 of file vector_double.h.

00288 {return gsl_vector_scale (gsldata, 1/x);}

int gsl::vector::operator/= ( const vector & other ) [inline]
 

Definition at line 278 of file vector_double.h.

00278 {return gsl_vector_div (gsldata, other.gsldata);}

vector & gsl::vector::operator= ( const vector & other ) [inline]
 

Definition at line 246 of file vector_double.h.

00246 {copy(other);return (*this);}

bool gsl::vector::operator== ( const vector & other ) const
 

Definition at line 65 of file vector_double.cc.

00066 {
00067         if (size() != other.size())
00068                 return false;
00069         for (int i=0;i<size(); i++)
00070         {
00071                 if (this->operator[](i) != other[i])
00072                         return false;
00073         }
00074         return true;
00075 }

const double & gsl::vector::operator[] ( size_t i ) const [inline]
 

Definition at line 93 of file vector_double.h.

00093 { return *gsl_vector_ptr(gsldata,i);}

double & gsl::vector::operator[] ( size_t i ) [inline]
 

Definition at line 92 of file vector_double.h.

Referenced by operator==().

00092 { return *gsl_vector_ptr(gsldata,i);}

void gsl::vector::resize ( size_t n )
 

Definition at line 40 of file vector_double.cc.

Referenced by copy().

00041 {
00042         if (gsldata)
00043         {
00044                 if (n==size())
00045                         return;
00046                 if (!gsldata->owner)
00047                 {
00048                         cout << "vector::resize ERROR can't resize a vector view" << endl;
00049                         exit(-1);
00050 //                      GSL_ERROR("You can't resize a vector view", GSL_EINVAL);
00051                 }
00052                 free();
00053         }
00054         alloc(n);
00055 }

int gsl::vector::reverse ( ) [inline]
 

Definition at line 261 of file vector_double.h.

00261 {return  gsl_vector_reverse (gsldata) ;}

void gsl::vector::set ( size_t i,
double x ) [inline]
 

Definition at line 89 of file vector_double.h.

00089 {gsl_vector_set(gsldata,i,x);}

void gsl::vector::set_all ( double x ) [inline]
 

Definition at line 103 of file vector_double.h.

00103 {gsl_vector_set_all (gsldata,x);}

int gsl::vector::set_basis ( size_t i ) [inline]
 

Definition at line 108 of file vector_double.h.

00108 {return gsl_vector_set_basis (gsldata,i);}

void gsl::vector::set_zero ( ) [inline]
 

Definition at line 105 of file vector_double.h.

00105 {gsl_vector_set_zero (gsldata);}

size_t gsl::vector::size ( ) const [inline]
 

Definition at line 70 of file vector_double.h.

Referenced by copy(), operator==(), resize(), and sum().

00070 {if (!gsldata) {cout << "vector::size vector not initialized" << endl; exit(-1);}return gsldata->size;}

const vector_view gsl::vector::subvector ( size_t offset,
size_t n ) const
 

Definition at line 86 of file vector_double.cc.

00087 {
00088         gsl_vector_view view = gsl_vector_subvector (gsldata, offset, n);
00089         return vector_view::create_vector_view(view);
00090 }

vector_view gsl::vector::subvector ( size_t offset,
size_t n )
 

Definition at line 78 of file vector_double.cc.

00079 {
00080         gsl_vector_view view = gsl_vector_subvector (gsldata, offset, n);
00081         return vector_view::create_vector_view(view);
00082 }

double gsl::vector::sum ( ) const
 

returns sum of all the vector elements.

Definition at line 93 of file vector_double.cc.

Referenced by RandomNumberGeneratorTest().

00094 {
00095         int i;
00096         double sum = 0;
00097 
00098         for ( i = 0; i < size(); i++ ) 
00099         {
00100                 sum += gsl_vector_get(gsldata, i);
00101         }
00102 
00103         return( sum );
00104 }

int gsl::vector::swap_elements ( size_t i,
size_t j ) [inline]
 

Definition at line 257 of file vector_double.h.

00257 {return gsl_vector_swap_elements (gsldata, i,j);}


Member Data Documentation

gsl_vector * gsl::vector::gsldata [protected]
 

Definition at line 35 of file vector_double.h.


The documentation for this class was generated from the following files:
Generated at Sun Dec 16 23:44:46 2001 for gslwrap by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001