laindex.h

Go to the documentation of this file.
00001 // -*-C++-*- 
00002 
00003 // Copyright (C) 2004 
00004 // Christian Stimming <stimming@tuhh.de>
00005 
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public License as
00008 // published by the Free Software Foundation; either version 2, or (at
00009 // your option) any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU Lesser General Public License for more details.
00015 
00016 // You should have received a copy of the GNU Lesser General Public License along
00017 // with this library; see the file COPYING.  If not, write to the Free
00018 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00019 // USA.
00020 
00021 //      LAPACK++ (V. 1.1)
00022 //      (C) 1992-1996 All Rights Reserved.
00023 
00028 #ifndef _LA_INDEX_H_
00029 #define _LA_INDEX_H_
00030 
00031 #include <iostream>
00032 #include "arch.h"
00033 
00043 class DLLIMPORT LaIndex
00044 {
00045    private:
00046       friend class LaGenMatDouble;
00047       friend class LaGenMatFloat;
00048       friend class LaGenMatInt;
00049       friend class LaGenMatLongInt;
00050       friend class LaGenMatComplex;
00051       int start_;
00052       int inc_;
00053       int end_;
00054    public:
00065       inline LaIndex()
00066          : start_(0)
00067          , inc_(0)
00068          , end_(0)
00069       {}
00070       
00076       inline LaIndex(int start) 
00077          : start_(start)
00078          , inc_(1)
00079          , end_(start)
00080       {}
00081 
00091       LaIndex(int start, int end);
00092 
00112       LaIndex(int start, int end, int increment);
00113 
00115       inline LaIndex(const LaIndex &s)
00116          : start_(s.start_)
00117          , inc_(s.inc_)
00118          , end_(s.end_)
00119       {}
00120 
00121    protected:
00122       // must have multply defined start(), inc() and end() member
00123       // functions for both const and non-const objects because
00124       // compiler complains in LaVector*.h, for example, about
00125       // assignment to const member.  (LaVector*.h line 112, 113,
00126       // 114) FIXME: Probably we should return by-value, not
00127       // by-reference!
00132       inline int& start() { return start_;}
00136       inline int& inc() { return inc_;}
00142       inline int& end() { return end_;}
00143    public:
00144 
00147       inline int start() const { return start_;}
00148 
00150       inline int inc() const { return inc_;}
00151 
00160       inline int end() const { return end_;}
00161 
00164       inline int length() const { return ((end()-start())/inc() + 1);}
00165 
00168       inline bool null() const { return (start() == 0 && 
00169                                          inc() == 0 && end() == 0);}
00170 
00171    protected:
00184       inline LaIndex& operator()(int start, int end){
00185          start_=start; inc_=1; end_=end; return *this;}
00186    public:
00187 
00197       inline LaIndex& set(int start, int end) {
00198          start_=start; inc_=1; end_=end; return *this;}
00199 
00221       LaIndex& set(int start, int end, int increment);
00222 
00227       inline LaIndex& operator+(int i) {
00228          start_+=i; end_+=i; return *this;}
00229 
00231       inline LaIndex& operator=(const LaIndex& i) {
00232          start_=i.start_; inc_=i.inc_; end_=i.end_; 
00233          return *this;}
00234 
00236       inline bool operator==(const LaIndex& s) {
00237          return start_ == s.start_ && inc_ == s.inc_ && end_ == s.end_;
00238       }
00240       inline bool operator!=(const LaIndex& s) {
00241          return !operator==(s);
00242       }
00243 };
00244 
00245 inline std::ostream& operator<<(std::ostream& s, const LaIndex& i)
00246 {
00247     s << "(" << i.start() << ":" << i.inc() << ":" << i.end() << ")";
00248 
00249     return s;
00250 }
00251 
00252 #endif  
00253 //  LA_INDEX_H_
00254 

Generated on Sat Jul 14 11:40:36 2007 for Lapack++ by  doxygen 1.5.0