C-XSC - A C++ Class Library for Extended Scientific Computing  2.5.4
rvector.cpp
1 /*
2 ** CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4)
3 **
4 ** Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik,
5 ** Universitaet Karlsruhe, Germany
6 ** (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie
7 ** Universitaet Wuppertal, Germany
8 **
9 ** This library is free software; you can redistribute it and/or
10 ** modify it under the terms of the GNU Library General Public
11 ** License as published by the Free Software Foundation; either
12 ** version 2 of the License, or (at your option) any later version.
13 **
14 ** This library is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ** Library General Public License for more details.
18 **
19 ** You should have received a copy of the GNU Library General Public
20 ** License along with this library; if not, write to the Free
21 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23 
24 /* CVS $Id: rvector.cpp,v 1.26 2014/01/30 17:23:48 cxsc Exp $ */
25 
26 #define _CXSC_CPP
27 
28 #include "rvector.hpp"
29 #include "vector.inl"
30 #include "rvector.inl"
31 
32 #include "dotk.inl"
33 
34 
35 namespace cxsc {
36 
37 
38  void accumulate(dotprecision &dp, const rvector & rv1, const rvector &rv2)
39 #if(CXSC_INDEX_CHECK)
40  throw(OP_WITH_WRONG_DIM)
41 #else
42  throw()
43 #endif
44  {
45 #if(CXSC_INDEX_CHECK)
46  if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(dotprecision&, const rvector &, const rvector &)"));
47 #endif
48  addDot(dp,rv1,rv2);
49  }
50 
51  void accumulate_approx(dotprecision &dp, const rvector & rv1, const rvector &rv2) {
52  addDot_op(dp,rv1,rv2);
53  }
54 
55 
56 // INLINE void accumulate(dotprecision &dp, const rvector & rv1, const rmatrix_subv &rv2) throw(OP_WITH_WRONG_DIM);
57 // INLINE void accumulate(dotprecision &dp, const rmatrix_subv & rv1, const rvector &rv2) throw(OP_WITH_WRONG_DIM);
58  void accumulate(dotprecision &dp,const rvector_slice &sl,const rvector &rv)
59 #if(CXSC_INDEX_CHECK)
60  throw(OP_WITH_WRONG_DIM)
61 #else
62  throw()
63 #endif
64  {
65 #if(CXSC_INDEX_CHECK)
66  if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(dotprecision&, const rvector_slice &, const rvector &)"));
67 #endif
68  addDot(dp,sl,rv);
69  }
70 
71  void accumulate_approx(dotprecision &dp,const rvector_slice &sl,const rvector &rv) {
72  addDot_op(dp,sl,rv);
73  }
74 
75  void accumulate(dotprecision &dp,const rvector &rv,const rvector_slice &sl)
76 #if(CXSC_INDEX_CHECK)
77  throw(OP_WITH_WRONG_DIM)
78 #else
79  throw()
80 #endif
81  {
82 #if(CXSC_INDEX_CHECK)
83  if(VecLen(rv)!=VecLen(sl)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(dotprecision&, const rvector &, const rvector_slice &)"));
84 #endif
85  addDot(dp,sl,rv);
86  }
87 
88  void accumulate_approx(dotprecision &dp,const rvector &rv,const rvector_slice &sl) {
89  addDot_op(dp,rv,sl);
90  }
91 
92  void accumulate(dotprecision &dp, const rvector_slice & sl1, const rvector_slice &sl2)
93 #if(CXSC_INDEX_CHECK)
94  throw(OP_WITH_WRONG_DIM)
95 #else
96  throw()
97 #endif
98  {
99 #if(CXSC_INDEX_CHECK)
100  if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(dotprecision&, const rvector_slice &, const rvector_slice &)"));
101 #endif
102  addDot(dp,sl1,sl2);
103  }
104 
105  void accumulate_approx(dotprecision &dp, const rvector_slice & sl1, const rvector_slice &sl2) {
106  addDot_op(dp,sl1,sl2);
107  }
108 
109 
110  void accumulate(idotprecision &dp, const rvector & rv1, const rvector &rv2)
111 #if(CXSC_INDEX_CHECK)
112  throw(OP_WITH_WRONG_DIM)
113 #else
114  throw()
115 #endif
116  {
117 #if(CXSC_INDEX_CHECK)
118  if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(idotprecision&, const rvector &, const rvector &)"));
119 #endif
120  dotprecision tmp(0.0);
121  tmp.set_k(dp.get_k());
122  addDot(tmp,rv1,rv2);
123  dp += tmp;
124  }
125 
126 // INLINE void accumulate(idotprecision &dp, const rvector & rv1, const rmatrix_subv &rv2) throw(OP_WITH_WRONG_DIM);
127 // INLINE void accumulate(idotprecision &dp, const rmatrix_subv & rv1, const rvector &rv2) throw(OP_WITH_WRONG_DIM);
128 
129 
130  void accumulate(idotprecision &dp,const rvector_slice &sl,const rvector &rv)
131 #if(CXSC_INDEX_CHECK)
132  throw(OP_WITH_WRONG_DIM)
133 #else
134  throw()
135 #endif
136  {
137 #if(CXSC_INDEX_CHECK)
138  if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(idotprecision&, const rvector_slice &, const rvector &)"));
139 #endif
140  dotprecision tmp(0.0);
141  tmp.set_k(dp.get_k());
142  addDot(tmp,sl,rv);
143  dp += tmp;
144  }
145 
146 
147  void accumulate(idotprecision &dp,const rvector &rv,const rvector_slice &sl)
148 #if(CXSC_INDEX_CHECK)
149  throw(OP_WITH_WRONG_DIM)
150 #else
151  throw()
152 #endif
153  {
154 #if(CXSC_INDEX_CHECK)
155  if(VecLen(rv)!=VecLen(sl)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(idotprecision&, const rvector &, const rvector_slice &)"));
156 #endif
157  dotprecision tmp(0.0);
158  tmp.set_k(dp.get_k());
159  addDot(tmp,rv,sl);
160  dp += tmp;
161  }
162 
163  void accumulate(idotprecision &dp, const rvector_slice & sl1, const rvector_slice &sl2)
164 #if(CXSC_INDEX_CHECK)
165  throw(OP_WITH_WRONG_DIM)
166 #else
167  throw()
168 #endif
169  {
170 #if(CXSC_INDEX_CHECK)
171  if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(idotprecision&, const rvector_slice &, const rvector_slice &)"));
172 #endif
173  dotprecision tmp(0.0);
174  tmp.set_k(dp.get_k());
175  addDot(tmp,sl1,sl2);
176  dp += tmp;
177  }
178 
179  void accumulate(cdotprecision &dp, const rvector & rv1, const rvector &rv2)
180 #if(CXSC_INDEX_CHECK)
181  throw(OP_WITH_WRONG_DIM)
182 #else
183  throw()
184 #endif
185  {
186 #if(CXSC_INDEX_CHECK)
187  if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const rvector &, const rvector &)"));
188 #endif
189  addDot(Re(dp),rv1,rv2);
190  }
191 
192  void accumulate_approx(cdotprecision &dp, const rvector & rv1, const rvector &rv2)
193  {
194  addDot_op(Re(dp),rv1,rv2);
195  }
196 
197 // INLINE void accumulate(cdotprecision &dp, const rvector & rv1, const rmatrix_subv &rv2) throw(OP_WITH_WRONG_DIM);
198 // INLINE void accumulate(cdotprecision &dp, const rmatrix_subv & rv1, const rvector &rv2) throw(OP_WITH_WRONG_DIM);
199 
200 
201  void accumulate(cdotprecision &dp,const rvector_slice &sl,const rvector &rv)
202 #if(CXSC_INDEX_CHECK)
203  throw(OP_WITH_WRONG_DIM)
204 #else
205  throw()
206 #endif
207  {
208 #if(CXSC_INDEX_CHECK)
209  if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const rvector_slice &, const rvector &)"));
210 #endif
211  addDot(Re(dp),sl,rv);
212  }
213 
214  void accumulate_approx(cdotprecision &dp,const rvector_slice &sl,const rvector &rv)
215  {
216  addDot_op(Re(dp),sl,rv);
217  }
218 
219 
220  void accumulate(cdotprecision &dp,const rvector &rv,const rvector_slice &sl)
221 #if(CXSC_INDEX_CHECK)
222  throw(OP_WITH_WRONG_DIM)
223 #else
224  throw()
225 #endif
226  {
227 #if(CXSC_INDEX_CHECK)
228  if(VecLen(rv)!=VecLen(sl)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const rvector &, const rvector_slice &)"));
229 #endif
230  addDot(Re(dp),rv,sl);
231  }
232 
233  void accumulate_approx(cdotprecision &dp,const rvector &rv,const rvector_slice &sl)
234  {
235  addDot_op(Re(dp),rv,sl);
236  }
237 
238 
239  void accumulate(cdotprecision &dp, const rvector_slice & sl1, const rvector_slice &sl2)
240 #if(CXSC_INDEX_CHECK)
241  throw(OP_WITH_WRONG_DIM)
242 #else
243  throw()
244 #endif
245  {
246 #if(CXSC_INDEX_CHECK)
247  if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const rvector_slice &, const rvector_slice &)"));
248 #endif
249  addDot(Re(dp),sl1,sl2);
250  }
251 
252  void accumulate_approx(cdotprecision &dp, const rvector_slice & sl1, const rvector_slice &sl2)
253  {
254  addDot_op(Re(dp),sl1,sl2);
255  }
256 
257 
258  void accumulate(cidotprecision &dp, const rvector & rv1, const rvector &rv2)
259 #if(CXSC_INDEX_CHECK)
260  throw(OP_WITH_WRONG_DIM)
261 #else
262  throw()
263 #endif
264  {
265 #if(CXSC_INDEX_CHECK)
266  if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const rvector &, const rvector &)"));
267 #endif
268  dotprecision tmp(0.0);
269  tmp.set_k(dp.get_k());
270  addDot(tmp,rv1,rv2);
271  dp += tmp;
272  }
273 
274 // INLINE void accumulate(cidotprecision &dp, const rvector & rv1, const rmatrix_subv &rv2) throw(OP_WITH_WRONG_DIM);
275 // INLINE void accumulate(cidotprecision &dp, const rmatrix_subv & rv1, const rvector &rv2) throw(OP_WITH_WRONG_DIM);
276 
277 
278  void accumulate(cidotprecision &dp,const rvector_slice &sl,const rvector &rv)
279 #if(CXSC_INDEX_CHECK)
280  throw(OP_WITH_WRONG_DIM)
281 #else
282  throw()
283 #endif
284  {
285 #if(CXSC_INDEX_CHECK)
286  if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const rvector_slice &, const rvector &)"));
287 #endif
288  dotprecision tmp(0.0);
289  tmp.set_k(dp.get_k());
290  addDot(tmp,sl,rv);
291  dp += tmp;
292  }
293 
294 
295  void accumulate(cidotprecision &dp,const rvector &rv,const rvector_slice &sl)
296 #if(CXSC_INDEX_CHECK)
297  throw(OP_WITH_WRONG_DIM)
298 #else
299  throw()
300 #endif
301  {
302 #if(CXSC_INDEX_CHECK)
303  if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const rvector &, const rvector_slice &)"));
304 #endif
305  dotprecision tmp(0.0);
306  tmp.set_k(dp.get_k());
307  addDot(tmp,rv,sl);
308  dp += tmp;
309  }
310 
311 
312  void accumulate(cidotprecision &dp, const rvector_slice & sl1, const rvector_slice &sl2)
313 #if(CXSC_INDEX_CHECK)
314  throw(OP_WITH_WRONG_DIM)
315 #else
316  throw()
317 #endif
318  {
319 #if(CXSC_INDEX_CHECK)
320  if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const rvector_slice &, const rvector_slice &)"));
321 #endif
322  dotprecision tmp(0.0);
323  tmp.set_k(dp.get_k());
324  addDot(tmp,sl1,sl2);
325  dp += tmp;
326  }
327 
328 
329  //Summation accumulates
330  void accumulate(dotprecision &dp, const rvector& v) {
331  addSum(dp,v);
332  }
333 
334  void accumulate(idotprecision &dp, const rvector& v) {
335  dotprecision tmp(0.0);
336  tmp.set_k(dp.get_k());
337  addSum(tmp,v);
338  Inf(dp) += tmp;
339  Sup(dp) += tmp;
340  }
341 
342  void accumulate(cdotprecision &dp, const rvector& v) {
343  addSum(Re(dp),v);
344  }
345 
346  void accumulate(cidotprecision &dp, const rvector& v) {
347  dotprecision tmp(0.0);
348  tmp.set_k(dp.get_k());
349  addSum(tmp,v);
350  InfRe(dp) += tmp;
351  SupRe(dp) += tmp;
352  }
353 }
cxsc::idotprecision::get_k
int get_k() const
Get currently set precision for computation of dot products.
Definition: idot.hpp:86
cxsc::cidotprecision::get_k
int get_k() const
Get currently set precision for computation of dot products.
Definition: cidot.hpp:89
cxsc::rvector
The Data Type rvector.
Definition: rvector.hpp:58
cxsc::idotprecision
The Data Type idotprecision.
Definition: idot.hpp:48
cxsc::rvector_slice
The Data Type rvector_slice.
Definition: rvector.hpp:1064
cxsc::accumulate_approx
void accumulate_approx(cdotprecision &dp, const cmatrix_subv &rv1, const cmatrix_subv &rv2)
The accurate scalar product of the last two arguments added to the value of the first argument (witho...
Definition: cmatrix.cpp:99
cxsc::dotprecision
The Data Type dotprecision.
Definition: dot.hpp:112
cxsc::cidotprecision
The Data Type cidotprecision.
Definition: cidot.hpp:58
cxsc::dotprecision::set_k
void set_k(unsigned int i)
Set precision for computation of dot products.
Definition: dot.hpp:131
cxsc
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition: cdot.cpp:29
cxsc::cdotprecision
The Data Type cdotprecision.
Definition: cdot.hpp:61
cxsc::VecLen
int VecLen(const scimatrix_subv &S)
Returns the length of the subvector.
Definition: scimatrix.hpp:9966