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(long int* v, int n);
00062 
00066       inline LaVectorLongInt(long int* 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 long int& operator()(int i);
00126 
00140       inline const long int& operator()(int i) const ;
00141 
00153       inline LaVectorLongInt operator()(const LaIndex&);
00155 
00162       inline LaVectorLongInt& operator=(long int);
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(long int *d, int m) : 
00218    LaGenMatLongInt(d,m,1) {}
00219 
00220 #if 0
00221 inline LaVectorLongInt::LaVectorLongInt(long int *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 { return LaGenMatLongInt::size(0)*LaGenMatLongInt::size(1); }
00238 
00239 inline long int& LaVectorLongInt::operator()(int i)
00240 { if (LaGenMatLongInt::size(0)==1 )
00241    return LaGenMatLongInt::operator()(0,i);
00242 else
00243    return LaGenMatLongInt::operator()(i,0);
00244 }
00245 
00246 inline const long int& LaVectorLongInt::operator()(int i) const
00247 { if (LaGenMatLongInt::size(0)==1 )
00248    return LaGenMatLongInt::operator()(0,i);
00249 else
00250    return LaGenMatLongInt::operator()(i,0);
00251 }
00252 
00253 inline LaVectorLongInt LaVectorLongInt::operator()(const LaIndex& I)
00254 { if (LaGenMatLongInt::size(0)==1)
00255    return LaGenMatLongInt::operator()(LaIndex(0,0),I).shallow_assign(); 
00256 else
00257    return LaGenMatLongInt::operator()(I,LaIndex(0,0)).shallow_assign(); 
00258 }
00259 
00260 
00261 inline LaVectorLongInt& LaVectorLongInt::copy(const LaGenMatLongInt &A)
00262 {
00263    assert(A.size(0) == 1 || A.size(1) == 1);   //make sure rhs is a
00264    // a vector.
00265    LaGenMatLongInt::copy(A);
00266    return *this;
00267 }
00268 
00269 inline LaVectorLongInt& LaVectorLongInt::operator=(const LaGenMatLongInt &A)
00270 {
00271    return copy(A);
00272 }
00273 
00274 inline LaVectorLongInt& LaVectorLongInt::ref(const LaGenMatLongInt &A)
00275 {
00276    assert(A.size(0) == 1 || A.size(1) == 1);
00277    LaGenMatLongInt::ref(A);
00278    return *this;
00279 }
00280 
00281 inline LaVectorLongInt& LaVectorLongInt::operator=(long int d)
00282 {
00283    LaGenMatLongInt::operator=(d);
00284    return *this;
00285 }
00286 
00287 inline LaVectorLongInt& LaVectorLongInt::inject(const LaGenMatLongInt &A)
00288 {
00289    assert(A.size(0) == 1 || A.size(1) == 1);
00290    LaGenMatLongInt::inject(A);
00291    return *this;
00292 }
00293     
00294 inline int LaVectorLongInt::inc() const
00295 {
00296    if (LaGenMatLongInt::size(1)==1 )
00297       return LaGenMatLongInt::inc(0);
00298    else
00299       return LaGenMatLongInt::inc(1)*LaGenMatLongInt::gdim(0);
00300    // NOTE: This was changed on 2005-03-04 because without the dim[0]
00301    // this gives wrong results on non-unit-stride submatrix views.
00302 }
00303 
00304 inline LaIndex LaVectorLongInt::index() const
00305 {
00306    if (LaGenMatLongInt::size(1)==1 )
00307       return LaGenMatLongInt::index(0);
00308    else
00309       return LaGenMatLongInt::index(1);
00310 }
00311 
00312 inline int LaVectorLongInt::start() const
00313 {
00314    if (LaGenMatLongInt::size(1)==1 )
00315       return LaGenMatLongInt::start(0);
00316    else
00317       return LaGenMatLongInt::start(1);
00318 }
00319 
00320 inline int LaVectorLongInt::end() const
00321 {
00322    if (LaGenMatLongInt::size(1)==1 )
00323       return LaGenMatLongInt::end(0);
00324    else
00325       return LaGenMatLongInt::end(1);
00326 }
00327 
00328 #endif 
00329 // _LA_VECTOR_LONG_INT_H_

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