C-XSC - A C++ Class Library for Extended Scientific Computing  2.5.4
rvector.cpp
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: rvector.cpp,v 1.26 2014/01/30 17:23:48 cxsc Exp $ */
00025 
00026 #define _CXSC_CPP
00027 
00028 #include "rvector.hpp"
00029 #include "vector.inl"
00030 #include "rvector.inl"
00031 
00032 #include "dotk.inl"
00033 
00034 
00035 namespace cxsc {
00036 
00037 
00038         void accumulate(dotprecision &dp, const rvector & rv1, const rvector &rv2)
00039 #if(CXSC_INDEX_CHECK)
00040         throw(OP_WITH_WRONG_DIM)
00041 #else
00042         throw()
00043 #endif
00044         { 
00045 #if(CXSC_INDEX_CHECK)
00046                 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(dotprecision&, const rvector &, const rvector &)"));
00047 #endif
00048                 addDot(dp,rv1,rv2); 
00049         }
00050 
00051         void accumulate_approx(dotprecision &dp, const rvector & rv1, const rvector &rv2) {
00052                 addDot_op(dp,rv1,rv2);
00053         }
00054 
00055 
00056 //      INLINE void accumulate(dotprecision &dp, const rvector & rv1, const rmatrix_subv &rv2) throw(OP_WITH_WRONG_DIM);
00057 //      INLINE void accumulate(dotprecision &dp, const rmatrix_subv & rv1, const rvector &rv2) throw(OP_WITH_WRONG_DIM);
00058         void accumulate(dotprecision &dp,const rvector_slice &sl,const rvector &rv)
00059 #if(CXSC_INDEX_CHECK)
00060         throw(OP_WITH_WRONG_DIM)
00061 #else
00062         throw()
00063 #endif
00064         { 
00065 #if(CXSC_INDEX_CHECK)
00066                 if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(dotprecision&, const rvector_slice &, const rvector &)"));
00067 #endif
00068                 addDot(dp,sl,rv); 
00069         }
00070 
00071         void accumulate_approx(dotprecision &dp,const rvector_slice &sl,const rvector &rv) {
00072                 addDot_op(dp,sl,rv);
00073         }
00074 
00075         void accumulate(dotprecision &dp,const rvector &rv,const rvector_slice &sl)
00076 #if(CXSC_INDEX_CHECK)
00077         throw(OP_WITH_WRONG_DIM)
00078 #else
00079         throw()
00080 #endif
00081         { 
00082 #if(CXSC_INDEX_CHECK)
00083                 if(VecLen(rv)!=VecLen(sl)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(dotprecision&, const rvector &, const rvector_slice &)"));
00084 #endif
00085                 addDot(dp,sl,rv); 
00086         }
00087 
00088         void accumulate_approx(dotprecision &dp,const rvector &rv,const rvector_slice &sl) {
00089                 addDot_op(dp,rv,sl);
00090         }
00091 
00092         void accumulate(dotprecision &dp, const rvector_slice & sl1, const rvector_slice &sl2)
00093 #if(CXSC_INDEX_CHECK)
00094         throw(OP_WITH_WRONG_DIM)
00095 #else
00096         throw()
00097 #endif
00098         { 
00099 #if(CXSC_INDEX_CHECK)
00100                 if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(dotprecision&, const rvector_slice &, const rvector_slice &)"));
00101 #endif
00102                 addDot(dp,sl1,sl2); 
00103         }
00104 
00105         void accumulate_approx(dotprecision &dp, const rvector_slice & sl1, const rvector_slice &sl2) {
00106                 addDot_op(dp,sl1,sl2);
00107         }
00108 
00109 
00110         void accumulate(idotprecision &dp, const rvector & rv1, const rvector &rv2)
00111 #if(CXSC_INDEX_CHECK)
00112         throw(OP_WITH_WRONG_DIM)
00113 #else
00114         throw()
00115 #endif
00116         { 
00117 #if(CXSC_INDEX_CHECK)
00118                 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(idotprecision&, const rvector &, const rvector &)"));
00119 #endif
00120                 dotprecision tmp(0.0);
00121                 tmp.set_k(dp.get_k());
00122                 addDot(tmp,rv1,rv2);
00123                 dp += tmp;
00124         }
00125 
00126 //      INLINE void accumulate(idotprecision &dp, const rvector & rv1, const rmatrix_subv &rv2) throw(OP_WITH_WRONG_DIM);
00127 //      INLINE void accumulate(idotprecision &dp, const rmatrix_subv & rv1, const rvector &rv2) throw(OP_WITH_WRONG_DIM);
00128 
00129 
00130         void accumulate(idotprecision &dp,const rvector_slice &sl,const rvector &rv)
00131 #if(CXSC_INDEX_CHECK)
00132         throw(OP_WITH_WRONG_DIM)
00133 #else
00134         throw()
00135 #endif
00136         { 
00137 #if(CXSC_INDEX_CHECK)
00138                 if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(idotprecision&, const rvector_slice &, const rvector &)"));
00139 #endif
00140                 dotprecision tmp(0.0);
00141                 tmp.set_k(dp.get_k());
00142                 addDot(tmp,sl,rv);
00143                 dp += tmp;
00144         }
00145 
00146 
00147         void accumulate(idotprecision &dp,const rvector &rv,const rvector_slice &sl)
00148 #if(CXSC_INDEX_CHECK)
00149         throw(OP_WITH_WRONG_DIM)
00150 #else
00151         throw()
00152 #endif
00153         { 
00154 #if(CXSC_INDEX_CHECK)
00155                 if(VecLen(rv)!=VecLen(sl)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(idotprecision&, const rvector &, const rvector_slice &)"));
00156 #endif
00157                 dotprecision tmp(0.0);
00158                 tmp.set_k(dp.get_k());
00159                 addDot(tmp,rv,sl);
00160                 dp += tmp;
00161         }
00162 
00163         void accumulate(idotprecision &dp, const rvector_slice & sl1, const rvector_slice &sl2)
00164 #if(CXSC_INDEX_CHECK)
00165         throw(OP_WITH_WRONG_DIM)
00166 #else
00167         throw()
00168 #endif
00169         { 
00170 #if(CXSC_INDEX_CHECK)
00171                 if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(idotprecision&, const rvector_slice &, const rvector_slice &)"));
00172 #endif
00173                 dotprecision tmp(0.0);
00174                 tmp.set_k(dp.get_k());
00175                 addDot(tmp,sl1,sl2);
00176                 dp += tmp;
00177         }
00178 
00179         void accumulate(cdotprecision &dp, const rvector & rv1, const rvector &rv2)
00180 #if(CXSC_INDEX_CHECK)
00181         throw(OP_WITH_WRONG_DIM)
00182 #else
00183         throw()
00184 #endif
00185         { 
00186 #if(CXSC_INDEX_CHECK)
00187                 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const rvector &, const rvector &)"));
00188 #endif
00189                 addDot(Re(dp),rv1,rv2); 
00190         }
00191 
00192         void accumulate_approx(cdotprecision &dp, const rvector & rv1, const rvector &rv2)
00193         { 
00194                 addDot_op(Re(dp),rv1,rv2); 
00195         }
00196 
00197 //      INLINE void accumulate(cdotprecision &dp, const rvector & rv1, const rmatrix_subv &rv2) throw(OP_WITH_WRONG_DIM);
00198 //      INLINE void accumulate(cdotprecision &dp, const rmatrix_subv & rv1, const rvector &rv2) throw(OP_WITH_WRONG_DIM);
00199 
00200 
00201         void accumulate(cdotprecision &dp,const rvector_slice &sl,const rvector &rv)
00202 #if(CXSC_INDEX_CHECK)
00203         throw(OP_WITH_WRONG_DIM)
00204 #else
00205         throw()
00206 #endif
00207         { 
00208 #if(CXSC_INDEX_CHECK)
00209                 if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const rvector_slice &, const rvector &)"));
00210 #endif
00211                 addDot(Re(dp),sl,rv);
00212         }
00213 
00214         void accumulate_approx(cdotprecision &dp,const rvector_slice &sl,const rvector &rv)
00215         { 
00216                 addDot_op(Re(dp),sl,rv);
00217         }
00218 
00219 
00220         void accumulate(cdotprecision &dp,const rvector &rv,const rvector_slice &sl)
00221 #if(CXSC_INDEX_CHECK)
00222         throw(OP_WITH_WRONG_DIM)
00223 #else
00224         throw()
00225 #endif
00226         { 
00227 #if(CXSC_INDEX_CHECK)
00228                 if(VecLen(rv)!=VecLen(sl)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const rvector &, const rvector_slice &)"));
00229 #endif
00230                 addDot(Re(dp),rv,sl);
00231         }
00232 
00233         void accumulate_approx(cdotprecision &dp,const rvector &rv,const rvector_slice &sl)
00234         { 
00235                 addDot_op(Re(dp),rv,sl);
00236         }
00237 
00238 
00239         void accumulate(cdotprecision &dp, const rvector_slice & sl1, const rvector_slice &sl2)
00240 #if(CXSC_INDEX_CHECK)
00241         throw(OP_WITH_WRONG_DIM)
00242 #else
00243         throw()
00244 #endif
00245         { 
00246 #if(CXSC_INDEX_CHECK)
00247                 if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const rvector_slice &, const rvector_slice &)"));
00248 #endif
00249                 addDot(Re(dp),sl1,sl2);
00250         }
00251 
00252         void accumulate_approx(cdotprecision &dp, const rvector_slice & sl1, const rvector_slice &sl2)
00253         { 
00254                 addDot_op(Re(dp),sl1,sl2);
00255         }
00256 
00257 
00258         void accumulate(cidotprecision &dp, const rvector & rv1, const rvector &rv2)
00259 #if(CXSC_INDEX_CHECK)
00260         throw(OP_WITH_WRONG_DIM)
00261 #else
00262         throw()
00263 #endif
00264         { 
00265 #if(CXSC_INDEX_CHECK)
00266                 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const rvector &, const rvector &)"));
00267 #endif
00268                 dotprecision tmp(0.0);
00269                 tmp.set_k(dp.get_k());
00270                 addDot(tmp,rv1,rv2);
00271                 dp += tmp;
00272         }
00273 
00274 //      INLINE void accumulate(cidotprecision &dp, const rvector & rv1, const rmatrix_subv &rv2) throw(OP_WITH_WRONG_DIM);
00275 //      INLINE void accumulate(cidotprecision &dp, const rmatrix_subv & rv1, const rvector &rv2) throw(OP_WITH_WRONG_DIM);
00276 
00277 
00278         void accumulate(cidotprecision &dp,const rvector_slice &sl,const rvector &rv)
00279 #if(CXSC_INDEX_CHECK)
00280         throw(OP_WITH_WRONG_DIM)
00281 #else
00282         throw()
00283 #endif
00284         { 
00285 #if(CXSC_INDEX_CHECK)
00286                 if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const rvector_slice &, const rvector &)"));
00287 #endif
00288                 dotprecision tmp(0.0);
00289                 tmp.set_k(dp.get_k());
00290                 addDot(tmp,sl,rv);
00291                 dp += tmp;
00292         }
00293 
00294 
00295         void accumulate(cidotprecision &dp,const rvector &rv,const rvector_slice &sl)
00296 #if(CXSC_INDEX_CHECK)
00297         throw(OP_WITH_WRONG_DIM)
00298 #else
00299         throw()
00300 #endif
00301         { 
00302 #if(CXSC_INDEX_CHECK)
00303                 if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const rvector &, const rvector_slice &)"));
00304 #endif
00305                 dotprecision tmp(0.0);
00306                 tmp.set_k(dp.get_k());
00307                 addDot(tmp,rv,sl);
00308                 dp += tmp;
00309         }
00310 
00311 
00312         void accumulate(cidotprecision &dp, const rvector_slice & sl1, const rvector_slice &sl2)
00313 #if(CXSC_INDEX_CHECK)
00314         throw(OP_WITH_WRONG_DIM)
00315 #else
00316         throw()
00317 #endif
00318         { 
00319 #if(CXSC_INDEX_CHECK)
00320                 if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const rvector_slice &, const rvector_slice &)"));
00321 #endif
00322                 dotprecision tmp(0.0);
00323                 tmp.set_k(dp.get_k());
00324                 addDot(tmp,sl1,sl2);
00325                 dp += tmp;
00326         }
00327 
00328 
00329         //Summation accumulates
00330         void accumulate(dotprecision &dp, const rvector& v) {
00331                 addSum(dp,v);
00332         }
00333 
00334         void accumulate(idotprecision &dp, const rvector& v) {
00335                 dotprecision tmp(0.0);
00336                 tmp.set_k(dp.get_k());   
00337                 addSum(tmp,v);
00338                 Inf(dp) += tmp;
00339                 Sup(dp) += tmp;
00340         }
00341 
00342         void accumulate(cdotprecision &dp, const rvector& v) {
00343                 addSum(Re(dp),v);
00344         }
00345 
00346         void accumulate(cidotprecision &dp, const rvector& v) {
00347                 dotprecision tmp(0.0);
00348                 tmp.set_k(dp.get_k());   
00349                 addSum(tmp,v);
00350                 InfRe(dp) += tmp;
00351                 SupRe(dp) += tmp;
00352         }
00353 }