Lapack++
lavli.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 
00029 #ifndef _LA_VECTOR_LONG_INT_H_
00030 #define _LA_VECTOR_LONG_INT_H_
00031 
00032 #include "lafnames.h"
00033 
00034 #include LA_GEN_MAT_LONG_INT_H
00035 
00036 
00043 class LaVectorLongInt: public LaGenMatLongInt
00044 {
00045 public:
00046 
00050     inline LaVectorLongInt();
00051 
00053     inline LaVectorLongInt(int n);
00054 
00057     inline LaVectorLongInt(int m, int n);
00058 
00061     inline LaVectorLongInt(value_type* v, int n);
00062 
00066     inline LaVectorLongInt(value_type* v, int m, int n);
00067 
00071     inline LaVectorLongInt(const LaGenMatLongInt&);
00072 
00075     LaVectorLongInt (const LaIndex& ind);
00077 
00078 
00082     inline int size() const;
00083 
00089     inline int inc() const;
00090 
00095     inline int start() const;
00096 
00101     inline int end() const;
00102 
00107     inline LaIndex index() const;
00109 
00125     inline value_type& operator()(int i);
00126 
00140     inline const value_type& operator()(int i) const ;
00141 
00153     inline LaVectorLongInt operator()(const LaIndex&);
00155 
00162     inline LaVectorLongInt& operator=(value_type);
00163 
00171     inline LaVectorLongInt& operator=(const LaGenMatLongInt&);
00172 
00173 
00182     inline LaVectorLongInt& inject(const LaGenMatLongInt &);
00183 
00188     inline LaVectorLongInt& copy(const LaGenMatLongInt &);
00189 
00197     inline LaVectorLongInt& ref(const LaGenMatLongInt &);
00199 
00200 };
00201 
00202 // NOTE: we default to column vectors, since matrices are column
00203 //  oriented.
00204 
00205 inline LaVectorLongInt::LaVectorLongInt() : LaGenMatLongInt(0, 1) {}
00206 inline LaVectorLongInt::LaVectorLongInt(int i) : LaGenMatLongInt(i, 1) {}
00207 
00208 // NOTE: one shouldn't be using this method to initalize, but
00209 // it is here so that the constructor can be overloaded with
00210 // a runtime test.
00211 //
00212 inline LaVectorLongInt::LaVectorLongInt(int m, int n) : LaGenMatLongInt(m, n)
00213 {
00214     assert(n == 1 || m == 1);
00215 }
00216 
00217 inline LaVectorLongInt::LaVectorLongInt(value_type *d, int m) :
00218     LaGenMatLongInt(d, m, 1) {}
00219 
00220 #if 0
00221 inline LaVectorLongInt::LaVectorLongInt(value_type *d, int m, int n) :
00222     LaGenMatLongInt(d, m, n) {}
00223 #endif
00224 
00225 inline LaVectorLongInt::LaVectorLongInt(const LaGenMatLongInt& G) :
00226     LaGenMatLongInt(G)
00227 {
00228     assert(G.size(0) == 1 || G.size(1) == 1);
00229 
00230 }
00231 
00232 //note that vectors can be either stored columnwise, or row-wise
00233 
00234 // this will handle the 0x0 case as well.
00235 
00236 inline int LaVectorLongInt::size() const
00237 {
00238     return LaGenMatLongInt::size(0) * LaGenMatLongInt::size(1);
00239 }
00240 
00241 inline LaGenMatLongInt::value_type& LaVectorLongInt::operator()(int i)
00242 {
00243     if (LaGenMatLongInt::size(0) == 1 )
00244         return LaGenMatLongInt::operator()(0, i);
00245     else
00246         return LaGenMatLongInt::operator()(i, 0);
00247 }
00248 
00249 inline const LaGenMatLongInt::value_type& LaVectorLongInt::operator()(int i) const
00250 {
00251     if (LaGenMatLongInt::size(0) == 1 )
00252         return LaGenMatLongInt::operator()(0, i);
00253     else
00254         return LaGenMatLongInt::operator()(i, 0);
00255 }
00256 
00257 inline LaVectorLongInt LaVectorLongInt::operator()(const LaIndex& I)
00258 {
00259     if (LaGenMatLongInt::size(0) == 1)
00260         return LaGenMatLongInt::operator()(LaIndex(0, 0), I).shallow_assign();
00261     else
00262         return LaGenMatLongInt::operator()(I, LaIndex(0, 0)).shallow_assign();
00263 }
00264 
00265 
00266 inline LaVectorLongInt& LaVectorLongInt::copy(const LaGenMatLongInt &A)
00267 {
00268     assert(A.size(0) == 1 || A.size(1) == 1);   //make sure rhs is a
00269     // a vector.
00270     LaGenMatLongInt::copy(A);
00271     return *this;
00272 }
00273 
00274 inline LaVectorLongInt& LaVectorLongInt::operator=(const LaGenMatLongInt &A)
00275 {
00276     return copy(A);
00277 }
00278 
00279 inline LaVectorLongInt& LaVectorLongInt::ref(const LaGenMatLongInt &A)
00280 {
00281     assert(A.size(0) == 1 || A.size(1) == 1);
00282     LaGenMatLongInt::ref(A);
00283     return *this;
00284 }
00285 
00286 inline LaVectorLongInt& LaVectorLongInt::operator=(value_type d)
00287 {
00288     LaGenMatLongInt::operator=(d);
00289     return *this;
00290 }
00291 
00292 inline LaVectorLongInt& LaVectorLongInt::inject(const LaGenMatLongInt &A)
00293 {
00294     assert(A.size(0) == 1 || A.size(1) == 1);
00295     LaGenMatLongInt::inject(A);
00296     return *this;
00297 }
00298 
00299 inline int LaVectorLongInt::inc() const
00300 {
00301     if (LaGenMatLongInt::size(1) == 1 )
00302         return LaGenMatLongInt::inc(0);
00303     else
00304         return LaGenMatLongInt::inc(1) * LaGenMatLongInt::gdim(0);
00305     // NOTE: This was changed on 2005-03-04 because without the dim[0]
00306     // this gives wrong results on non-unit-stride submatrix views.
00307 }
00308 
00309 inline LaIndex LaVectorLongInt::index() const
00310 {
00311     if (LaGenMatLongInt::size(1) == 1 )
00312         return LaGenMatLongInt::index(0);
00313     else
00314         return LaGenMatLongInt::index(1);
00315 }
00316 
00317 inline int LaVectorLongInt::start() const
00318 {
00319     if (LaGenMatLongInt::size(1) == 1 )
00320         return LaGenMatLongInt::start(0);
00321     else
00322         return LaGenMatLongInt::start(1);
00323 }
00324 
00325 inline int LaVectorLongInt::end() const
00326 {
00327     if (LaGenMatLongInt::size(1) == 1 )
00328         return LaGenMatLongInt::end(0);
00329     else
00330         return LaGenMatLongInt::end(1);
00331 }
00332 
00333 #endif
00334 // _LA_VECTOR_LONG_INT_H_