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: srvector.hpp,v 1.16 2014/01/30 17:23:49 cxsc Exp $ */ 00025 00026 #ifndef _CXSC_SRVECTOR_HPP_INCLUDED 00027 #define _CXSC_SRVECTOR_HPP_INCLUDED 00028 00029 #include <real.hpp> 00030 #include <intvector.hpp> 00031 #include <rvector.hpp> 00032 #include <intmatrix.hpp> 00033 #include <vector> 00034 #include <map> 00035 #include <iostream> 00036 #include <except.hpp> 00037 #include <cidot.hpp> 00038 #include <sparsedot.hpp> 00039 #include <sparsevector.hpp> 00040 00041 namespace cxsc { 00042 00043 class srvector_slice; 00044 class srmatrix; 00045 class srmatrix_slice; 00046 class srmatrix_subv; 00047 00048 class scvector; 00049 class sivector; 00050 class sivector_slice; 00051 class scivector; 00052 00054 00058 class srvector { 00059 private: 00060 std::vector<int> p; 00061 std::vector<real> x; 00062 int lb; 00063 int ub; 00064 int n; 00065 00066 public: 00068 srvector() : lb(0), ub(-1) , n(0) { 00069 } 00070 00072 explicit srvector(const int s) : lb(1), ub(s), n(s) { 00073 p.reserve((int)(s*0.1)); 00074 x.reserve((int)(s*0.1)); 00075 } 00076 00078 srvector(const int s, const int b) : lb(1), ub(s), n(s) { 00079 p.reserve(b); 00080 x.reserve(b); 00081 } 00082 00084 srvector(const rvector& v) : lb(Lb(v)), ub(Ub(v)), n(VecLen(v)) { 00085 for(int i=lb ; i<=ub ; i++) { 00086 if(v[i] != 0.0) { 00087 p.push_back(i-lb); 00088 x.push_back(v[i]); 00089 } 00090 } 00091 } 00092 00094 srvector(const int n, const int nnz, const intvector& index, const rvector& values) : lb(1), ub(n) { 00095 this->n = n; 00096 for(int i=0 ; i<nnz ; i++) { 00097 if(values[Lb(values)+i] != 0.0) { 00098 p.push_back(index[Lb(index)+i]); 00099 x.push_back(values[Lb(values)+i]); 00100 } 00101 } 00102 00103 } 00104 00106 srvector(const int n, const int nnz, const int *index, const real *values) : lb(1), ub(n) { 00107 this->n = n; 00108 for(int i=0 ; i<nnz ; i++) { 00109 if(values[i] != 0.0) { 00110 p.push_back(index[i]); 00111 x.push_back(values[i]); 00112 } 00113 } 00114 } 00115 00117 srvector(const srvector_slice&); 00119 srvector(const srmatrix_subv& A); 00120 00122 00127 std::vector<int>& row_indices() { 00128 return p; 00129 } 00130 00132 00136 std::vector<real>& values() { 00137 return x; 00138 } 00139 00141 00146 const std::vector<int>& row_indices() const { 00147 return p; 00148 } 00149 00151 00155 const std::vector<real>& values() const { 00156 return x; 00157 } 00158 00160 int get_nnz() const { 00161 return x.size(); 00162 } 00163 00165 real density() const { 00166 return (double)x.size()/n; 00167 } 00168 00170 void dropzeros() { 00171 for(int i=0 ; i<get_nnz() ; i++) { 00172 if(x[i] == 0.0) { 00173 x.erase(x.begin()+i); 00174 p.erase(p.begin()+i); 00175 } 00176 } 00177 } 00178 00180 srvector& operator=(const real& v) { 00181 return sp_vs_assign<srvector,real,real>(*this,v); 00182 } 00183 00185 srvector& operator=(const rvector& v) { 00186 return spf_vv_assign<srvector,rvector,real>(*this,v); 00187 } 00188 00190 srvector& operator=(const rvector_slice& v) { 00191 return spf_vv_assign<srvector,rvector_slice,real>(*this,v); 00192 } 00193 00195 srvector& operator=(const srvector_slice&); 00196 00198 00202 real& operator[](const int i) { 00203 #if(CXSC_INDEX_CHECK) 00204 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC("srvector::operator[](const int)")); 00205 #endif 00206 int k; 00207 00208 for(k=0 ; k<get_nnz() && p[k]<=i-lb ; k++) { 00209 if(p[k] == i-lb) 00210 return x[k]; 00211 } 00212 00213 p.insert(p.begin() + k, i-lb); 00214 x.insert(x.begin() + k, 0.0); 00215 00216 return x[k]; 00217 } 00218 00220 00224 real operator[](const int i) const { 00225 #if(CXSC_INDEX_CHECK) 00226 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC("srvector::operator[](const int)")); 00227 #endif 00228 return (*this)(i); 00229 } 00230 00232 00236 const real operator()(const int i) const { 00237 #if(CXSC_INDEX_CHECK) 00238 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC("srvector::operator()(const int)")); 00239 #endif 00240 real r = 0.0; 00241 00242 for(int k=0 ; k<get_nnz() && p[k]<=i-lb ; k++) { 00243 if(p[k] == i-lb) 00244 r = x[k]; 00245 } 00246 00247 return r; 00248 } 00249 00251 00253 srvector_slice operator()(const int i, const int j); 00254 00256 00259 srvector operator()(const intvector& per) { 00260 srvector v(n,get_nnz()); 00261 intvector pinv = perminv(per); 00262 00263 std::map<int,real> work; 00264 for(int i=0 ; i<get_nnz() ; i++) 00265 work.insert(std::make_pair(pinv[Lb(pinv)+p[i]], x[i])); 00266 00267 for(std::map<int,real>::iterator it=work.begin() ; it!=work.end() ; it++) { 00268 v.p.push_back(it->first); 00269 v.x.push_back(it->second); 00270 } 00271 00272 return v; 00273 } 00274 00276 00282 srvector operator()(const intmatrix& P) { 00283 intvector p = permvec(P); 00284 return (*this)(p); 00285 } 00286 00288 srvector& operator*=(const real& s) { 00289 return sp_vs_multassign(*this,s); 00290 } 00291 00293 srvector& operator/=(const real& s) { 00294 return sp_vs_divassign(*this,s); 00295 } 00296 00298 srvector& operator+=(const rvector& v) 00299 { 00300 return spf_vv_addassign(*this,v); 00301 } 00302 00304 srvector& operator+=(const rvector_slice& v) { 00305 return spf_vv_addassign(*this,v); 00306 } 00307 00309 srvector& operator+=(const srvector& v) { 00310 return spsp_vv_addassign(*this,v); 00311 } 00312 00314 srvector& operator+=(const srvector_slice&); 00315 00317 srvector& operator-=(const rvector& v) { 00318 return spf_vv_subassign(*this,v); 00319 } 00320 00322 srvector& operator-=(const rvector_slice& v) { 00323 return spf_vv_subassign(*this,v); 00324 } 00325 00327 srvector& operator-=(const srvector& v) { 00328 return spsp_vv_subassign(*this,v); 00329 } 00330 00332 srvector& operator-=(const srvector_slice&); 00333 00334 friend int Lb(const srvector&); 00335 friend int Ub(const srvector&); 00336 friend void SetLb(srvector&, const int); 00337 friend void SetUb(srvector&, const int); 00338 00339 friend int VecLen(const srvector&); 00340 friend srvector Re(const scvector&); 00341 friend srvector Im(const scvector&); 00342 friend srvector Inf(const sivector&); 00343 friend srvector Sup(const sivector&); 00344 friend srvector InfRe(const scivector&); 00345 friend srvector SupRe(const scivector&); 00346 friend srvector InfIm(const scivector&); 00347 friend srvector SupIm(const scivector&); 00348 friend srvector mid(const sivector&); 00349 friend srvector diam(const sivector&); 00350 friend srvector absmin(const sivector&); 00351 friend srvector absmax(const sivector&); 00352 friend srvector abs(const srvector&); 00353 friend srvector mid(const sivector_slice&); 00354 friend srvector diam(const sivector_slice&); 00355 00356 00357 friend class srvector_slice; 00358 friend class scvector_slice; 00359 friend class scvector; 00360 friend class sivector_slice; 00361 friend class sivector; 00362 friend class scivector_slice; 00363 friend class scivector; 00364 friend class srmatrix_subv; 00365 friend class rvector; 00366 friend class rvector_slice; 00367 friend class ivector; 00368 friend class ivector_slice; 00369 friend class cvector; 00370 friend class cvector_slice; 00371 friend class civector; 00372 friend class civector_slice; 00373 00374 00375 #include "vector_friend_declarations.inl" 00376 }; 00377 00378 inline rvector::rvector(const srvector& v) { 00379 l = v.lb; 00380 u = v.ub; 00381 size = v.n; 00382 dat = new real[v.n]; 00383 for(int i=0 ; i<v.n ; i++) 00384 dat[i] = 0.0; 00385 for(int i=0 ; i<v.get_nnz() ; i++) 00386 dat[v.p[i]] = v.x[i]; 00387 } 00388 00389 inline rvector& rvector::operator=(const srvector& v) { 00390 return fsp_vv_assign<rvector,srvector,real>(*this,v); 00391 } 00392 00393 inline rvector& rvector::operator=(const srvector_slice& v) { 00394 return fsl_vv_assign<rvector,srvector_slice,real>(*this,v); 00395 } 00396 00397 00399 00402 inline void SetLb(srvector& v, const int i) { 00403 v.lb = i; 00404 v.ub = v.lb + v.n - 1; 00405 } 00406 00408 00411 inline void SetUb(srvector& v, const int j) { 00412 v.ub = j; 00413 v.lb = v.ub - v.n + 1; 00414 } 00415 00417 inline int Lb(const srvector& v) { 00418 return v.lb; 00419 } 00420 00422 inline int Ub(const srvector& v) { 00423 return v.ub; 00424 } 00425 00427 inline int VecLen(const srvector& v) { 00428 return v.n; 00429 } 00430 00432 inline void Resize(srvector& v) { 00433 sp_v_resize(v); 00434 } 00435 00437 00440 inline void Resize(srvector& v, const int n) { 00441 sp_v_resize(v,n); 00442 } 00443 00445 00449 inline void Resize(srvector& v, const int l, const int u) { 00450 sp_v_resize(v,l,u); 00451 } 00452 00454 inline srvector operator-(const srvector& v) { 00455 return sp_v_negative(v); 00456 } 00457 00459 00465 inline real operator*(const srvector& v1, const rvector& v2) { 00466 return spf_vv_mult<srvector,rvector,real,sparse_dot>(v1,v2); 00467 } 00468 00470 00476 inline real operator*(const rvector& v1, const srvector& v2) { 00477 return fsp_vv_mult<rvector,srvector,real,sparse_dot>(v1,v2); 00478 } 00479 00481 00487 inline real operator*(const srvector& v1, const rvector_slice& v2) { 00488 return spf_vv_mult<srvector,rvector_slice,real,sparse_dot>(v1,v2); 00489 } 00490 00492 00498 inline real operator*(const rvector_slice& v1, const srvector& v2) { 00499 return fsp_vv_mult<rvector_slice,srvector,real,sparse_dot>(v1,v2); 00500 } 00501 00503 00509 inline real operator*(const srvector& v1, const srvector& v2) { 00510 return spsp_vv_mult<srvector,srvector,real,sparse_dot>(v1,v2); 00511 } 00512 00514 inline srvector operator*(const srvector& v, const real& s) { 00515 return sp_vs_mult<srvector,real,srvector>(v,s); 00516 } 00517 00519 inline srvector operator/(const srvector& v, const real& s) { 00520 return sp_vs_div<srvector,real,srvector>(v,s); 00521 } 00522 00524 inline srvector operator*(const real& s, const srvector& v) { 00525 return sp_sv_mult<real,srvector,srvector>(s,v); 00526 } 00527 00529 inline rvector operator+(const rvector& v1, const srvector& v2) { 00530 return fsp_vv_add<rvector,srvector,rvector>(v1,v2); 00531 } 00532 00534 inline rvector operator+(const srvector& v1, const rvector& v2) { 00535 return spf_vv_add<srvector,rvector,rvector>(v1,v2); 00536 } 00537 00539 inline rvector operator+(const rvector_slice& v1, const srvector& v2) { 00540 return fsp_vv_add<rvector_slice,srvector,rvector>(v1,v2); 00541 } 00542 00544 inline rvector operator+(const srvector& v1, const rvector_slice& v2) { 00545 return spf_vv_add<srvector,rvector_slice,rvector>(v1,v2); 00546 } 00547 00549 inline srvector operator+(const srvector& v1, const srvector& v2) { 00550 return spsp_vv_add<srvector,srvector,srvector,real>(v1,v2); 00551 } 00552 00554 inline rvector operator-(const rvector& v1, const srvector& v2) { 00555 return fsp_vv_sub<rvector,srvector,rvector>(v1,v2); 00556 } 00557 00559 inline rvector operator-(const srvector& v1, const rvector& v2) { 00560 return spf_vv_sub<srvector,rvector,rvector>(v1,v2); 00561 } 00562 00564 inline rvector operator-(const rvector_slice& v1, const srvector& v2) { 00565 return fsp_vv_sub<rvector_slice,srvector,rvector>(v1,v2); 00566 } 00567 00569 inline rvector operator-(const srvector& v1, const rvector_slice& v2) { 00570 return spf_vv_sub<srvector,rvector_slice,rvector>(v1,v2); 00571 } 00572 00574 inline srvector operator-(const srvector& v1, const srvector& v2) { 00575 return spsp_vv_sub<srvector,srvector,srvector,real>(v1,v2); 00576 } 00577 00578 inline rvector& rvector::operator+=(const srvector& v2) { 00579 return fsp_vv_addassign(*this,v2); 00580 } 00581 00582 inline rvector_slice& rvector_slice::operator+=(const srvector& v2) { 00583 return fsp_vv_addassign(*this,v2); 00584 } 00585 00586 inline rvector& rvector::operator-=(const srvector& v2) { 00587 return fsp_vv_subassign(*this,v2); 00588 } 00589 00590 inline rvector_slice& rvector_slice::operator-=(const srvector& v2) { 00591 return fsp_vv_subassign(*this,v2); 00592 } 00593 00595 00598 inline bool operator==(const srvector& v1, const srvector& v2) { 00599 return spsp_vv_comp(v1,v2); 00600 } 00601 00603 00606 inline bool operator==(const srvector& v1, const rvector& v2) { 00607 return spf_vv_comp(v1,v2); 00608 } 00609 00611 00614 inline bool operator==(const rvector& v1, const srvector& v2) { 00615 return fsp_vv_comp(v1,v2); 00616 } 00617 00619 00622 inline bool operator==(const srvector& v1, const rvector_slice& v2) { 00623 return spf_vv_comp(v1,v2); 00624 } 00625 00627 00630 inline bool operator==(const rvector_slice& v1, const srvector& v2) { 00631 return fsp_vv_comp(v1,v2); 00632 } 00633 00635 00638 inline bool operator!=(const srvector& v1, const srvector& v2) { 00639 return !spsp_vv_comp(v1,v2); 00640 } 00641 00643 00646 inline bool operator!=(const srvector& v1, const rvector& v2) { 00647 return !spf_vv_comp(v1,v2); 00648 } 00649 00651 00654 inline bool operator!=(const rvector& v1, const srvector& v2) { 00655 return !fsp_vv_comp(v1,v2); 00656 } 00657 00659 00662 inline bool operator!=(const srvector& v1, const rvector_slice& v2) { 00663 return !spf_vv_comp(v1,v2); 00664 } 00665 00667 00670 inline bool operator!=(const rvector_slice& v1, const srvector& v2) { 00671 return !fsp_vv_comp(v1,v2); 00672 } 00673 00675 00678 inline bool operator<(const srvector& v1, const srvector& v2) { 00679 return spsp_vv_less<srvector,srvector,real>(v1,v2); 00680 } 00681 00683 00686 inline bool operator<(const srvector& v1, const rvector& v2) { 00687 return spf_vv_less<srvector,rvector,real>(v1,v2); 00688 } 00689 00691 00694 inline bool operator<(const rvector& v1, const srvector& v2) { 00695 return fsp_vv_less<rvector,srvector,real>(v1,v2); 00696 } 00697 00699 00702 inline bool operator<(const srvector& v1, const rvector_slice& v2) { 00703 return spf_vv_less<srvector,rvector_slice,real>(v1,v2); 00704 } 00705 00707 00710 inline bool operator<(const rvector_slice& v1, const srvector& v2) { 00711 return fsp_vv_less<rvector_slice,srvector,real>(v1,v2); 00712 } 00713 00715 00718 inline bool operator<=(const srvector& v1, const srvector& v2) { 00719 return spsp_vv_leq<srvector,srvector,real>(v1,v2); 00720 } 00721 00723 00726 inline bool operator<=(const srvector& v1, const rvector& v2) { 00727 return spf_vv_leq<srvector,rvector,real>(v1,v2); 00728 } 00729 00731 00734 inline bool operator<=(const rvector& v1, const srvector& v2) { 00735 return fsp_vv_leq<rvector,srvector,real>(v1,v2); 00736 } 00737 00739 00742 inline bool operator<=(const srvector& v1, const rvector_slice& v2) { 00743 return spf_vv_leq<srvector,rvector_slice,real>(v1,v2); 00744 } 00745 00747 00750 inline bool operator<=(const rvector_slice& v1, const srvector& v2) { 00751 return fsp_vv_leq<rvector_slice,srvector,real>(v1,v2); 00752 } 00753 00755 00758 inline bool operator>(const srvector& v1, const srvector& v2) { 00759 return spsp_vv_greater<srvector,srvector,real>(v1,v2); 00760 } 00761 00763 00766 inline bool operator>(const srvector& v1, const rvector& v2) { 00767 return spf_vv_greater<srvector,rvector,real>(v1,v2); 00768 } 00769 00771 00774 inline bool operator>(const rvector& v1, const srvector& v2) { 00775 return fsp_vv_greater<rvector,srvector,real>(v1,v2); 00776 } 00777 00779 00782 inline bool operator>(const srvector& v1, const rvector_slice& v2) { 00783 return spf_vv_greater<srvector,rvector_slice,real>(v1,v2); 00784 } 00785 00787 00790 inline bool operator>(const rvector_slice& v1, const srvector& v2) { 00791 return fsp_vv_greater<rvector_slice,srvector,real>(v1,v2); 00792 } 00793 00795 00798 inline bool operator>=(const srvector& v1, const srvector& v2) { 00799 return spsp_vv_geq<srvector,srvector,real>(v1,v2); 00800 } 00801 00803 00806 inline bool operator>=(const srvector& v1, const rvector& v2) { 00807 return spf_vv_geq<srvector,rvector,real>(v1,v2); 00808 } 00809 00811 00814 inline bool operator>=(const rvector& v1, const srvector& v2) { 00815 return fsp_vv_geq<rvector,srvector,real>(v1,v2); 00816 } 00817 00819 00822 inline bool operator>=(const srvector& v1, const rvector_slice& v2) { 00823 return spf_vv_geq<srvector,rvector_slice,real>(v1,v2); 00824 } 00825 00827 00830 inline bool operator>=(const rvector_slice& v1, const srvector& v2) { 00831 return fsp_vv_geq<rvector_slice,srvector,real>(v1,v2); 00832 } 00833 00835 00838 inline bool operator!(const srvector& x) { 00839 return sp_v_not(x); 00840 } 00841 00843 00848 inline std::ostream& operator<<(std::ostream& os, const srvector& v) { 00849 return sp_v_output<srvector,real>(os,v); 00850 } 00851 00853 00858 inline std::istream& operator>>(std::istream& is, srvector& v) { 00859 return sp_v_input<srvector,real>(is,v); 00860 } 00861 00863 00868 class srvector_slice { 00869 private: 00870 std::vector<int>& p; 00871 std::vector<real>& x; 00872 srvector& orig; 00873 int start,end; 00874 int lb; 00875 int ub; 00876 int n; 00877 int nnz; 00878 int offset; 00879 00881 00885 srvector_slice(srvector& v, int l, int u) : p(v.p), x(v.x), orig(v), lb(l), ub(u), n(u-l+1) { 00886 int i; 00887 00888 for(i=0 ; i<v.get_nnz() && p[i]<lb-v.lb ; i++); 00889 00890 start = i; 00891 00892 for(i=start ; i<v.get_nnz() && p[i]<=ub-v.lb ; i++); 00893 00894 end = i-1; 00895 00896 nnz = end-start+1; 00897 offset = lb-v.lb; 00898 } 00899 00900 public: 00902 int get_nnz() const { 00903 return nnz; 00904 } 00906 real density() const { 00907 return (double)nnz/n; 00908 } 00909 00911 00915 real& operator[](const int i) { 00916 #if(CXSC_INDEX_CHECK) 00917 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC("srvector_slice::operator[](const int)")); 00918 #endif 00919 int k; 00920 00921 for(k=start ; k<end+1 && p[k]-start<=i-lb ; k++) { 00922 if(p[k]-offset == i-lb) 00923 return x[k]; 00924 } 00925 00926 p.insert(p.begin() + k, i-lb); 00927 x.insert(x.begin() + k, 0.0); 00928 end++; 00929 00930 return x[k]; 00931 } 00932 00934 00938 real operator[](const int i) const { 00939 #if(CXSC_INDEX_CHECK) 00940 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC("srvector_slice::operator[](const int)")); 00941 #endif 00942 return (*this)(i); 00943 } 00944 00946 00950 const real operator()(const int i) const { 00951 #if(CXSC_INDEX_CHECK) 00952 if(i<lb || i>ub) cxscthrow(ELEMENT_NOT_IN_VEC("srvector_slice::operator()(const int)")); 00953 #endif 00954 real r = 0.0; 00955 00956 for(int k=start ; k<end && p[k]-start<=i-lb ; k++) { 00957 if(p[k]-start == i-lb) 00958 r = x[k]; 00959 } 00960 00961 return r; 00962 } 00963 00965 srvector_slice& operator=(const real& v) { 00966 return sl_vs_assign<srvector_slice,real,real,std::vector<real>::iterator>(*this,v); 00967 } 00968 00970 srvector_slice& operator=(const srvector_slice& v) { 00971 return slsl_vv_assign<srvector_slice,srvector_slice,real,std::vector<real>::iterator>(*this,v); 00972 } 00973 00975 srvector_slice& operator=(const srvector& v) { 00976 return slsp_vv_assign<srvector_slice,srvector,real,std::vector<real>::iterator>(*this,v); 00977 } 00978 00980 srvector_slice& operator=(const rvector& v) { 00981 return slf_vv_assign<srvector_slice,rvector,real,std::vector<real>::iterator>(*this,v); 00982 } 00983 00985 srvector_slice& operator=(const rvector_slice& v) { 00986 return slf_vv_assign<srvector_slice,rvector,real,std::vector<real>::iterator>(*this,v); 00987 } 00988 00990 srvector_slice& operator*=(const real& s) { 00991 return sl_vs_multassign(*this,s); 00992 } 00993 00995 srvector_slice& operator/=(const real& s) { 00996 return sl_vs_divassign(*this,s); 00997 } 00998 01000 srvector_slice& operator+=(const rvector& v) { 01001 return slf_vv_addassign<srvector_slice,rvector,real>(*this,v); 01002 } 01003 01005 srvector_slice& operator+=(const rvector_slice& v) { 01006 return slf_vv_addassign<srvector_slice,rvector_slice,real>(*this,v); 01007 } 01008 01010 srvector_slice& operator+=(const srvector& v) { 01011 return slsp_vv_addassign(*this,v); 01012 } 01013 01015 srvector_slice& operator+=(const srvector_slice& v) { 01016 return slsl_vv_addassign(*this,v); 01017 } 01018 01020 srvector_slice& operator-=(const rvector& v) { 01021 return slf_vv_subassign<srvector_slice,rvector,real>(*this,v); 01022 } 01023 01025 srvector_slice& operator-=(const rvector_slice& v) { 01026 return slf_vv_subassign<srvector_slice,rvector_slice,real>(*this,v); 01027 } 01028 01030 srvector_slice& operator-=(const srvector& v) { 01031 return slsp_vv_subassign(*this,v); 01032 } 01033 01035 srvector_slice& operator-=(const srvector_slice& v) { 01036 return slsl_vv_subassign(*this,v); 01037 } 01038 01039 01040 friend int Lb(const srvector_slice&); 01041 friend int Ub(const srvector_slice&); 01042 friend int VecLen(const srvector_slice&); 01043 01044 friend srvector operator*(const srmatrix&, const srvector_slice&); //ok 01045 friend srvector operator*(const srmatrix_slice&, const srvector_slice&); //ok 01046 01047 friend class srvector; 01048 friend class scvector; 01049 friend class sivector; 01050 friend class scivector; 01051 friend class srmatrix_subv; 01052 friend class rvector; 01053 friend class rvector_slice; 01054 friend class ivector; 01055 friend class ivector_slice; 01056 friend class cvector; 01057 friend class cvector_slice; 01058 friend class civector; 01059 friend class civector_slice; 01060 01061 #include "vector_friend_declarations.inl" 01062 }; 01063 01064 inline rvector::rvector(const srvector_slice& v) { 01065 l = v.lb; 01066 u = v.ub; 01067 size = v.n; 01068 dat = new real[v.n]; 01069 for(int i=0 ; i<v.n ; i++) 01070 dat[i] = 0.0; 01071 for(int i=v.start ; i<=v.end ; i++) 01072 dat[v.p[i]] = v.x[i]; 01073 } 01074 01075 inline rvector_slice& rvector_slice::operator=(const srvector& v) { 01076 *this = rvector(v); 01077 return *this; 01078 } 01079 01080 inline rvector_slice& rvector_slice::operator=(const srvector_slice& v) { 01081 *this = rvector(v); 01082 return *this; 01083 } 01084 01085 inline srvector::srvector(const srvector_slice& s) : lb(s.lb), ub(s.ub), n(s.n) { 01086 p.reserve(s.nnz); 01087 x.reserve(s.nnz); 01088 01089 for(int i=s.start ; i<=s.end ; i++) { 01090 p.push_back(s.p[i]-s.offset); 01091 x.push_back(s.x[i]); 01092 } 01093 01094 } 01095 01096 inline srvector& srvector::operator=(const srvector_slice& v) { 01097 return spsl_vv_assign<srvector,srvector_slice,real>(*this,v); 01098 } 01099 01100 inline srvector_slice srvector::operator()(const int i, const int j) { 01101 #if(CXSC_INDEX_CHECK) 01102 if(i<lb || j>ub) cxscthrow(ELEMENT_NOT_IN_VEC("srvector::operator()(const int,const int)")); 01103 #endif 01104 return srvector_slice(*this,i,j); 01105 } 01106 01108 inline srvector operator-(const srvector_slice& v) { 01109 return sl_v_negative<srvector_slice,srvector>(v); 01110 } 01111 01113 inline int Lb(const srvector_slice& v) { 01114 return v.lb; 01115 } 01116 01118 inline int Ub(const srvector_slice& v) { 01119 return v.ub; 01120 } 01121 01123 inline int VecLen(const srvector_slice& v) { 01124 return v.n; 01125 } 01126 01128 inline srvector abs(const srvector& v) { 01129 srvector ret(v); 01130 std::vector<real>& x = ret.values(); 01131 for(unsigned int i=0 ; i<x.size() ; i++) 01132 x[i] = abs(x[i]); 01133 return ret; 01134 } 01135 01137 01143 inline real operator*(const srvector_slice& v1, const rvector& v2) { 01144 return slf_vv_mult<srvector_slice,rvector,real,sparse_dot>(v1,v2); 01145 } 01146 01148 inline real operator*(const rvector& v1, const srvector_slice& v2) { 01154 return fsl_vv_mult<rvector,srvector_slice,real,sparse_dot>(v1,v2); 01155 } 01156 01158 inline real operator*(const srvector_slice& v1, const rvector_slice& v2) { 01164 return slf_vv_mult<srvector_slice,rvector_slice,real,sparse_dot>(v1,v2); 01165 } 01166 01168 inline real operator*(const rvector_slice& v1, const srvector_slice& v2) { 01174 return fsl_vv_mult<rvector_slice,srvector_slice,real,sparse_dot>(v1,v2); 01175 } 01176 01178 inline real operator*(const srvector& v1, const srvector_slice& v2) { 01184 return spsl_vv_mult<srvector,srvector_slice,real,sparse_dot>(v1,v2); 01185 } 01186 01188 inline real operator*(const srvector_slice& v1, const srvector& v2) { 01194 return slsp_vv_mult<srvector_slice,srvector,real,sparse_dot>(v1,v2); 01195 } 01196 01198 inline real operator*(const srvector_slice& v1, const srvector_slice& v2) { 01204 return slsl_vv_mult<srvector_slice,srvector_slice,real,sparse_dot>(v1,v2); 01205 } 01206 01208 inline srvector operator*(const srvector_slice& v, const real& s) { 01209 return sp_vs_mult<srvector_slice,real,srvector>(v,s); 01210 } 01211 01213 inline srvector operator/(const srvector_slice& v, const real& s) { 01214 return sp_vs_div<srvector_slice,real,srvector>(v,s); 01215 } 01216 01218 inline srvector operator*(const real& s, const srvector_slice& v) { 01219 return sp_sv_mult<real,srvector_slice,srvector>(s,v); 01220 } 01221 01223 inline rvector operator+(const rvector& v1, const srvector_slice& v2) { 01224 return fsl_vv_add<rvector,srvector_slice,rvector>(v1,v2); 01225 } 01226 01228 inline rvector operator+(const srvector_slice& v1, const rvector& v2) { 01229 return slf_vv_add<srvector_slice,rvector,rvector>(v1,v2); 01230 } 01231 01233 inline rvector operator+(const rvector_slice& v1, const srvector_slice& v2) { 01234 return fsl_vv_add<rvector_slice,srvector_slice,rvector>(v1,v2); 01235 } 01236 01238 inline rvector operator+(const srvector_slice& v1, const rvector_slice& v2) { 01239 return slf_vv_add<srvector_slice,rvector_slice,rvector>(v1,v2); 01240 } 01241 01243 inline srvector operator+(const srvector_slice& v1, const srvector_slice& v2) { 01244 return slsl_vv_add<srvector_slice,srvector_slice,srvector,real>(v1,v2); 01245 } 01246 01248 inline srvector operator+(const srvector& v1, const srvector_slice& v2) { 01249 return spsl_vv_add<srvector,srvector_slice,srvector,real>(v1,v2); 01250 } 01251 01253 inline srvector operator+(const srvector_slice& v1, const srvector& v2) { 01254 return slsp_vv_add<srvector_slice,srvector,srvector,real>(v1,v2); 01255 } 01256 01258 inline rvector operator-(const rvector& v1, const srvector_slice& v2) { 01259 return fsl_vv_sub<rvector,srvector_slice,rvector>(v1,v2); 01260 } 01261 01263 inline rvector operator-(const srvector_slice& v1, const rvector& v2) { 01264 return slf_vv_sub<srvector_slice,rvector,rvector>(v1,v2); 01265 } 01266 01268 inline rvector operator-(const rvector_slice& v1, const srvector_slice& v2) { 01269 return fsl_vv_sub<rvector_slice,srvector_slice,rvector>(v1,v2); 01270 } 01271 01273 inline rvector operator-(const srvector_slice& v1, const rvector_slice& v2) { 01274 return slf_vv_sub<srvector_slice,rvector_slice,rvector>(v1,v2); 01275 } 01276 01278 inline srvector operator-(const srvector_slice& v1, const srvector_slice& v2) { 01279 return slsl_vv_sub<srvector_slice,srvector_slice,srvector,real>(v1,v2); 01280 } 01281 01283 inline srvector operator-(const srvector& v1, const srvector_slice& v2) { 01284 return spsl_vv_sub<srvector,srvector_slice,srvector,real>(v1,v2); 01285 } 01286 01288 inline srvector operator-(const srvector_slice& v1, const srvector& v2) { 01289 return slsp_vv_sub<srvector_slice,srvector,srvector,real>(v1,v2); 01290 } 01291 01292 inline rvector& rvector::operator+=(const srvector_slice& v2) { 01293 return fsl_vv_addassign(*this,v2); 01294 } 01295 01296 inline rvector_slice& rvector_slice::operator+=(const srvector_slice& v2) { 01297 return fsl_vv_addassign(*this,v2); 01298 } 01299 01300 inline srvector& srvector::operator+=(const srvector_slice& v2) { 01301 return spsl_vv_addassign(*this,v2); 01302 } 01303 01304 inline rvector& rvector::operator-=(const srvector_slice& v2) { 01305 return fsl_vv_subassign(*this,v2); 01306 } 01307 01308 inline rvector_slice& rvector_slice::operator-=(const srvector_slice& v2) { 01309 return fsl_vv_subassign(*this,v2); 01310 } 01311 01312 inline srvector& srvector::operator-=(const srvector_slice& v2) { 01313 return spsl_vv_subassign(*this,v2); 01314 } 01315 01317 01320 inline bool operator==(const srvector_slice& v1, const srvector_slice& v2) { 01321 return slsl_vv_comp(v1,v2); 01322 } 01323 01325 01328 inline bool operator==(const srvector_slice& v1, const srvector& v2) { 01329 return slsp_vv_comp(v1,v2); 01330 } 01331 01333 01336 inline bool operator==(const srvector& v1, const srvector_slice& v2) { 01337 return spsl_vv_comp(v1,v2); 01338 } 01339 01341 01344 inline bool operator==(const srvector_slice& v1, const rvector& v2) { 01345 return slf_vv_comp(v1,v2); 01346 } 01347 01349 01352 inline bool operator==(const rvector& v1, const srvector_slice& v2) { 01353 return fsl_vv_comp(v1,v2); 01354 } 01355 01357 01360 inline bool operator==(const srvector_slice& v1, const rvector_slice& v2) { 01361 return slf_vv_comp(v1,v2); 01362 } 01363 01365 01368 inline bool operator==(const rvector_slice& v1, const srvector_slice& v2) { 01369 return fsl_vv_comp(v1,v2); 01370 } 01371 01373 01376 inline bool operator!=(const srvector_slice& v1, const srvector_slice& v2) { 01377 return !slsl_vv_comp(v1,v2); 01378 } 01379 01381 01384 inline bool operator!=(const srvector_slice& v1, const rvector& v2) { 01385 return !slf_vv_comp(v1,v2); 01386 } 01387 01389 01392 inline bool operator!=(const rvector& v1, const srvector_slice& v2) { 01393 return !fsl_vv_comp(v1,v2); 01394 } 01395 01397 01400 inline bool operator!=(const srvector_slice& v1, const srvector& v2) { 01401 return !slsp_vv_comp(v1,v2); 01402 } 01403 01405 01408 inline bool operator!=(const srvector& v1, const srvector_slice& v2) { 01409 return !spsl_vv_comp(v1,v2); 01410 } 01411 01413 01416 inline bool operator!=(const srvector_slice& v1, const rvector_slice& v2) { 01417 return !slf_vv_comp(v1,v2); 01418 } 01419 01421 01424 inline bool operator!=(const rvector_slice& v1, const srvector_slice& v2) { 01425 return !fsl_vv_comp(v1,v2); 01426 } 01427 01429 01432 inline bool operator<(const srvector_slice& v1, const srvector_slice& v2) { 01433 return slsl_vv_less<srvector_slice,srvector_slice,real>(v1,v2); 01434 } 01435 01437 01440 inline bool operator<(const srvector_slice& v1, const srvector& v2) { 01441 return slsp_vv_less<srvector_slice,srvector,real>(v1,v2); 01442 } 01443 01445 01448 inline bool operator<(const srvector& v1, const srvector_slice& v2) { 01449 return spsl_vv_less<srvector,srvector_slice,real>(v1,v2); 01450 } 01451 01453 01456 inline bool operator<(const srvector_slice& v1, const rvector& v2) { 01457 return slf_vv_less<srvector_slice,rvector,real>(v1,v2); 01458 } 01459 01461 01464 inline bool operator<(const rvector& v1, const srvector_slice& v2) { 01465 return fsl_vv_less<rvector,srvector_slice,real>(v1,v2); 01466 } 01467 01469 01472 inline bool operator<(const srvector_slice& v1, const rvector_slice& v2) { 01473 return slf_vv_less<srvector_slice,rvector_slice,real>(v1,v2); 01474 } 01475 01477 01480 inline bool operator<(const rvector_slice& v1, const srvector_slice& v2) { 01481 return fsl_vv_less<rvector_slice,srvector_slice,real>(v1,v2); 01482 } 01483 01485 01488 inline bool operator<=(const srvector_slice& v1, const srvector_slice& v2) { 01489 return slsl_vv_leq<srvector_slice,srvector_slice,real>(v1,v2); 01490 } 01491 01493 01496 inline bool operator<=(const srvector_slice& v1, const srvector& v2) { 01497 return slsp_vv_leq<srvector_slice,srvector,real>(v1,v2); 01498 } 01499 01501 01504 inline bool operator<=(const srvector& v1, const srvector_slice& v2) { 01505 return spsl_vv_leq<srvector,srvector_slice,real>(v1,v2); 01506 } 01507 01509 01512 inline bool operator<=(const srvector_slice& v1, const rvector& v2) { 01513 return slf_vv_leq<srvector_slice,rvector,real>(v1,v2); 01514 } 01515 01517 01520 inline bool operator<=(const rvector& v1, const srvector_slice& v2) { 01521 return fsl_vv_leq<rvector,srvector_slice,real>(v1,v2); 01522 } 01523 01525 01528 inline bool operator<=(const srvector_slice& v1, const rvector_slice& v2) { 01529 return slf_vv_leq<srvector_slice,rvector_slice,real>(v1,v2); 01530 } 01531 01533 01536 inline bool operator<=(const rvector_slice& v1, const srvector_slice& v2) { 01537 return fsl_vv_leq<rvector_slice,srvector_slice,real>(v1,v2); 01538 } 01539 01541 01544 inline bool operator>(const srvector_slice& v1, const srvector_slice& v2) { 01545 return slsl_vv_greater<srvector_slice,srvector_slice,real>(v1,v2); 01546 } 01547 01549 01552 inline bool operator>(const srvector_slice& v1, const srvector& v2) { 01553 return slsp_vv_greater<srvector_slice,srvector,real>(v1,v2); 01554 } 01555 01557 01560 inline bool operator>(const srvector& v1, const srvector_slice& v2) { 01561 return spsl_vv_greater<srvector,srvector_slice,real>(v1,v2); 01562 } 01563 01565 01568 inline bool operator>(const srvector_slice& v1, const rvector& v2) { 01569 return slf_vv_greater<srvector_slice,rvector,real>(v1,v2); 01570 } 01571 01573 01576 inline bool operator>(const rvector& v1, const srvector_slice& v2) { 01577 return fsl_vv_greater<rvector,srvector_slice,real>(v1,v2); 01578 } 01579 01581 01584 inline bool operator>(const srvector_slice& v1, const rvector_slice& v2) { 01585 return slf_vv_greater<srvector_slice,rvector_slice,real>(v1,v2); 01586 } 01587 01589 01592 inline bool operator>(const rvector_slice& v1, const srvector_slice& v2) { 01593 return fsl_vv_greater<rvector_slice,srvector_slice,real>(v1,v2); 01594 } 01595 01597 01600 inline bool operator>=(const srvector_slice& v1, const srvector_slice& v2) { 01601 return slsl_vv_geq<srvector_slice,srvector_slice,real>(v1,v2); 01602 } 01603 01605 01608 inline bool operator>=(const srvector_slice& v1, const srvector& v2) { 01609 return slsp_vv_geq<srvector_slice,srvector,real>(v1,v2); 01610 } 01611 01613 01616 inline bool operator>=(const srvector& v1, const srvector_slice& v2) { 01617 return spsl_vv_geq<srvector,srvector_slice,real>(v1,v2); 01618 } 01619 01621 01624 inline bool operator>=(const srvector_slice& v1, const rvector& v2) { 01625 return slf_vv_geq<srvector_slice,rvector,real>(v1,v2); 01626 } 01627 01629 01632 inline bool operator>=(const rvector& v1, const srvector_slice& v2) { 01633 return fsl_vv_geq<rvector,srvector_slice,real>(v1,v2); 01634 } 01635 01637 01640 inline bool operator>=(const srvector_slice& v1, const rvector_slice& v2) { 01641 return slf_vv_geq<srvector_slice,rvector_slice,real>(v1,v2); 01642 } 01643 01645 01648 inline bool operator>=(const rvector_slice& v1, const srvector_slice& v2) { 01649 return fsl_vv_geq<rvector_slice,srvector_slice,real>(v1,v2); 01650 } 01651 01653 01656 inline bool operator!(const srvector_slice& x) { 01657 return sl_v_not(x); 01658 } 01659 01661 01666 inline std::ostream& operator<<(std::ostream& os, const srvector_slice& v) { 01667 return sl_v_output<srvector_slice, real>(os,v); 01668 } 01669 01671 01676 inline std::istream& operator>>(std::istream& is, srvector_slice& v) { 01677 return sl_v_input<srvector_slice, real>(is,v); 01678 } 01679 01681 01684 inline void accumulate(dotprecision& dot, const srvector& x, const srvector& y) { 01685 spsp_vv_accu<dotprecision,srvector,srvector,sparse_dot>(dot,x,y); 01686 } 01687 01689 01692 inline void accumulate(dotprecision& dot, const srvector& x, const rvector& y) { 01693 spf_vv_accu<dotprecision,srvector,rvector,sparse_dot>(dot,x,y); 01694 } 01695 01697 01700 inline void accumulate(dotprecision& dot, const srvector& x, const rvector_slice& y) { 01701 spf_vv_accu<dotprecision,srvector,rvector_slice,sparse_dot>(dot,x,y); 01702 } 01703 01705 01708 inline void accumulate(dotprecision& dot, const rvector& x, const srvector& y) { 01709 fsp_vv_accu<dotprecision,rvector,srvector,sparse_dot>(dot,x,y); 01710 } 01711 01713 01716 inline void accumulate(dotprecision& dot, const rvector_slice& x, const srvector& y) { 01717 fsp_vv_accu<dotprecision,rvector_slice,srvector,sparse_dot>(dot,x,y); 01718 } 01719 01721 01724 inline void accumulate(dotprecision& dot, const srvector_slice& x, const rvector& y) { 01725 slf_vv_accu<dotprecision,srvector_slice,rvector,sparse_dot>(dot,x,y); 01726 } 01727 01729 01732 inline void accumulate(dotprecision& dot, const srvector_slice& x, const rvector_slice& y) { 01733 slf_vv_accu<dotprecision,srvector_slice,rvector_slice,sparse_dot>(dot,x,y); 01734 } 01735 01737 01740 inline void accumulate(dotprecision& dot, const rvector& x, const srvector_slice& y) { 01741 fsl_vv_accu<dotprecision,rvector,srvector_slice,sparse_dot>(dot,x,y); 01742 } 01743 01745 01748 inline void accumulate(dotprecision& dot, const rvector_slice& x, const srvector_slice& y) { 01749 fsl_vv_accu<dotprecision,rvector_slice,srvector_slice,sparse_dot>(dot,x,y); 01750 } 01751 01753 01756 inline void accumulate(dotprecision& dot, const srvector_slice& x, const srvector_slice& y) { 01757 slsl_vv_accu<dotprecision,srvector_slice,srvector_slice,sparse_dot>(dot,x,y); 01758 } 01759 01761 01764 inline void accumulate(dotprecision& dot, const srvector& x, const srvector_slice& y) { 01765 spsl_vv_accu<dotprecision,srvector,srvector_slice,sparse_dot>(dot,x,y); 01766 } 01767 01769 01772 inline void accumulate(dotprecision& dot, const srvector_slice& x, const srvector& y) { 01773 slsp_vv_accu<dotprecision,srvector_slice,srvector,sparse_dot>(dot,x,y); 01774 } 01775 01777 01781 inline void accumulate_approx(dotprecision& dot, const srvector& x, const srvector& y) { 01782 spsp_vv_accuapprox<dotprecision,srvector,srvector,sparse_dot>(dot,x,y); 01783 } 01784 01786 01790 inline void accumulate_approx(dotprecision& dot, const srvector& x, const rvector& y) { 01791 spf_vv_accuapprox<dotprecision,srvector,rvector,sparse_dot>(dot,x,y); 01792 } 01793 01795 01799 inline void accumulate_approx(dotprecision& dot, const srvector& x, const rvector_slice& y) { 01800 spf_vv_accuapprox<dotprecision,srvector,rvector_slice,sparse_dot>(dot,x,y); 01801 } 01802 01804 01808 inline void accumulate_approx(dotprecision& dot, const rvector& x, const srvector& y) { 01809 fsp_vv_accuapprox<dotprecision,rvector,srvector,sparse_dot>(dot,x,y); 01810 } 01811 01813 01817 inline void accumulate_approx(dotprecision& dot, const rvector_slice& x, const srvector& y) { 01818 fsp_vv_accuapprox<dotprecision,rvector_slice,srvector,sparse_dot>(dot,x,y); 01819 } 01820 01822 01826 inline void accumulate_approx(dotprecision& dot, const srvector_slice& x, const rvector& y) { 01827 slf_vv_accuapprox<dotprecision,srvector_slice,rvector,sparse_dot>(dot,x,y); 01828 } 01829 01831 01835 inline void accumulate_approx(dotprecision& dot, const srvector_slice& x, const rvector_slice& y) { 01836 slf_vv_accuapprox<dotprecision,srvector_slice,rvector_slice,sparse_dot>(dot,x,y); 01837 } 01838 01840 01844 inline void accumulate_approx(dotprecision& dot, const rvector& x, const srvector_slice& y) { 01845 fsl_vv_accuapprox<dotprecision,rvector,srvector_slice,sparse_dot>(dot,x,y); 01846 } 01847 01849 01853 inline void accumulate_approx(dotprecision& dot, const rvector_slice& x, const srvector_slice& y) { 01854 fsl_vv_accuapprox<dotprecision,rvector_slice,srvector_slice,sparse_dot>(dot,x,y); 01855 } 01856 01858 01862 inline void accumulate_approx(dotprecision& dot, const srvector_slice& x, const srvector_slice& y) { 01863 slsl_vv_accuapprox<dotprecision,srvector_slice,srvector_slice,sparse_dot>(dot,x,y); 01864 } 01865 01867 01871 inline void accumulate_approx(dotprecision& dot, const srvector& x, const srvector_slice& y) { 01872 spsl_vv_accuapprox<dotprecision,srvector,srvector_slice,sparse_dot>(dot,x,y); 01873 } 01874 01876 01880 inline void accumulate_approx(dotprecision& dot, const srvector_slice& x, const srvector& y) { 01881 slsp_vv_accuapprox<dotprecision,srvector_slice,srvector,sparse_dot>(dot,x,y); 01882 } 01883 01885 01888 inline void accumulate(idotprecision& dot, const srvector& x, const srvector& y) { 01889 dotprecision tmp(0.0); 01890 tmp.set_k(dot.get_k()); 01891 accumulate(tmp,x,y); 01892 dot += tmp; 01893 } 01894 01896 01899 inline void accumulate(idotprecision& dot, const srvector& x, const rvector& y) { 01900 dotprecision tmp(0.0); 01901 tmp.set_k(dot.get_k()); 01902 accumulate(tmp,x,y); 01903 dot += tmp; 01904 } 01905 01907 01910 inline void accumulate(idotprecision& dot, const srvector& x, const rvector_slice& y) { 01911 dotprecision tmp(0.0); 01912 tmp.set_k(dot.get_k()); 01913 accumulate(tmp,x,y); 01914 dot += tmp; 01915 } 01916 01918 01921 inline void accumulate(idotprecision& dot, const rvector& x, const srvector& y) { 01922 dotprecision tmp(0.0); 01923 tmp.set_k(dot.get_k()); 01924 accumulate(tmp,x,y); 01925 dot += tmp; 01926 } 01927 01929 01932 inline void accumulate(idotprecision& dot, const rvector_slice& x, const srvector& y) { 01933 dotprecision tmp(0.0); 01934 tmp.set_k(dot.get_k()); 01935 accumulate(tmp,x,y); 01936 dot += tmp; 01937 } 01938 01940 01943 inline void accumulate(idotprecision& dot, const srvector_slice& x, const rvector& y) { 01944 dotprecision tmp(0.0); 01945 tmp.set_k(dot.get_k()); 01946 accumulate(tmp,x,y); 01947 dot += tmp; 01948 } 01949 01951 01954 inline void accumulate(idotprecision& dot, const srvector_slice& x, const rvector_slice& y) { 01955 dotprecision tmp(0.0); 01956 tmp.set_k(dot.get_k()); 01957 accumulate(tmp,x,y); 01958 dot += tmp; 01959 } 01960 01962 01965 inline void accumulate(idotprecision& dot, const rvector& x, const srvector_slice& y) { 01966 dotprecision tmp(0.0); 01967 tmp.set_k(dot.get_k()); 01968 accumulate(tmp,x,y); 01969 dot += tmp; 01970 } 01971 01973 01976 inline void accumulate(idotprecision& dot, const rvector_slice& x, const srvector_slice& y) { 01977 dotprecision tmp(0.0); 01978 tmp.set_k(dot.get_k()); 01979 accumulate(tmp,x,y); 01980 dot += tmp; 01981 } 01982 01984 01987 inline void accumulate(idotprecision& dot, const srvector_slice& x, const srvector_slice& y) { 01988 dotprecision tmp(0.0); 01989 tmp.set_k(dot.get_k()); 01990 accumulate(tmp,x,y); 01991 dot += tmp; 01992 } 01993 01995 01998 inline void accumulate(idotprecision& dot, const srvector& x, const srvector_slice& y) { 01999 dotprecision tmp(0.0); 02000 tmp.set_k(dot.get_k()); 02001 accumulate(tmp,x,y); 02002 dot += tmp; 02003 } 02004 02006 02009 inline void accumulate(idotprecision& dot, const srvector_slice& x, const srvector& y) { 02010 dotprecision tmp(0.0); 02011 tmp.set_k(dot.get_k()); 02012 accumulate(tmp,x,y); 02013 dot += tmp; 02014 } 02015 02017 02020 inline void accumulate(cdotprecision& dot, const srvector& x, const srvector& y) { 02021 dotprecision tmp(0.0); 02022 tmp.set_k(dot.get_k()); 02023 accumulate(tmp,x,y); 02024 dot += tmp; 02025 } 02026 02028 02031 inline void accumulate(cdotprecision& dot, const srvector& x, const rvector& y) { 02032 dotprecision tmp(0.0); 02033 tmp.set_k(dot.get_k()); 02034 accumulate(tmp,x,y); 02035 dot += tmp; 02036 } 02037 02039 02042 inline void accumulate(cdotprecision& dot, const srvector& x, const rvector_slice& y) { 02043 dotprecision tmp(0.0); 02044 tmp.set_k(dot.get_k()); 02045 accumulate(tmp,x,y); 02046 dot += tmp; 02047 } 02048 02050 02053 inline void accumulate(cdotprecision& dot, const rvector& x, const srvector& y) { 02054 dotprecision tmp(0.0); 02055 tmp.set_k(dot.get_k()); 02056 accumulate(tmp,x,y); 02057 dot += tmp; 02058 } 02059 02061 02064 inline void accumulate(cdotprecision& dot, const rvector_slice& x, const srvector& y) { 02065 dotprecision tmp(0.0); 02066 tmp.set_k(dot.get_k()); 02067 accumulate(tmp,x,y); 02068 dot += tmp; 02069 } 02070 02072 02075 inline void accumulate(cdotprecision& dot, const srvector_slice& x, const rvector& y) { 02076 dotprecision tmp(0.0); 02077 tmp.set_k(dot.get_k()); 02078 accumulate(tmp,x,y); 02079 dot += tmp; 02080 } 02081 02083 02086 inline void accumulate(cdotprecision& dot, const srvector_slice& x, const rvector_slice& y) { 02087 dotprecision tmp(0.0); 02088 tmp.set_k(dot.get_k()); 02089 accumulate(tmp,x,y); 02090 dot += tmp; 02091 } 02092 02094 02097 inline void accumulate(cdotprecision& dot, const rvector& x, const srvector_slice& y) { 02098 dotprecision tmp(0.0); 02099 tmp.set_k(dot.get_k()); 02100 accumulate(tmp,x,y); 02101 dot += tmp; 02102 } 02103 02105 02108 inline void accumulate(cdotprecision& dot, const rvector_slice& x, const srvector_slice& y) { 02109 dotprecision tmp(0.0); 02110 tmp.set_k(dot.get_k()); 02111 accumulate(tmp,x,y); 02112 dot += tmp; 02113 } 02114 02116 02119 inline void accumulate(cdotprecision& dot, const srvector_slice& x, const srvector_slice& y) { 02120 dotprecision tmp(0.0); 02121 tmp.set_k(dot.get_k()); 02122 accumulate(tmp,x,y); 02123 dot += tmp; 02124 } 02125 02127 02130 inline void accumulate(cdotprecision& dot, const srvector& x, const srvector_slice& y) { 02131 dotprecision tmp(0.0); 02132 tmp.set_k(dot.get_k()); 02133 accumulate(tmp,x,y); 02134 dot += tmp; 02135 } 02136 02138 02141 inline void accumulate(cdotprecision& dot, const srvector_slice& x, const srvector& y) { 02142 dotprecision tmp(0.0); 02143 tmp.set_k(dot.get_k()); 02144 accumulate(tmp,x,y); 02145 dot += tmp; 02146 } 02147 02149 02153 inline void accumulate_approx(cdotprecision& dot, const srvector& x, const srvector& y) { 02154 dotprecision tmp(0.0); 02155 tmp.set_k(dot.get_k()); 02156 accumulate_approx(tmp,x,y); 02157 dot += tmp; 02158 } 02159 02161 02165 inline void accumulate_approx(cdotprecision& dot, const srvector& x, const rvector& y) { 02166 dotprecision tmp(0.0); 02167 tmp.set_k(dot.get_k()); 02168 accumulate_approx(tmp,x,y); 02169 dot += tmp; 02170 } 02171 02173 02177 inline void accumulate_approx(cdotprecision& dot, const srvector& x, const rvector_slice& y) { 02178 dotprecision tmp(0.0); 02179 tmp.set_k(dot.get_k()); 02180 accumulate_approx(tmp,x,y); 02181 dot += tmp; 02182 } 02183 02185 02189 inline void accumulate_approx(cdotprecision& dot, const rvector& x, const srvector& y) { 02190 dotprecision tmp(0.0); 02191 tmp.set_k(dot.get_k()); 02192 accumulate_approx(tmp,x,y); 02193 dot += tmp; 02194 } 02195 02197 02201 inline void accumulate_approx(cdotprecision& dot, const rvector_slice& x, const srvector& y) { 02202 dotprecision tmp(0.0); 02203 tmp.set_k(dot.get_k()); 02204 accumulate_approx(tmp,x,y); 02205 dot += tmp; 02206 } 02207 02209 02213 inline void accumulate_approx(cdotprecision& dot, const srvector_slice& x, const rvector& y) { 02214 dotprecision tmp(0.0); 02215 tmp.set_k(dot.get_k()); 02216 accumulate_approx(tmp,x,y); 02217 dot += tmp; 02218 } 02219 02221 02225 inline void accumulate_approx(cdotprecision& dot, const srvector_slice& x, const rvector_slice& y) { 02226 dotprecision tmp(0.0); 02227 tmp.set_k(dot.get_k()); 02228 accumulate_approx(tmp,x,y); 02229 dot += tmp; 02230 } 02231 02233 02237 inline void accumulate_approx(cdotprecision& dot, const rvector& x, const srvector_slice& y) { 02238 dotprecision tmp(0.0); 02239 tmp.set_k(dot.get_k()); 02240 accumulate_approx(tmp,x,y); 02241 dot += tmp; 02242 } 02243 02245 02249 inline void accumulate_approx(cdotprecision& dot, const rvector_slice& x, const srvector_slice& y) { 02250 dotprecision tmp(0.0); 02251 tmp.set_k(dot.get_k()); 02252 accumulate_approx(tmp,x,y); 02253 dot += tmp; 02254 } 02255 02257 02261 inline void accumulate_approx(cdotprecision& dot, const srvector_slice& x, const srvector_slice& y) { 02262 dotprecision tmp(0.0); 02263 tmp.set_k(dot.get_k()); 02264 accumulate_approx(tmp,x,y); 02265 dot += tmp; 02266 } 02267 02269 02273 inline void accumulate_approx(cdotprecision& dot, const srvector& x, const srvector_slice& y) { 02274 dotprecision tmp(0.0); 02275 tmp.set_k(dot.get_k()); 02276 accumulate_approx(tmp,x,y); 02277 dot += tmp; 02278 } 02279 02281 02285 inline void accumulate_approx(cdotprecision& dot, const srvector_slice& x, const srvector& y) { 02286 dotprecision tmp(0.0); 02287 tmp.set_k(dot.get_k()); 02288 accumulate_approx(tmp,x,y); 02289 dot += tmp; 02290 } 02291 02293 02296 inline void accumulate(cidotprecision& dot, const srvector& x, const srvector& y) { 02297 dotprecision tmp(0.0); 02298 tmp.set_k(dot.get_k()); 02299 accumulate(tmp,x,y); 02300 dot += tmp; 02301 } 02302 02304 02307 inline void accumulate(cidotprecision& dot, const srvector& x, const rvector& y) { 02308 dotprecision tmp(0.0); 02309 tmp.set_k(dot.get_k()); 02310 accumulate(tmp,x,y); 02311 dot += tmp; 02312 } 02313 02315 02318 inline void accumulate(cidotprecision& dot, const srvector& x, const rvector_slice& y) { 02319 dotprecision tmp(0.0); 02320 tmp.set_k(dot.get_k()); 02321 accumulate(tmp,x,y); 02322 dot += tmp; 02323 } 02324 02326 02329 inline void accumulate(cidotprecision& dot, const rvector& x, const srvector& y) { 02330 dotprecision tmp(0.0); 02331 tmp.set_k(dot.get_k()); 02332 accumulate(tmp,x,y); 02333 dot += tmp; 02334 } 02335 02337 02340 inline void accumulate(cidotprecision& dot, const rvector_slice& x, const srvector& y) { 02341 dotprecision tmp(0.0); 02342 tmp.set_k(dot.get_k()); 02343 accumulate(tmp,x,y); 02344 dot += tmp; 02345 } 02346 02348 02351 inline void accumulate(cidotprecision& dot, const srvector_slice& x, const rvector& y) { 02352 dotprecision tmp(0.0); 02353 tmp.set_k(dot.get_k()); 02354 accumulate(tmp,x,y); 02355 dot += tmp; 02356 } 02357 02359 02362 inline void accumulate(cidotprecision& dot, const srvector_slice& x, const rvector_slice& y) { 02363 dotprecision tmp(0.0); 02364 tmp.set_k(dot.get_k()); 02365 accumulate(tmp,x,y); 02366 dot += tmp; 02367 } 02368 02370 02373 inline void accumulate(cidotprecision& dot, const rvector& x, const srvector_slice& y) { 02374 dotprecision tmp(0.0); 02375 tmp.set_k(dot.get_k()); 02376 accumulate(tmp,x,y); 02377 dot += tmp; 02378 } 02379 02381 02384 inline void accumulate(cidotprecision& dot, const rvector_slice& x, const srvector_slice& y) { 02385 dotprecision tmp(0.0); 02386 tmp.set_k(dot.get_k()); 02387 accumulate(tmp,x,y); 02388 dot += tmp; 02389 } 02390 02392 02395 inline void accumulate(cidotprecision& dot, const srvector_slice& x, const srvector_slice& y) { 02396 dotprecision tmp(0.0); 02397 tmp.set_k(dot.get_k()); 02398 accumulate(tmp,x,y); 02399 dot += tmp; 02400 } 02401 02403 02406 inline void accumulate(cidotprecision& dot, const srvector& x, const srvector_slice& y) { 02407 dotprecision tmp(0.0); 02408 tmp.set_k(dot.get_k()); 02409 accumulate(tmp,x,y); 02410 dot += tmp; 02411 } 02412 02414 02417 inline void accumulate(cidotprecision& dot, const srvector_slice& x, const srvector& y) { 02418 dotprecision tmp(0.0); 02419 tmp.set_k(dot.get_k()); 02420 accumulate(tmp,x,y); 02421 dot += tmp; 02422 } 02423 02424 02425 } //namespace cxsc 02426 02427 #include "sparsevector.inl" 02428 02429 #endif