yat  0.8.3pre
VectorBase.h
00001 #ifndef _theplu_yat_utility_vector_base_
00002 #define _theplu_yat_utility_vector_base_
00003 
00004 // $Id: VectorBase.h 2119 2009-12-12 23:11:43Z peter $
00005 
00006 /*
00007   Copyright (C) 2003 Daniel Dalevi, Peter Johansson
00008   Copyright (C) 2004 Jari Häkkinen, Peter Johansson
00009   Copyright (C) 2005 Jari Häkkinen, Peter Johansson, Markus Ringnér
00010   Copyright (C) 2006 Jari Häkkinen, Markus Ringnér
00011   Copyright (C) 2007 Jari Häkkinen, Peter Johansson, Markus Ringnér
00012   Copyright (C) 2008 Jari Häkkinen, Peter Johansson
00013   Copyright (C) 2009 Peter Johansson
00014 
00015   This file is part of the yat library, http://dev.thep.lu.se/trac/yat
00016 
00017   The yat library is free software; you can redistribute it and/or
00018   modify it under the terms of the GNU General Public License as
00019   published by the Free Software Foundation; either version 3 of the
00020   License, or (at your option) any later version.
00021 
00022   The yat library is distributed in the hope that it will be useful,
00023   but WITHOUT ANY WARRANTY; without even the implied warranty of
00024   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00025   General Public License for more details.
00026 
00027   You should have received a copy of the GNU General Public License
00028   along with yat. If not, see <http://www.gnu.org/licenses/>.
00029 */
00030 
00031 #include "StrideIterator.h"
00032 
00033 #include <iosfwd>
00034 #include <vector>
00035 #include <cstddef> // size_t
00036 
00037 #include <gsl/gsl_vector.h>
00038 
00039 namespace theplu {
00040 namespace yat {
00041 namespace utility {
00042   
00043   class matrix;
00044   class Vector;
00045 
00052   class VectorBase
00053   {
00054   public:
00060     typedef double value_type;
00061 
00067     typedef const double& const_reference;
00068 
00070     typedef StrideIterator<const double*> const_iterator;
00071 
00075     VectorBase(const gsl_vector* v=NULL);
00076 
00080     virtual ~VectorBase(void);
00081 
00085     const_iterator begin(void) const;
00086 
00090     const_iterator end(void) const;
00091 
00101     bool equal(const VectorBase&, const double precision=0) const;
00102 
00106     const gsl_vector* gsl_vector_p(void) const;
00107 
00114     virtual bool isview(void) const=0; 
00115 
00119     size_t size(void) const;
00120 
00130     const double& operator()(size_t i) const;
00131 
00143     bool operator==(const VectorBase&) const;
00144 
00156     bool operator!=(const VectorBase&) const;
00157 
00161     double operator*(const VectorBase&) const;
00162 
00163   protected:
00165     const gsl_vector* const_vec_;
00166 
00167   private:
00168     // copy assignment not allowed
00169     const VectorBase& operator=(const VectorBase&);
00170   };
00171 
00180   bool isnull(const VectorBase&);
00181 
00189   double max(const VectorBase&);
00190 
00200   size_t max_index(const VectorBase&);
00201 
00209   double min(const VectorBase&);
00210 
00220   size_t min_index(const VectorBase&);
00221 
00237   bool nan(const VectorBase& templat, Vector& flag);
00238 
00251   void sort_index(std::vector<size_t>& sort_index, const VectorBase& invec);
00252 
00259   void sort_smallest_index(std::vector<size_t>& sort_index, size_t k, 
00260                            const VectorBase& invec);
00261 
00268   void sort_largest_index(std::vector<size_t>& sort_index, size_t k, 
00269                           const VectorBase& invec);
00270 
00278   double sum(const VectorBase&);
00279 
00293   std::ostream& operator<<(std::ostream& s, const VectorBase& v);
00294 
00295 }}} // of namespace utility, yat, and theplu
00296 
00297 #endif

Generated on Thu Dec 20 2012 03:12:58 for yat by  doxygen 1.8.0-20120409