lavi.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_VECTOR_INT_H_
00029 #define _LA_VECTOR_INT_H_
00030 
00031 #include "lafnames.h"
00032 
00033 #include LA_GEN_MAT_INT_H
00034 
00041 class LaVectorInt: public LaGenMatInt
00042 {
00043  public:
00044 
00048   inline LaVectorInt();
00049 
00051   inline LaVectorInt(int n);
00052 
00055   inline LaVectorInt(int m, int n);  
00056 
00059   inline LaVectorInt(int* v, int n);
00060 
00064   inline LaVectorInt(int* v, int m, int n);
00065 
00069   inline LaVectorInt(const LaGenMatInt&);
00070 
00073   LaVectorInt (const LaIndex& ind);
00075 
00076 
00080   inline int size() const;
00081 
00087   inline int inc() const;
00088 
00093   inline int start() const;
00094 
00099   inline int end() const;
00100 
00105   inline LaIndex index() const;
00107 
00123   inline int& operator()(int i);
00124 
00138   inline int& operator()(int i) const ;
00139 
00151   inline LaVectorInt operator()(const LaIndex&);
00153 
00160   inline LaVectorInt& operator=(int);
00161 
00169   inline LaVectorInt& operator=(const LaGenMatInt&);
00170 
00171 
00180   inline LaVectorInt& inject(const LaGenMatInt &);
00181 
00186   inline LaVectorInt& copy(const LaGenMatInt &);
00187 
00195   inline LaVectorInt& ref(const LaGenMatInt &);
00197     
00198 };
00199 
00200 // NOTE: we default to column vectors, since matrices are column
00201 //  oriented.
00202 
00203 inline LaVectorInt::LaVectorInt() : LaGenMatInt(0,1) {}
00204 inline LaVectorInt::LaVectorInt(int i) : LaGenMatInt(i,1) {}
00205 
00206 // NOTE: one shouldn't be using this method to initalize, but
00207 // it is here so that the constructor can be overloaded with 
00208 // a runtime test.
00209 //
00210 inline LaVectorInt::LaVectorInt(int m, int n) : LaGenMatInt(m,n)
00211 {
00212   assert(n==1 || m==1);
00213 }
00214 
00215 inline LaVectorInt::LaVectorInt(int *d, int n) : 
00216   LaGenMatInt(d,n,1) {}
00217 
00218 inline LaVectorInt::LaVectorInt(int *d, int n, int m) : 
00219   LaGenMatInt(d,n,m) {}
00220 
00221 inline LaVectorInt::LaVectorInt(const LaGenMatInt &G) 
00222 {
00223   assert(G.size(0)==1 || G.size(1)==1);
00224 
00225   (*this).ref(G);
00226 }
00227 
00228 
00229 //note that vectors can be either stored columnwise, or row-wise
00230 
00231 // this will handle the 0x0 case as well.
00232 
00233 inline int LaVectorInt::size() const 
00234 { return LaGenMatInt::size(0)*LaGenMatInt::size(1); }
00235 
00236 inline int& LaVectorInt::operator()(int i)
00237 { if (LaGenMatInt::size(0)==1 )
00238   return LaGenMatInt::operator()(0,i);
00239  else
00240    return LaGenMatInt::operator()(i,0);
00241 }
00242 
00243 inline int& LaVectorInt::operator()(int i) const
00244 { if (LaGenMatInt::size(0)==1 )
00245   return LaGenMatInt::operator()(0,i);
00246  else
00247    return LaGenMatInt::operator()(i,0);
00248 }
00249 
00250 inline LaVectorInt LaVectorInt::operator()(const LaIndex& I)
00251 { if (LaGenMatInt::size(0)==1)
00252   return LaGenMatInt::operator()(LaIndex(0,0),I).shallow_assign(); 
00253  else
00254    return LaGenMatInt::operator()(I,LaIndex(0,0)).shallow_assign(); 
00255 }
00256 
00257 
00258 inline LaVectorInt& LaVectorInt::copy(const LaGenMatInt &A)
00259 {
00260   assert(A.size(0) == 1 || A.size(1) == 1);   //make sure rhs is a
00261   // a vector.
00262   LaGenMatInt::copy(A);
00263   return *this;
00264 }
00265 
00266 inline LaVectorInt& LaVectorInt::operator=(const  LaGenMatInt &A)
00267 {
00268   return inject(A);
00269 }
00270 
00271 inline LaVectorInt& LaVectorInt::ref(const LaGenMatInt &A)
00272 {
00273   assert(A.size(0) == 1 || A.size(1) == 1);
00274   LaGenMatInt::ref(A);
00275   return *this;
00276 }
00277 
00278 inline LaVectorInt& LaVectorInt::operator=(int d)
00279 {
00280   LaGenMatInt::operator=(d);
00281   return *this;
00282 }
00283 
00284 inline LaVectorInt& LaVectorInt::inject(const LaGenMatInt &A)
00285 {
00286   assert(A.size(0) == 1 || A.size(1) == 1);
00287   LaGenMatInt::inject(A);
00288   return *this;
00289 }
00290     
00291 inline int LaVectorInt::inc() const
00292 {
00293    if (LaGenMatInt::size(1)==1 )
00294       return LaGenMatInt::inc(0);
00295    else
00296       return LaGenMatInt::inc(1)*LaGenMatInt::gdim(0);
00297    // NOTE: This was changed on 2005-03-04 because without the dim[0]
00298    // this gives wrong results on non-unit-stride submatrix views.
00299 }
00300 
00301 inline LaIndex LaVectorInt::index() const
00302 {
00303   if (LaGenMatInt::size(1)==1 )
00304     return LaGenMatInt::index(0);
00305   else
00306     return LaGenMatInt::index(1);
00307 }
00308 
00309 inline int LaVectorInt::start() const
00310 {
00311   if (LaGenMatInt::size(1)==1 )
00312     return LaGenMatInt::start(0);
00313   else
00314     return LaGenMatInt::start(1);
00315 }
00316 
00317 inline int LaVectorInt::end() const
00318 {
00319   if (LaGenMatInt::size(1)==1 )
00320     return LaGenMatInt::end(0);
00321   else
00322     return LaGenMatInt::end(1);
00323 }
00324 
00325 #endif 
00326 // _LA_VECTOR_INT_H_

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