gsl_vector_integer.h

Go to the documentation of this file.
00001 
00002 
00003 //
00013 
00014 //  This vector integer class has been adapted from the gslwrap project.
00015 //  It is a C++ wrapper for the GNU Scientific Library
00016 //  Copyright (C) 2001 Ramin Nakisa
00017 
00018 //  This program is free software; you can redistribute it and/or modify
00019 //  it under the terms of the GNU General Public License as published by
00020 //  the Free Software Foundation; either version 2 of the License, or
00021 //  (at your option) any later version.
00022 
00023 //  This program is distributed in the hope that it will be useful,
00024 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00025 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00026 //  GNU General Public License for more details.
00027 
00028 //  You should have received a copy of the GNU General Public License
00029 //  along with this program; if not, write to the Free Software
00030 //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00031 
00032 #ifndef _GSL_VECTOR_INTEGER_H
00033 #define _GSL_VECTOR_INTEGER_H
00034 
00035 #include <iostream>
00036 #include <assert.h>
00037 #include <gsl/gsl_math.h>
00038 #include <gsl/gsl_vector_int.h>
00039 #include <gsl/gsl_blas.h>
00040 #include "gsl_vector_double.h"
00041 
00043 //
00044 
00045 class vector_int
00046 {
00047 private:
00048 
00050 //
00051 
00052 gsl_vector_int *gsldata;
00053 
00055 //
00059 //  
00060 
00061 void alloc(size_t n);
00062 
00064 //
00068 
00069 void calloc(size_t n);
00070 
00071 public:
00072 
00074 //
00076 //
00077 
00078     vector_int();
00079 
00081 //
00088 //
00089     
00090     vector_int(const size_t& n,bool clear=true);
00091 
00093 //
00095 //
00096 
00097     ~vector_int();
00098 
00100 //    
00101     vector_int( const vector_int &other );
00102 
00104 // 
00108 //
00109 
00110         void copy(const vector_int& other);
00111 
00113 // 
00117 //
00118 
00119         void resize(size_t n);
00120 
00122 // 
00123 
00124         bool is_set() const;
00125 
00127 // 
00128 
00129     size_t size() const;
00130 
00132 //
00133 
00134     gsl_vector_int       *gslobj()       {assert(gsldata);return gsldata;}
00135 
00137 //
00138 
00139         const gsl_vector_int *gslobj() const {assert(gsldata);return gsldata;}
00140 
00142 //
00146 //
00147 
00148     int get(size_t i) const;
00149 
00151 //
00156 //
00157 
00158     void  set(size_t i,int x);
00159 
00161 //
00165 //
00166 
00167         int       &operator[](size_t i);
00168 
00170 //
00174 //
00175         
00176         const int &operator[](size_t i) const;
00177 
00179 //
00183 //
00184 
00185         int &operator()(size_t i);
00186 
00188 //
00192 //
00193 
00194         const int &operator()(size_t i) const;
00195 
00197 // 
00203 //
00204         
00205         int fprintf (FILE * stream, const char * format) const;
00206 
00208 //
00212 //
00213 
00214     int fscanf (FILE * stream);
00215 
00217 //
00221 //
00222 
00223         void set_all(int x);
00224 
00226 //
00228 //
00229         
00230         void set_zero();
00231 
00233 //
00238 //
00239 
00240         int set_basis (size_t i);
00241     
00243 //
00244 
00245     vector_int& operator=(const vector_int& other){copy(other);return (*this);}
00246 
00248 //
00251 //
00252 
00253     int swap_elements (size_t i, size_t j);
00254 
00256 //
00257 
00258     int reverse ();
00259 
00261 //
00265 //
00266 
00267         int operator+=(const vector_int &other) {return gsl_vector_int_add (gsldata, other.gsldata);}
00268 
00270 //
00274 //
00275 
00276         int operator-=(const vector_int &other) {return gsl_vector_int_sub (gsldata, other.gsldata);}
00277 
00279 //
00283 
00284         int operator*=(const vector_int &other) {return gsl_vector_int_mul (gsldata, other.gsldata);}
00285 
00287 //
00291 
00292         int operator/=(const vector_int &other) {return gsl_vector_int_div (gsldata, other.gsldata);}
00293 
00295 //
00298 //
00299 
00300         int operator*=(int x) {return gsl_vector_int_scale (gsldata, x);}
00301 
00303 //
00306 //
00307 
00308         int operator+=(int x) {return gsl_vector_int_add_constant (gsldata,x);}
00309 
00311 //
00314 //
00315 
00316         int operator/=(int x) {return gsl_vector_int_scale (gsldata, 1/x);}
00317 
00319 //
00321 //      
00322 
00323         bool operator==(const vector_int& other) const;
00324 
00326 //
00328 //      
00329         
00330         bool operator!=(const vector_int& other) const { return (!((*this)==other));}
00331 
00333 //
00334 
00335         int sum() const;
00336 
00338 //
00339 
00340     double max() const;
00341 
00343 //
00344 
00345     double min() const;
00346 
00348 //
00349 
00350         size_t max_index();
00351         
00353 //
00354 
00355         bool isnull();
00356 
00358 //
00360 //
00361 
00362         void load( const char *filename );
00363 
00365 //
00367 //
00368                 
00369         void save( const char *filename ) const;
00370 
00372 //
00378 //
00379 
00380         vector_int glex() const; 
00381 
00383 //
00390 //
00391 
00392         vector_int advance_cartesian_product(size_t num_points) const; 
00393         
00394         };
00395 
00396 #endif // GSL_VECTOR_INTEGER_H
All Classes Files Functions Variables Typedefs Friends Defines