00001 #ifndef _theplu_yat_utility_vector_base_ 00002 #define _theplu_yat_utility_vector_base_ 00003 00004 // $Id: VectorBase.h 1797 2009-02-12 18:07:10Z 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 "Exception.h" 00032 #include "StrideIterator.h" 00033 00034 #include <iosfwd> 00035 #include <vector> 00036 #include <cstddef> // size_t 00037 00038 #include <gsl/gsl_vector.h> 00039 00040 namespace theplu { 00041 namespace yat { 00042 namespace utility { 00043 00044 class matrix; 00045 class Vector; 00046 00053 class VectorBase 00054 { 00055 public: 00061 typedef double value_type; 00062 00068 typedef const double& const_reference; 00069 00071 typedef StrideIterator<const double*> const_iterator; 00072 00076 VectorBase(const gsl_vector* v=NULL); 00077 00081 virtual ~VectorBase(void); 00082 00086 const_iterator begin(void) const; 00087 00091 const_iterator end(void) const; 00092 00102 bool equal(const VectorBase&, const double precision=0) const; 00103 00107 const gsl_vector* gsl_vector_p(void) const; 00108 00115 virtual bool isview(void) const=0; 00116 00120 size_t size(void) const; 00121 00131 const double& operator()(size_t i) const; 00132 00144 bool operator==(const VectorBase&) const; 00145 00157 bool operator!=(const VectorBase&) const; 00158 00162 double operator*(const VectorBase&) const; 00163 00164 protected: 00166 const gsl_vector* const_vec_; 00167 00168 private: 00169 // copy assignment not allowed 00170 const VectorBase& operator=(const VectorBase&); 00171 }; 00172 00179 bool isnull(const VectorBase&); 00180 00186 double max(const VectorBase&); 00187 00195 size_t max_index(const VectorBase&); 00196 00202 double min(const VectorBase&); 00203 00211 size_t min_index(const VectorBase&); 00212 00226 bool nan(const VectorBase& templat, Vector& flag); 00227 00238 void sort_index(std::vector<size_t>& sort_index, const VectorBase& invec); 00239 00244 void sort_smallest_index(std::vector<size_t>& sort_index, size_t k, 00245 const VectorBase& invec); 00246 00251 void sort_largest_index(std::vector<size_t>& sort_index, size_t k, 00252 const VectorBase& invec); 00253 00259 double sum(const VectorBase&); 00260 00272 std::ostream& operator<<(std::ostream& s, const VectorBase& v); 00273 00274 }}} // of namespace utility, yat, and theplu 00275 00276 #endif