C-XSC - A C++ Class Library for Extended Scientific Computing
2.5.4
|
00001 /* 00002 ** CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4) 00003 ** 00004 ** Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik, 00005 ** Universitaet Karlsruhe, Germany 00006 ** (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie 00007 ** Universitaet Wuppertal, Germany 00008 ** 00009 ** This library is free software; you can redistribute it and/or 00010 ** modify it under the terms of the GNU Library General Public 00011 ** License as published by the Free Software Foundation; either 00012 ** version 2 of the License, or (at your option) any later version. 00013 ** 00014 ** This library is distributed in the hope that it will be useful, 00015 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 ** Library General Public License for more details. 00018 ** 00019 ** You should have received a copy of the GNU Library General Public 00020 ** License along with this library; if not, write to the Free 00021 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 */ 00023 00024 /* CVS $Id: cvector.inl,v 1.28 2014/01/30 17:23:44 cxsc Exp $ */ 00025 00026 #ifndef _CXSC_CVECTOR_INL_INCLUDED 00027 #define _CXSC_CVECTOR_INL_INCLUDED 00028 00029 namespace cxsc { 00030 00031 INLINE cvector::cvector () throw():dat(NULL),l(1),u(0),size(0) 00032 { 00033 } 00034 00035 INLINE cvector::cvector(const int &i) throw():l(1),u(i),size(i) 00036 { 00037 dat=new complex[i]; 00038 } 00039 00040 #ifdef OLD_CXSC 00041 INLINE cvector::cvector(const class index &i) throw():l(1),u(i._int()),size(i._int()) 00042 { 00043 dat=new complex[i._int()]; 00044 } 00045 #endif 00046 00047 INLINE cvector::cvector(const int &i1,const int &i2) 00048 #if(CXSC_INDEX_CHECK) 00049 throw(ERROR_CVECTOR_WRONG_BOUNDARIES,ERROR_CVECTOR_NO_MORE_MEMORY):l(i1),u(i2),size(i2-i1+1) 00050 #else 00051 throw():l(i1),u(i2),size(i2-i1+1) 00052 #endif 00053 { 00054 #if(CXSC_INDEX_CHECK) 00055 if(i1>i2) cxscthrow(ERROR_CVECTOR_WRONG_BOUNDARIES("cvector::cvector(const int &i1,const int &i2)")); 00056 #endif 00057 dat=new complex[size]; 00058 } 00059 00060 INLINE cvector::cvector(const cvector_slice &rs) throw():l(rs.start),u(rs.end),size(rs.end-rs.start+1) 00061 { 00062 dat=new complex[size]; 00063 for(int i=0, j=l-rs.l;i<size;i++,j++) 00064 dat[i]=rs.dat[j]; 00065 } 00066 00067 INLINE cvector::cvector(const cvector &v) throw():l(v.l),u(v.u),size(v.size) 00068 { 00069 dat=new complex[size]; 00070 for (int i=0;i<size;i++) 00071 dat[i]=v.dat[i]; 00072 } 00073 00074 INLINE cvector::cvector(const complex &r) throw():l(1),u(1),size(1) 00075 { 00076 dat=new complex[1]; 00077 *dat=r; 00078 } 00079 00080 INLINE cvector::cvector(const rvector_slice &rs) throw():l(rs.start),u(rs.end),size(rs.end-rs.start+1) 00081 { 00082 dat=new complex[size]; 00083 for(int i=0, j=l-rs.l;i<size;i++,j++) 00084 dat[i]=rs.dat[j]; 00085 } 00086 00087 INLINE cvector::cvector(const rvector &v) throw():l(v.l),u(v.u),size(v.size) 00088 { 00089 dat=new complex[size]; 00090 for (int i=0;i<size;i++) 00091 dat[i]=v.dat[i]; 00092 } 00093 00094 INLINE cvector::cvector(const real &r) throw():l(1),u(1),size(1) 00095 { 00096 dat=new complex[1]; 00097 *dat=r; 00098 } 00099 00100 INLINE complex & cvector_slice::operator [](const int &i) const 00101 #if(CXSC_INDEX_CHECK) 00102 throw(ERROR_CVECTOR_ELEMENT_NOT_IN_VEC) 00103 #else 00104 throw() 00105 #endif 00106 { 00107 #if(CXSC_INDEX_CHECK) 00108 if(i<start||i>end) cxscthrow(ERROR_CVECTOR_ELEMENT_NOT_IN_VEC("complex & cvector_slice::operator [](const int &i) const")); 00109 #endif 00110 return dat[i-l]; 00111 } 00112 00113 INLINE complex & cvector_slice::operator [](const int &i) 00114 #if(CXSC_INDEX_CHECK) 00115 throw(ERROR_CVECTOR_ELEMENT_NOT_IN_VEC) 00116 #else 00117 throw() 00118 #endif 00119 { 00120 #if(CXSC_INDEX_CHECK) 00121 if(i<start||i>end) cxscthrow(ERROR_CVECTOR_ELEMENT_NOT_IN_VEC("complex & cvector_slice::operator [](const int &i)")); 00122 #endif 00123 return dat[i-l]; 00124 } 00125 00126 INLINE complex & cvector::operator [](const int &i) const 00127 #if(CXSC_INDEX_CHECK) 00128 throw(ERROR_CVECTOR_ELEMENT_NOT_IN_VEC) 00129 #else 00130 throw() 00131 #endif 00132 { 00133 #if(CXSC_INDEX_CHECK) 00134 if(i<l||i>u) cxscthrow(ERROR_CVECTOR_ELEMENT_NOT_IN_VEC("complex & cvector::operator [](const int &i) const")); 00135 #endif 00136 return dat[i-l]; 00137 } 00138 00139 INLINE complex & cvector::operator [](const int &i) 00140 #if(CXSC_INDEX_CHECK) 00141 throw(ERROR_CVECTOR_ELEMENT_NOT_IN_VEC) 00142 #else 00143 throw() 00144 #endif 00145 { 00146 #if(CXSC_INDEX_CHECK) 00147 if(i<l||i>u) cxscthrow(ERROR_CVECTOR_ELEMENT_NOT_IN_VEC("complex & cvector::operator [](const int &i)")); 00148 #endif 00149 return dat[i-l]; 00150 } 00151 00152 00159 INLINE cvector_slice cvector::operator ()(const int &i) 00160 #if(CXSC_INDEX_CHECK) 00161 throw(ERROR_CVECTOR_SUB_ARRAY_TOO_BIG) 00162 #else 00163 throw() 00164 #endif 00165 { 00166 #if(CXSC_INDEX_CHECK) 00167 if(1<l||i>u) cxscthrow(ERROR_CVECTOR_SUB_ARRAY_TOO_BIG("cvector_slice cvector::operator ()(const int &i)")); 00168 #endif 00169 return cvector_slice(*this,1,i); 00170 } 00171 00179 INLINE cvector_slice cvector::operator ()(const int &i1,const int &i2) 00180 #if(CXSC_INDEX_CHECK) 00181 throw(ERROR_CVECTOR_SUB_ARRAY_TOO_BIG) 00182 #else 00183 throw() 00184 #endif 00185 { 00186 #if(CXSC_INDEX_CHECK) 00187 if(i1<l||i2>u) cxscthrow(ERROR_CVECTOR_SUB_ARRAY_TOO_BIG("cvector_slice cvector::operator ()(const int &i1,const int &i2)")); 00188 #endif 00189 return cvector_slice(*this,i1,i2); 00190 } 00191 00192 INLINE cvector_slice cvector_slice::operator ()(const int &i) 00193 #if(CXSC_INDEX_CHECK) 00194 throw(ERROR_CVECTOR_SUB_ARRAY_TOO_BIG) 00195 #else 00196 throw() 00197 #endif 00198 { 00199 #if(CXSC_INDEX_CHECK) 00200 if(1<start||i>end) cxscthrow(ERROR_CVECTOR_SUB_ARRAY_TOO_BIG("cvector_slice cvector_slice::operator ()(const int &i)")); 00201 #endif 00202 return cvector_slice(*this,1,i); 00203 } 00204 00205 INLINE cvector_slice cvector_slice::operator ()(const int &i1,const int &i2) 00206 #if(CXSC_INDEX_CHECK) 00207 throw(ERROR_CVECTOR_SUB_ARRAY_TOO_BIG) 00208 #else 00209 throw() 00210 #endif 00211 { 00212 #if(CXSC_INDEX_CHECK) 00213 if(i1<start||i2>end) cxscthrow(ERROR_CVECTOR_SUB_ARRAY_TOO_BIG("cvector_slice cvector_slice::operator ()(const int &i1,const int &i2)")); 00214 #endif 00215 return cvector_slice(*this,i1,i2); 00216 } 00217 00218 INLINE complex::complex(const cvector &rv) 00219 #if(CXSC_INDEX_CHECK) 00220 throw(ERROR_CVECTOR_TYPE_CAST_OF_THICK_OBJ,ERROR_CVECTOR_USE_OF_UNINITIALIZED_OBJ) 00221 #else 00222 throw() 00223 #endif 00224 { 00225 #if(CXSC_INDEX_CHECK) 00226 if(rv.size>1) cxscthrow(ERROR_CVECTOR_TYPE_CAST_OF_THICK_OBJ("complex::complex(const cvector &rv)")); 00227 else if(rv.size<1) cxscthrow(ERROR_CVECTOR_USE_OF_UNINITIALIZED_OBJ("complex::complex(const cvector &rv)")); 00228 #endif 00229 *this=rv.dat[0]; 00230 } 00231 00232 INLINE complex::complex(const cvector_slice &sl) 00233 #if(CXSC_INDEX_CHECK) 00234 throw(ERROR_CVECTOR_TYPE_CAST_OF_THICK_OBJ,ERROR_CVECTOR_USE_OF_UNINITIALIZED_OBJ) 00235 #else 00236 throw() 00237 #endif 00238 { 00239 #if(CXSC_INDEX_CHECK) 00240 if(sl.size>1) cxscthrow(ERROR_CVECTOR_TYPE_CAST_OF_THICK_OBJ("complex::complex(const cvector_slice &sl)")); 00241 else if(sl.size<1) cxscthrow(ERROR_CVECTOR_USE_OF_UNINITIALIZED_OBJ("complex::complex(const cvector_slice &sl)")); 00242 #endif 00243 *this=sl.dat[sl.start-sl.l]; 00244 } 00245 00251 INLINE cvector _cvector(const complex &r) throw() { return cvector(r); } 00257 INLINE cvector _cvector(const real &r) throw() { return cvector(r); } 00263 INLINE cvector _cvector(const rvector_slice &rs) throw() { return cvector(rs); } 00269 INLINE cvector _cvector(const rvector &rs) throw() { return cvector(rs); } 00275 INLINE cvector _cvector(const rmatrix_subv &rs) throw() { return cvector(rs); } 00276 INLINE cvector &cvector::operator =(const cvector &rv) throw() { return _vvassign<cvector,cvector,complex>(*this,rv); } 00277 INLINE cvector &cvector::operator =(const complex &r) throw() { return _vsassign<cvector,complex>(*this,r); } 00278 INLINE cvector &cvector::operator =(const rvector &rv) throw() { return _vvassign<cvector,rvector,complex>(*this,rv); } 00279 INLINE cvector &cvector::operator =(const real &r) throw() { return _vsassign<cvector,real>(*this,r); } 00280 INLINE cvector::operator void*() throw() { return _vvoid(*this); } 00281 INLINE cvector_slice & cvector_slice::operator =(const cvector_slice &sl) 00282 #if(CXSC_INDEX_CHECK) 00283 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00284 #else 00285 throw() 00286 #endif 00287 { return _vsvsassign(*this,sl); } 00288 INLINE cvector_slice & cvector_slice::operator =(const cvector &rv) 00289 #if(CXSC_INDEX_CHECK) 00290 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00291 #else 00292 throw() 00293 #endif 00294 { return _vsvassign(*this,rv); } 00295 INLINE cvector_slice & cvector_slice::operator =(const complex &r) throw() { return _vssassign<cvector_slice,complex>(*this,r); } 00296 INLINE cvector_slice & cvector_slice::operator =(const cmatrix &m) 00297 #if(CXSC_INDEX_CHECK) 00298 throw(ERROR__OP_WITH_WRONG_DIM<cvector>,ERROR_CMATRIX_TYPE_CAST_OF_THICK_OBJ) 00299 #else 00300 throw() 00301 #endif 00302 { return _vsvassign(*this,cvector(m)); } 00303 INLINE cvector_slice & cvector_slice::operator =(const rvector_slice &sl) 00304 #if(CXSC_INDEX_CHECK) 00305 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00306 #else 00307 throw() 00308 #endif 00309 { return _vsvsassign(*this,sl); } 00310 INLINE cvector_slice & cvector_slice::operator =(const rvector &rv) 00311 #if(CXSC_INDEX_CHECK) 00312 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00313 #else 00314 throw() 00315 #endif 00316 { return _vsvassign(*this,rv); } 00317 INLINE cvector_slice & cvector_slice::operator =(const real &r) throw() { return _vssassign(*this,r); } 00318 INLINE cvector_slice::operator void*() throw() { return _vsvoid(*this); } 00319 00320 //======================================================================= 00321 //======================== Vector Functions ============================= 00322 00323 INLINE cvector &SetRe(cvector &iv,const rvector &rv) 00324 #if(CXSC_INDEX_CHECK) 00325 throw(ERROR_CMATRIX_OP_WITH_WRONG_DIM) 00326 #else 00327 throw() 00328 #endif 00329 { return iv;} // S.W. temp return _vvsetre(iv,rv); } 00330 INLINE cvector_slice &SetRe(cvector_slice &iv,const rvector &rv) 00331 #if(CXSC_INDEX_CHECK) 00332 throw(ERROR_CMATRIX_OP_WITH_WRONG_DIM) 00333 #else 00334 throw() 00335 #endif 00336 { return _vsvsetre(iv,rv); } 00337 INLINE cvector &SetRe(cvector &iv,const rvector_slice &rv) 00338 #if(CXSC_INDEX_CHECK) 00339 throw(ERROR_CMATRIX_OP_WITH_WRONG_DIM) 00340 #else 00341 throw() 00342 #endif 00343 { return _vvssetre(iv,rv); } 00344 INLINE cvector_slice &SetRe(cvector_slice &iv,const rvector_slice &rv) 00345 #if(CXSC_INDEX_CHECK) 00346 throw(ERROR_CMATRIX_OP_WITH_WRONG_DIM) 00347 #else 00348 throw() 00349 #endif 00350 { return _vsvssetre(iv,rv); } 00351 00352 INLINE cvector &SetIm(cvector &iv,const rvector &rv) 00353 #if(CXSC_INDEX_CHECK) 00354 throw(ERROR_CMATRIX_OP_WITH_WRONG_DIM) 00355 #else 00356 throw() 00357 #endif 00358 { return _vvsetim(iv,rv); } 00359 INLINE cvector_slice &SetIm(cvector_slice &iv,const rvector &rv) 00360 #if(CXSC_INDEX_CHECK) 00361 throw(ERROR_CMATRIX_OP_WITH_WRONG_DIM) 00362 #else 00363 throw() 00364 #endif 00365 { return _vsvsetim(iv,rv); } 00366 INLINE cvector &SetIm(cvector &iv,const rvector_slice &rv) 00367 #if(CXSC_INDEX_CHECK) 00368 throw(ERROR_CMATRIX_OP_WITH_WRONG_DIM) 00369 #else 00370 throw() 00371 #endif 00372 { return _vvssetim(iv,rv); } 00373 INLINE cvector_slice &SetIm(cvector_slice &iv,const rvector_slice &rv) 00374 #if(CXSC_INDEX_CHECK) 00375 throw(ERROR_CMATRIX_OP_WITH_WRONG_DIM) 00376 #else 00377 throw() 00378 #endif 00379 { return _vsvssetim(iv,rv); } 00380 00381 INLINE cvector &SetRe(cvector &iv,const real &r) throw() { return _vssetre(iv,r); } 00382 INLINE cvector &SetIm(cvector &iv,const real &r) throw() { return _vssetim(iv,r); } 00383 INLINE cvector_slice &SetRe(cvector_slice &iv,const real &r) throw() { return _vsssetre(iv,r); } 00384 INLINE cvector_slice &SetIm(cvector_slice &iv,const real &r) throw() { return _vsssetim(iv,r); } 00385 00386 INLINE void Resize(cvector &rv) throw() { _vresize(rv); } 00387 INLINE void Resize(cvector &rv, const int &len) 00388 #if(CXSC_INDEX_CHECK) 00389 throw(ERROR__WRONG_BOUNDARIES<cvector>) 00390 #else 00391 throw() 00392 #endif 00393 { _vresize<class cvector,class complex>(rv,len); } 00394 INLINE void Resize(cvector &rv, const int &lb, const int &ub) 00395 #if(CXSC_INDEX_CHECK) 00396 throw(ERROR__WRONG_BOUNDARIES<cvector>) 00397 #else 00398 throw() 00399 #endif 00400 { _vresize<class cvector,class complex>(rv,lb,ub); } 00401 00402 INLINE cvector conj(const cvector &rv) throw() { return _vconj<cvector>(rv); } 00403 INLINE cvector conj(const cvector_slice &sl) throw() { return _vsconj<cvector_slice,cvector>(sl); } 00404 00405 INLINE rvector abs(const cvector &rv) throw() { return _vabs<cvector,rvector>(rv); } 00406 INLINE rvector abs(const cvector_slice &sl) throw() { return _vsabs<cvector_slice,rvector>(sl); } 00407 INLINE rvector Im(const cvector &v) throw() { return _vim<cvector,rvector>(v); } 00408 INLINE rvector Im(const cvector_slice &v) throw() { return _vsim<cvector_slice,rvector>(v); } 00409 INLINE rvector Re(const cvector &v) throw() { return _vre<cvector,rvector>(v); } 00410 INLINE rvector Re(const cvector_slice &v) throw() { return _vsre<cvector_slice,rvector>(v); } 00411 INLINE bool operator !(const cvector &rv) throw() { return _vnot(rv); } 00412 INLINE bool operator !(const cvector_slice &sl) throw() { return _vsnot(sl); } 00413 00414 //======================= Vector / Scalar =============================== 00415 00416 //----------------------------- complex --------------------------- 00417 00418 INLINE cvector operator *(const cvector &rv, const complex &s) throw() { return _vsmult<cvector,complex,cvector>(rv,s); } 00419 INLINE cvector operator *(const cvector_slice &sl, const complex &s) throw() { return _vssmult<cvector_slice,complex,cvector>(sl,s); } 00420 INLINE cvector operator *(const complex &s, const cvector &rv) throw() { return _vsmult<cvector,complex,cvector>(rv,s); } 00421 INLINE cvector operator *(const complex &s, const cvector_slice &sl) throw() { return _vssmult<cvector_slice,complex,cvector>(sl,s); } 00422 INLINE cvector &operator *=(cvector &rv,const complex &r) throw() { return _vsmultassign(rv,r); } 00423 INLINE cvector_slice &cvector_slice::operator *=(const complex &r) throw() { return _vssmultassign(*this,r); } 00424 00425 INLINE cvector operator /(const cvector &rv, const complex &s) throw() { return _vsdiv<cvector,complex,cvector>(rv,s); } 00426 INLINE cvector operator /(const cvector_slice &sl, const complex &s) throw() { return _vssdiv<cvector_slice,complex,cvector>(sl,s); } 00427 INLINE cvector &operator /=(cvector &rv,const complex &r) throw() { return _vsdivassign(rv,r); } 00428 INLINE cvector_slice &cvector_slice::operator /=(const complex &r) throw() { return _vssdivassign(*this,r); } 00429 00430 //---------------------------- Real -------------------------------------- 00431 00432 INLINE cvector operator *(const cvector &rv, const real &s) throw() { return _vsmult<cvector,real,cvector>(rv,s); } 00433 INLINE cvector operator *(const cvector_slice &sl, const real &s) throw() { return _vssmult<cvector_slice,real,cvector>(sl,s); } 00434 INLINE cvector operator *(const real &s, const cvector &rv) throw() { return _vsmult<cvector,real,cvector>(rv,s); } 00435 INLINE cvector operator *(const real &s, const cvector_slice &sl) throw() { return _vssmult<cvector_slice,real,cvector>(sl,s); } 00436 INLINE cvector &operator *=(cvector &rv,const real &r) throw() { return _vsmultassign(rv,r); } 00437 INLINE cvector_slice &cvector_slice::operator *=(const real &r) throw() { return _vssmultassign(*this,r); } 00438 00439 INLINE cvector operator /(const cvector &rv, const real &s) throw() { return _vsdiv<cvector,real,cvector>(rv,s); } 00440 INLINE cvector operator /(const cvector_slice &sl, const real &s) throw() { return _vssdiv<cvector_slice,real,cvector>(sl,s); } 00441 INLINE cvector &operator /=(cvector &rv,const real &r) throw() { return _vsdivassign(rv,r); } 00442 INLINE cvector_slice &cvector_slice::operator /=(const real &r) throw() { return _vssdivassign(*this,r); } 00443 00444 INLINE cvector operator *(const rvector &rv, const complex &s) throw() { return _vsmult<rvector,complex,cvector>(rv,s); } 00445 INLINE cvector operator *(const rvector_slice &sl, const complex &s) throw() { return _vssmult<rvector_slice,complex,cvector>(sl,s); } 00446 INLINE cvector operator *(const complex &s, const rvector &rv) throw() { return _vsmult<rvector,complex,cvector>(rv,s); } 00447 INLINE cvector operator *(const complex &s, const rvector_slice &sl) throw() { return _vssmult<rvector_slice,complex,cvector>(sl,s); } 00448 00449 INLINE cvector operator /(const rvector &rv, const complex &s) throw() { return _vsdiv<rvector,complex,cvector>(rv,s); } 00450 INLINE cvector operator /(const rvector_slice &sl, const complex &s) throw() { return _vssdiv<rvector_slice,complex,cvector>(sl,s); } 00451 00452 //======================= Vector / Vector =============================== 00453 00454 00455 INLINE std::ostream &operator <<(std::ostream &s, const cvector &rv) throw() { return _vout(s,rv); } 00456 INLINE std::ostream &operator <<(std::ostream &o, const cvector_slice &sl) throw() { return _vsout(o,sl); } 00457 INLINE std::istream &operator >>(std::istream &s, cvector &rv) throw() { return _vin(s,rv); } 00458 INLINE std::istream &operator >>(std::istream &s, cvector_slice &rv) throw() { return _vsin(s,rv); } 00459 00460 //----------------------- complex / complex --------------------------- 00461 INLINE cvector & cvector::operator =(const cvector_slice &sl) throw() { return _vvsassign<cvector,cvector_slice,complex>(*this,sl); } 00462 00463 00464 00465 INLINE complex operator *(const cvector & rv1, const cvector &rv2) 00466 #if(CXSC_INDEX_CHECK) 00467 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00468 #else 00469 throw() 00470 #endif 00471 { return _vvcmult<cvector,cvector,complex>(rv1,rv2); } 00472 INLINE complex operator *(const cvector_slice &sl, const cvector &rv) 00473 #if(CXSC_INDEX_CHECK) 00474 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00475 #else 00476 throw() 00477 #endif 00478 { return _vsvcmult<cvector_slice,cvector,complex>(sl,rv); } 00479 INLINE complex operator *(const cvector &rv, const cvector_slice &sl) 00480 #if(CXSC_INDEX_CHECK) 00481 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00482 #else 00483 throw() 00484 #endif 00485 { return _vsvcmult<cvector_slice,cvector,complex>(sl,rv); } 00486 INLINE complex operator *(const cvector_slice & sl1, const cvector_slice &sl2) 00487 #if(CXSC_INDEX_CHECK) 00488 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00489 #else 00490 throw() 00491 #endif 00492 { return _vsvscmult<cvector_slice,cvector_slice,complex>(sl1,sl2); } 00493 00494 INLINE const cvector &operator +(const cvector &rv) throw() { return rv; } 00495 INLINE cvector operator +(const cvector_slice &sl) throw() { return sl; } 00496 INLINE cvector operator +(const cvector &rv1, const cvector &rv2) 00497 #if(CXSC_INDEX_CHECK) 00498 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00499 #else 00500 throw() 00501 #endif 00502 { return _vvplus<cvector,cvector,cvector>(rv1,rv2); } 00503 INLINE cvector operator +(const cvector &rv, const cvector_slice &sl) 00504 #if(CXSC_INDEX_CHECK) 00505 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00506 #else 00507 throw() 00508 #endif 00509 { return _vvsplus<cvector,cvector_slice,cvector>(rv,sl); } 00510 INLINE cvector operator +(const cvector_slice &sl, const cvector &rv) 00511 #if(CXSC_INDEX_CHECK) 00512 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00513 #else 00514 throw() 00515 #endif 00516 { return _vvsplus<cvector,cvector_slice,cvector>(rv,sl); } 00517 INLINE cvector operator +(const cvector_slice &sl1, const cvector_slice &sl2) 00518 #if(CXSC_INDEX_CHECK) 00519 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00520 #else 00521 throw() 00522 #endif 00523 { return _vsvsplus<cvector_slice,cvector_slice,cvector>(sl1,sl2); } 00524 INLINE cvector & operator +=(cvector &rv1, const cvector &rv2) 00525 #if(CXSC_INDEX_CHECK) 00526 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00527 #else 00528 throw() 00529 #endif 00530 { return _vvplusassign(rv1,rv2); } 00531 INLINE cvector &operator +=(cvector &rv, const cvector_slice &sl) 00532 #if(CXSC_INDEX_CHECK) 00533 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00534 #else 00535 throw() 00536 #endif 00537 { return _vvsplusassign(rv,sl); } 00538 INLINE cvector_slice &cvector_slice::operator +=(const cvector &rv) 00539 #if(CXSC_INDEX_CHECK) 00540 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00541 #else 00542 throw() 00543 #endif 00544 { return _vsvplusassign(*this,rv); } 00545 INLINE cvector_slice &cvector_slice::operator +=(const cvector_slice &sl2) 00546 #if(CXSC_INDEX_CHECK) 00547 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00548 #else 00549 throw() 00550 #endif 00551 { return _vsvsplusassign(*this,sl2); } 00552 00553 INLINE cvector operator -(const cvector &rv) throw() { return _vminus(rv); } 00554 INLINE cvector operator -(const cvector_slice &sl) throw() { return _vsminus<cvector_slice,cvector>(sl); } 00555 INLINE cvector operator -(const cvector &rv1, const cvector &rv2) 00556 #if(CXSC_INDEX_CHECK) 00557 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00558 #else 00559 throw() 00560 #endif 00561 { return _vvminus<cvector,cvector,cvector>(rv1,rv2); } 00562 INLINE cvector operator -(const cvector &rv, const cvector_slice &sl) 00563 #if(CXSC_INDEX_CHECK) 00564 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00565 #else 00566 throw() 00567 #endif 00568 { return _vvsminus<cvector,cvector_slice,cvector>(rv,sl); } 00569 INLINE cvector operator -(const cvector_slice &sl, const cvector &rv) 00570 #if(CXSC_INDEX_CHECK) 00571 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00572 #else 00573 throw() 00574 #endif 00575 { return _vsvminus<cvector_slice,cvector,cvector>(sl,rv); } 00576 INLINE cvector operator -(const cvector_slice &sl1, const cvector_slice &sl2) 00577 #if(CXSC_INDEX_CHECK) 00578 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00579 #else 00580 throw() 00581 #endif 00582 { return _vsvsminus<cvector_slice,cvector_slice,cvector>(sl1,sl2); } 00583 INLINE cvector & operator -=(cvector &rv1, const cvector &rv2) 00584 #if(CXSC_INDEX_CHECK) 00585 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00586 #else 00587 throw() 00588 #endif 00589 { return _vvminusassign(rv1,rv2); } 00590 INLINE cvector &operator -=(cvector &rv, const cvector_slice &sl) 00591 #if(CXSC_INDEX_CHECK) 00592 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00593 #else 00594 throw() 00595 #endif 00596 { return _vvsminusassign(rv,sl); } 00597 INLINE cvector_slice &cvector_slice::operator -=(const cvector &rv) 00598 #if(CXSC_INDEX_CHECK) 00599 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00600 #else 00601 throw() 00602 #endif 00603 { return _vsvminusassign(*this,rv); } 00604 INLINE cvector_slice &cvector_slice::operator -=(const cvector_slice &sl2) 00605 #if(CXSC_INDEX_CHECK) 00606 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00607 #else 00608 throw() 00609 #endif 00610 { return _vsvsminusassign(*this,sl2); } 00611 00612 INLINE bool operator ==(const cvector &rv1, const cvector &rv2) throw() { return _vveq(rv1,rv2); } 00613 INLINE bool operator ==(const cvector_slice &sl1, const cvector_slice &sl2) throw() { return _vsvseq(sl1,sl2); } 00614 INLINE bool operator ==(const cvector_slice &sl, const cvector &rv) throw() { return _vsveq(sl,rv); } 00615 INLINE bool operator ==(const cvector &rv, const cvector_slice &sl) throw() { return _vsveq(sl,rv); } 00616 INLINE bool operator !=(const cvector &rv1, const cvector &rv2) throw() { return _vvneq(rv1,rv2); } 00617 INLINE bool operator !=(const cvector_slice &sl1, const cvector_slice &sl2) throw() { return _vsvsneq(sl1,sl2); } 00618 INLINE bool operator !=(const cvector_slice &sl, const cvector &rv) throw() { return _vsvneq(sl,rv); } 00619 INLINE bool operator !=(const cvector &rv, const cvector_slice &sl) throw() { return _vsvneq(sl,rv); } 00620 /* INLINE bool operator <(const cvector &rv1, const cvector &rv2) throw() { return _vvless(rv1,rv2); } 00621 INLINE bool operator <(const cvector_slice &sl1, const cvector_slice &sl2) throw() { return _vsvsless(sl1,sl2); } 00622 INLINE bool operator < (const cvector_slice &sl, const cvector &rv) throw() { return _vsvless(sl,rv); } 00623 INLINE bool operator < (const cvector &rv, const cvector_slice &sl) throw() { return _vvsless(rv,sl); } 00624 INLINE bool operator <=(const cvector &rv1, const cvector &rv2) throw() { return _vvleq(rv1,rv2); } 00625 INLINE bool operator <=(const cvector_slice &sl1, const cvector_slice &sl2) throw() { return _vsvsleq(sl1,sl2); } 00626 INLINE bool operator <=(const cvector_slice &sl, const cvector &rv) throw() { return _vsvleq(sl,rv); } 00627 INLINE bool operator <=(const cvector &rv, const cvector_slice &sl) throw() { return _vvsleq(rv,sl); } 00628 INLINE bool operator >(const cvector &rv1, const cvector &rv2) throw() { return _vvless(rv2,rv1); } 00629 INLINE bool operator >(const cvector_slice &sl1, const cvector_slice &sl2) throw() { return _vsvsless(sl2,sl1); } 00630 INLINE bool operator >(const cvector_slice &sl, const cvector &rv) throw() { return _vvsless(rv,sl); } 00631 INLINE bool operator >(const cvector &rv, const cvector_slice &sl) throw() { return _vsvless(sl,rv); } 00632 INLINE bool operator >=(const cvector &rv1, const cvector &rv2) throw() { return _vvleq(rv2,rv1); } 00633 INLINE bool operator >=(const cvector_slice &sl1, const cvector_slice &sl2) throw() { return _vsvsleq(sl2,sl1); } 00634 INLINE bool operator >=(const cvector_slice &sl, const cvector &rv) throw() { return _vvsleq(rv,sl); } 00635 INLINE bool operator >=(const cvector &rv, const cvector_slice &sl) throw() { return _vsvleq(sl,rv); } 00636 */ 00637 //-------------------------------- complex / Real -------------------------------- 00638 00639 INLINE cvector & cvector::operator =(const rvector_slice &sl) throw() { return _vvsassign<cvector,rvector_slice,complex>(*this,sl); } 00640 00641 00642 INLINE complex operator *(const rvector & rv1, const cvector &rv2) 00643 #if(CXSC_INDEX_CHECK) 00644 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00645 #else 00646 throw() 00647 #endif 00648 { return _vvcmult<rvector,cvector,complex>(rv1,rv2); } 00649 INLINE complex operator *(const rvector_slice &sl, const cvector &rv) 00650 #if(CXSC_INDEX_CHECK) 00651 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00652 #else 00653 throw() 00654 #endif 00655 { return _vsvcmult<rvector_slice,cvector,complex>(sl,rv); } 00656 INLINE complex operator *(const rvector &rv, const cvector_slice &sl) 00657 #if(CXSC_INDEX_CHECK) 00658 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00659 #else 00660 throw() 00661 #endif 00662 { return _vsvcmult<cvector_slice,rvector,complex>(sl,rv); } 00663 INLINE complex operator *(const rvector_slice & sl1, const cvector_slice &sl2) 00664 #if(CXSC_INDEX_CHECK) 00665 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00666 #else 00667 throw() 00668 #endif 00669 { return _vsvscmult<rvector_slice,cvector_slice,complex>(sl1,sl2); } 00670 00671 INLINE complex operator *(const cvector & rv1, const rvector &rv2) 00672 #if(CXSC_INDEX_CHECK) 00673 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00674 #else 00675 throw() 00676 #endif 00677 { return _vvcmult<rvector,cvector,complex>(rv2,rv1); } 00678 INLINE complex operator *(const cvector_slice &sl, const rvector &rv) 00679 #if(CXSC_INDEX_CHECK) 00680 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00681 #else 00682 throw() 00683 #endif 00684 { return _vsvcmult<cvector_slice,rvector,complex>(sl,rv); } 00685 INLINE complex operator *(const cvector &rv, const rvector_slice &sl) 00686 #if(CXSC_INDEX_CHECK) 00687 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00688 #else 00689 throw() 00690 #endif 00691 { return _vsvcmult<rvector_slice,cvector,complex>(sl,rv); } 00692 INLINE complex operator *(const cvector_slice & sl1, const rvector_slice &sl2) 00693 #if(CXSC_INDEX_CHECK) 00694 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00695 #else 00696 throw() 00697 #endif 00698 { return _vsvscmult<rvector_slice,cvector_slice,complex>(sl2,sl1); } 00699 00700 INLINE cvector operator +(const rvector &rv1, const cvector &rv2) 00701 #if(CXSC_INDEX_CHECK) 00702 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00703 #else 00704 throw() 00705 #endif 00706 { return _vvplus<rvector,cvector,cvector>(rv1,rv2); } 00707 INLINE cvector operator +(const rvector &rv, const cvector_slice &sl) 00708 #if(CXSC_INDEX_CHECK) 00709 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00710 #else 00711 throw() 00712 #endif 00713 { return _vvsplus<rvector,cvector_slice,cvector>(rv,sl); } 00714 INLINE cvector operator +(const rvector_slice &sl, const cvector &rv) 00715 #if(CXSC_INDEX_CHECK) 00716 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00717 #else 00718 throw() 00719 #endif 00720 { return _vvsplus<cvector,rvector_slice,cvector>(rv,sl); } 00721 INLINE cvector operator +(const rvector_slice &sl1, const cvector_slice &sl2) 00722 #if(CXSC_INDEX_CHECK) 00723 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00724 #else 00725 throw() 00726 #endif 00727 { return _vsvsplus<rvector_slice,cvector_slice,cvector>(sl1,sl2); } 00728 00729 INLINE cvector operator +(const cvector &rv1, const rvector &rv2) 00730 #if(CXSC_INDEX_CHECK) 00731 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00732 #else 00733 throw() 00734 #endif 00735 { return _vvplus<rvector,cvector,cvector>(rv2,rv1); } 00736 INLINE cvector operator +(const cvector &rv, const rvector_slice &sl) 00737 #if(CXSC_INDEX_CHECK) 00738 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00739 #else 00740 throw() 00741 #endif 00742 { return _vvsplus<cvector,rvector_slice,cvector>(rv,sl); } 00743 INLINE cvector operator +(const cvector_slice &sl, const rvector &rv) 00744 #if(CXSC_INDEX_CHECK) 00745 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00746 #else 00747 throw() 00748 #endif 00749 { return _vvsplus<rvector,cvector_slice,cvector>(rv,sl); } 00750 INLINE cvector operator +(const cvector_slice &sl1, const rvector_slice &sl2) 00751 #if(CXSC_INDEX_CHECK) 00752 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00753 #else 00754 throw() 00755 #endif 00756 { return _vsvsplus<rvector_slice,cvector_slice,cvector>(sl2,sl1); } 00757 00758 INLINE cvector & operator +=(cvector &rv1, const rvector &rv2) 00759 #if(CXSC_INDEX_CHECK) 00760 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00761 #else 00762 throw() 00763 #endif 00764 { return _vvplusassign(rv1,rv2); } 00765 INLINE cvector &operator +=(cvector &rv, const rvector_slice &sl) 00766 #if(CXSC_INDEX_CHECK) 00767 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00768 #else 00769 throw() 00770 #endif 00771 { return _vvsplusassign(rv,sl); } 00772 INLINE cvector_slice &cvector_slice::operator +=(const rvector &rv) 00773 #if(CXSC_INDEX_CHECK) 00774 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00775 #else 00776 throw() 00777 #endif 00778 { return _vsvplusassign(*this,rv); } 00779 INLINE cvector_slice &cvector_slice::operator +=(const rvector_slice &sl2) 00780 #if(CXSC_INDEX_CHECK) 00781 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00782 #else 00783 throw() 00784 #endif 00785 { return _vsvsplusassign(*this,sl2); } 00786 00787 INLINE cvector operator -(const rvector &rv1, const cvector &rv2) 00788 #if(CXSC_INDEX_CHECK) 00789 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00790 #else 00791 throw() 00792 #endif 00793 { return _vvminus<rvector,cvector,cvector>(rv1,rv2); } 00794 INLINE cvector operator -(const rvector &rv, const cvector_slice &sl) 00795 #if(CXSC_INDEX_CHECK) 00796 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00797 #else 00798 throw() 00799 #endif 00800 { return _vvsminus<rvector,cvector_slice,cvector>(rv,sl); } 00801 INLINE cvector operator -(const rvector_slice &sl, const cvector &rv) 00802 #if(CXSC_INDEX_CHECK) 00803 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00804 #else 00805 throw() 00806 #endif 00807 { return _vsvminus<rvector_slice,cvector,cvector>(sl,rv); } 00808 INLINE cvector operator -(const rvector_slice &sl1, const cvector_slice &sl2) 00809 #if(CXSC_INDEX_CHECK) 00810 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00811 #else 00812 throw() 00813 #endif 00814 { return _vsvsminus<rvector_slice,cvector_slice,cvector>(sl1,sl2); } 00815 00816 INLINE cvector operator -(const cvector &rv1, const rvector &rv2) 00817 #if(CXSC_INDEX_CHECK) 00818 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00819 #else 00820 throw() 00821 #endif 00822 { return _vvminus<cvector,rvector,cvector>(rv1,rv2); } 00823 INLINE cvector operator -(const cvector &rv, const rvector_slice &sl) 00824 #if(CXSC_INDEX_CHECK) 00825 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00826 #else 00827 throw() 00828 #endif 00829 { return _vvsminus<cvector,rvector_slice,cvector>(rv,sl); } 00830 INLINE cvector operator -(const cvector_slice &sl, const rvector &rv) 00831 #if(CXSC_INDEX_CHECK) 00832 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00833 #else 00834 throw() 00835 #endif 00836 { return _vsvminus<cvector_slice,rvector,cvector>(sl,rv); } 00837 INLINE cvector operator -(const cvector_slice &sl1, const rvector_slice &sl2) 00838 #if(CXSC_INDEX_CHECK) 00839 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00840 #else 00841 throw() 00842 #endif 00843 { return _vsvsminus<cvector_slice,rvector_slice,cvector>(sl1,sl2); } 00844 00845 INLINE cvector & operator -=(cvector &rv1, const rvector &rv2) 00846 #if(CXSC_INDEX_CHECK) 00847 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00848 #else 00849 throw() 00850 #endif 00851 { return _vvminusassign(rv1,rv2); } 00852 INLINE cvector &operator -=(cvector &rv, const rvector_slice &sl) 00853 #if(CXSC_INDEX_CHECK) 00854 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00855 #else 00856 throw() 00857 #endif 00858 { return _vvsminusassign(rv,sl); } 00859 INLINE cvector_slice &cvector_slice::operator -=(const rvector &rv) 00860 #if(CXSC_INDEX_CHECK) 00861 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00862 #else 00863 throw() 00864 #endif 00865 { return _vsvminusassign(*this,rv); } 00866 INLINE cvector_slice &cvector_slice::operator -=(const rvector_slice &sl2) 00867 #if(CXSC_INDEX_CHECK) 00868 throw(ERROR__OP_WITH_WRONG_DIM<cvector>) 00869 #else 00870 throw() 00871 #endif 00872 { return _vsvsminusassign(*this,sl2); } 00873 00875 INLINE cvector cvector::operator()(const intvector& p) { 00876 cvector x(*this); 00877 for(int i=0 ; i<VecLen(x) ; i++) 00878 x[i+Lb(x)] = (*this)[p[i+Lb(p)]+Lb(*this)]; 00879 return x; 00880 } 00881 00882 } // namespace cxsc 00883 00884 #endif // _CXSC_CVECTOR_INL_INCLUDED 00885