Lapack++
|
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_COMPLEX_H_ 00029 #define _LA_VECTOR_COMPLEX_H_ 00030 00031 #include "lafnames.h" 00032 #include LA_GEN_MAT_COMPLEX_H 00033 00034 00051 class LaVectorComplex: public LaGenMatComplex 00052 { 00053 public: 00054 00058 LaVectorComplex(); 00059 00061 LaVectorComplex(int n); 00062 00065 LaVectorComplex(int m, int n); 00066 00069 LaVectorComplex(COMPLEX* v, int n); 00070 00074 LaVectorComplex(COMPLEX*, int m, int n); 00075 00079 LaVectorComplex(const LaGenMatComplex&); 00081 00082 00086 inline int size() const; 00087 00093 inline int inc() const; 00094 00099 inline int start() const; 00100 00105 inline int end() const; 00106 00111 inline LaIndex index() const; 00113 00129 inline COMPLEX& operator()(int i); 00130 00144 inline const COMPLEX& operator()(int i) const ; 00145 00157 inline LaVectorComplex operator()(const LaIndex& i); 00158 00170 inline LaVectorComplex operator()(const LaIndex& i) const; 00172 00179 inline LaVectorComplex& operator=(COMPLEX s); 00180 00181 // CS: addition 00186 inline LaVectorComplex& operator=(LaComplex s); 00187 00192 inline LaVectorComplex& operator=(double s); 00193 // CS: end 00194 00202 inline LaVectorComplex& operator=(const LaGenMatComplex& s); 00203 00204 00213 inline LaVectorComplex& inject(const LaGenMatComplex &s); 00214 00219 inline LaVectorComplex& copy(const LaGenMatComplex &s); 00220 00228 inline LaVectorComplex& ref(const LaGenMatComplex &s); 00230 }; 00231 00232 // NOTE: we default to column vectors, since matrices are column 00233 // oriented. 00234 00235 inline LaVectorComplex::LaVectorComplex() : LaGenMatComplex(0, 1) {} 00236 inline LaVectorComplex::LaVectorComplex(int i) : LaGenMatComplex(i, 1) {} 00237 00238 // NOTE: one shouldn't be using this method to initalize, but 00239 // it is here so that the constructor can be overloaded with 00240 // a runtime test. 00241 // 00242 inline LaVectorComplex::LaVectorComplex(int m, int n) : LaGenMatComplex(m, n) 00243 { 00244 assert(n == 1 || m == 1); 00245 } 00246 00247 inline LaVectorComplex::LaVectorComplex(COMPLEX *d, int m) : 00248 LaGenMatComplex(d, m, 1) {} 00249 00250 inline LaVectorComplex::LaVectorComplex(COMPLEX *d, int m, int n) : 00251 LaGenMatComplex(d, m, n) {} 00252 00253 inline LaVectorComplex::LaVectorComplex(const LaGenMatComplex& G) 00254 { 00255 assert(G.size(0) == 1 || G.size(1) == 1); 00256 00257 (*this).ref(G); 00258 } 00259 00260 //note that vectors can be either stored columnwise, or row-wise 00261 00262 // this will handle the 0x0 case as well. 00263 00264 inline int LaVectorComplex::size() const 00265 { 00266 return LaGenMatComplex::size(0) * LaGenMatComplex::size(1); 00267 } 00268 00269 inline COMPLEX& LaVectorComplex::operator()(int i) 00270 { 00271 if (LaGenMatComplex::size(0) == 1 ) 00272 return LaGenMatComplex::operator()(0, i); 00273 else 00274 return LaGenMatComplex::operator()(i, 0); 00275 } 00276 00277 inline const COMPLEX& LaVectorComplex::operator()(int i) const 00278 { 00279 if (LaGenMatComplex::size(0) == 1 ) 00280 return LaGenMatComplex::operator()(0, i); 00281 else 00282 return LaGenMatComplex::operator()(i, 0); 00283 } 00284 00285 inline LaVectorComplex LaVectorComplex::operator()(const LaIndex& I) 00286 { 00287 if (LaGenMatComplex::size(0) == 1) 00288 return LaGenMatComplex::operator()(LaIndex(0, 0), I).shallow_assign(); 00289 else 00290 return LaGenMatComplex::operator()(I, LaIndex(0, 0)).shallow_assign(); 00291 } 00292 00293 inline LaVectorComplex LaVectorComplex::operator()(const LaIndex& I) const 00294 { 00295 if (LaGenMatComplex::size(0) == 1) 00296 return LaGenMatComplex::operator()(LaIndex(0, 0), I).shallow_assign(); 00297 else 00298 return LaGenMatComplex::operator()(I, LaIndex(0, 0)).shallow_assign(); 00299 } 00300 00301 inline LaVectorComplex& LaVectorComplex::copy(const LaGenMatComplex &A) 00302 { 00303 assert(A.size(0) == 1 || A.size(1) == 1); //make sure rhs is a 00304 // a vector. 00305 LaGenMatComplex::copy(A); 00306 return *this; 00307 } 00308 00309 00310 inline LaVectorComplex& LaVectorComplex::operator=(const LaGenMatComplex &A) 00311 { 00312 return copy(A); // until lapackpp-2.5.0: inject(A); 00313 } 00314 00315 inline LaVectorComplex& LaVectorComplex::ref(const LaGenMatComplex &A) 00316 { 00317 assert(A.size(0) == 1 || A.size(1) == 1); 00318 LaGenMatComplex::ref(A); 00319 return *this; 00320 } 00321 00322 inline LaVectorComplex& LaVectorComplex::operator=(COMPLEX d) 00323 { 00324 LaGenMatComplex::operator=(d); 00325 return *this; 00326 } 00327 inline LaVectorComplex& LaVectorComplex::operator=(LaComplex d) 00328 { 00329 LaGenMatComplex::operator=(d.toCOMPLEX()); 00330 return *this; 00331 } 00332 inline LaVectorComplex& LaVectorComplex::operator=(double d) 00333 { 00334 LaGenMatComplex::operator=(LaComplex(d).toCOMPLEX()); 00335 return *this; 00336 } 00337 00338 inline LaVectorComplex& LaVectorComplex::inject(const LaGenMatComplex &A) 00339 { 00340 assert(A.size(0) == 1 || A.size(1) == 1); 00341 LaGenMatComplex::inject(A); 00342 return *this; 00343 } 00344 00345 inline int LaVectorComplex::inc() const 00346 { 00347 if (LaGenMatComplex::size(1) == 1 ) 00348 return LaGenMatComplex::inc(0); 00349 else 00350 return LaGenMatComplex::inc(1) * LaGenMatComplex::gdim(0); 00351 // NOTE: This was changed on 2005-03-04 because without the dim[0] 00352 // this gives wrong results on non-unit-stride submatrix views. 00353 } 00354 00355 inline LaIndex LaVectorComplex::index() const 00356 { 00357 if (LaGenMatComplex::size(1) == 1 ) 00358 return LaGenMatComplex::index(0); 00359 else 00360 return LaGenMatComplex::index(1); 00361 } 00362 00363 inline int LaVectorComplex::start() const 00364 { 00365 if (LaGenMatComplex::size(1) == 1 ) 00366 return LaGenMatComplex::start(0); 00367 else 00368 return LaGenMatComplex::start(1); 00369 } 00370 00371 inline int LaVectorComplex::end() const 00372 { 00373 if (LaGenMatComplex::size(1) == 1 ) 00374 return LaGenMatComplex::end(0); 00375 else 00376 return LaGenMatComplex::end(1); 00377 } 00378 00379 #endif 00380 // _LA_VECTOR_COMPLEX_H_