C-XSC - A C++ Class Library for Extended Scientific Computing 2.5.4
civector.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: civector.cpp,v 1.26 2014/01/30 17:23:44 cxsc Exp $ */
25
26#define _CXSC_CPP
27
28#include "civector.hpp"
29#include "vector.inl"
30#include "civector.inl"
31#include "rmatrix.hpp"
32
33#include "iveccvec.inl"
34
35#include "cidotk.inl"
36
37
38namespace cxsc {
39
40
41 void accumulate(cidotprecision &dp, const civector & rv1, const civector &rv2)
42#if(CXSC_INDEX_CHECK)
43
44#else
45 noexcept
46#endif
47 {
48#if(CXSC_INDEX_CHECK)
49 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector &, const civector &)"));
50#endif
51 addDot(dp,rv1,rv2);
52 }
53
54 void accumulate(cidotprecision &dp, const civector_slice & sl, const civector &rv)
55#if(CXSC_INDEX_CHECK)
56
57#else
58 noexcept
59#endif
60 {
61#if(CXSC_INDEX_CHECK)
62 if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector_slice &, const civector &)"));
63#endif
64 addDot(dp,sl,rv);
65 }
66
67 void accumulate(cidotprecision &dp, const civector &rv, const civector_slice &sl)
68#if(CXSC_INDEX_CHECK)
69
70#else
71 noexcept
72#endif
73 {
74#if(CXSC_INDEX_CHECK)
75 if(VecLen(rv)!=VecLen(sl)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector &, const civector_slice &)"));
76#endif
77 addDot(dp,rv,sl);
78 }
79
80 void accumulate(cidotprecision &dp, const civector_slice & sl1, const civector_slice &sl2)
81#if(CXSC_INDEX_CHECK)
82
83#else
84 noexcept
85#endif
86 {
87#if(CXSC_INDEX_CHECK)
88 if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector_slice &, const civector_slice &)"));
89#endif
90 addDot(dp,sl1,sl2);
91 }
92
93 void accumulate(cidotprecision &dp, const rvector & rv1, const civector &rv2)
94#if(CXSC_INDEX_CHECK)
95
96#else
97 noexcept
98#endif
99 {
100#if(CXSC_INDEX_CHECK)
101 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const rvector &, const civector &)"));
102#endif
103 idotprecision tmp_re(0.0);
104 idotprecision tmp_im(0.0);
105 tmp_re.set_k(dp.get_k());
106 tmp_im.set_k(dp.get_k());
107 addDot(tmp_re,rv1,Re(rv2));
108 addDot(tmp_im,rv1,Im(rv2));
109 dp += cidotprecision(tmp_re,tmp_im);
110 }
111
112 void accumulate(cidotprecision &dp, const civector & rv1, const rvector &rv2)
113#if(CXSC_INDEX_CHECK)
114
115#else
116 noexcept
117#endif
118 {
119#if(CXSC_INDEX_CHECK)
120 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector &, const rvector &)"));
121#endif
122 idotprecision tmp_re(0.0);
123 idotprecision tmp_im(0.0);
124 tmp_re.set_k(dp.get_k());
125 tmp_im.set_k(dp.get_k());
126 addDot(tmp_re,Re(rv1),rv2);
127 addDot(tmp_im,Im(rv1),rv2);
128 dp += cidotprecision(tmp_re,tmp_im);
129 }
130
131 void accumulate(cidotprecision &dp, const rvector_slice & sl, const civector &rv)
132#if(CXSC_INDEX_CHECK)
133
134#else
135 noexcept
136#endif
137 {
138#if(CXSC_INDEX_CHECK)
139 if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const rvector_slice &, const civector &)"));
140#endif
141 idotprecision tmp_re(0.0);
142 idotprecision tmp_im(0.0);
143 tmp_re.set_k(dp.get_k());
144 tmp_im.set_k(dp.get_k());
145 addDot(tmp_re,sl,Re(rv));
146 addDot(tmp_im,sl,Im(rv));
147 dp += cidotprecision(tmp_re,tmp_im);
148 }
149
150 void accumulate(cidotprecision &dp,const civector_slice &sl,const rvector &rv)
151#if(CXSC_INDEX_CHECK)
152
153#else
154 noexcept
155#endif
156 {
157#if(CXSC_INDEX_CHECK)
158 if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector_slice&, const rvector &)"));
159#endif
160 idotprecision tmp_re(0.0);
161 idotprecision tmp_im(0.0);
162 tmp_re.set_k(dp.get_k());
163 tmp_im.set_k(dp.get_k());
164 addDot(tmp_re,Re(sl),rv);
165 addDot(tmp_im,Im(sl),rv);
166 dp += cidotprecision(tmp_re,tmp_im);
167 }
168
169 void accumulate(cidotprecision &dp, const rvector &rv, const civector_slice &sl)
170#if(CXSC_INDEX_CHECK)
171
172#else
173 noexcept
174#endif
175 {
176#if(CXSC_INDEX_CHECK)
177 if(VecLen(rv)!=VecLen(sl)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const rvector &, const civector_slice &)"));
178#endif
179 idotprecision tmp_re(0.0);
180 idotprecision tmp_im(0.0);
181 tmp_re.set_k(dp.get_k());
182 tmp_im.set_k(dp.get_k());
183 addDot(tmp_re,rv,Re(sl));
184 addDot(tmp_im,rv,Im(sl));
185 dp += cidotprecision(tmp_re,tmp_im);
186 }
187
188 void accumulate(cidotprecision &dp,const civector &rv,const rvector_slice &sl)
189#if(CXSC_INDEX_CHECK)
190
191#else
192 noexcept
193#endif
194 {
195#if(CXSC_INDEX_CHECK)
196 if(VecLen(rv)!=VecLen(sl)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector &, const rvector_slice &)"));
197#endif
198 idotprecision tmp_re(0.0);
199 idotprecision tmp_im(0.0);
200 tmp_re.set_k(dp.get_k());
201 tmp_im.set_k(dp.get_k());
202 addDot(tmp_re,Re(rv),sl);
203 addDot(tmp_im,Im(rv),sl);
204 dp += cidotprecision(tmp_re,tmp_im);
205 }
206
207 void accumulate(cidotprecision &dp, const civector_slice & sl1, const rvector_slice &sl2)
208#if(CXSC_INDEX_CHECK)
209
210#else
211 noexcept
212#endif
213 {
214#if(CXSC_INDEX_CHECK)
215 if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector_slice &, const rvector_slice &)"));
216#endif
217 idotprecision tmp_re(0.0);
218 idotprecision tmp_im(0.0);
219 tmp_re.set_k(dp.get_k());
220 tmp_im.set_k(dp.get_k());
221 addDot(tmp_re,Re(sl1),sl2);
222 addDot(tmp_im,Im(sl1),sl2);
223 dp += cidotprecision(tmp_re,tmp_im);
224 }
225
226 void accumulate(cidotprecision &dp, const rvector_slice & sl1, const civector_slice &sl2)
227#if(CXSC_INDEX_CHECK)
228
229#else
230 noexcept
231#endif
232 {
233#if(CXSC_INDEX_CHECK)
234 if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const rvector_slice &, const civector_slice &)"));
235#endif
236 idotprecision tmp_re(0.0);
237 idotprecision tmp_im(0.0);
238 tmp_re.set_k(dp.get_k());
239 tmp_im.set_k(dp.get_k());
240 addDot(tmp_re,sl1,Re(sl2));
241 addDot(tmp_im,sl1,Im(sl2));
242 dp += cidotprecision(tmp_re,tmp_im);
243 }
244
245 void accumulate(cidotprecision &dp, const civector_slice & sl1, const rmatrix_subv &sl2)
246#if(CXSC_INDEX_CHECK)
247
248#else
249 noexcept
250#endif
251 {
252#if(CXSC_INDEX_CHECK)
253 if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector_slice &, const rmatrix_subv &)"));
254#endif
255 idotprecision tmp_re(0.0);
256 idotprecision tmp_im(0.0);
257 tmp_re.set_k(dp.get_k());
258 tmp_im.set_k(dp.get_k());
259 addDot(tmp_re,Re(sl1),sl2);
260 addDot(tmp_im,Im(sl1),sl2);
261 dp += cidotprecision(tmp_re,tmp_im);
262 }
263
264 void accumulate(cidotprecision &dp, const rmatrix_subv & sl1, const civector_slice &sl2)
265#if(CXSC_INDEX_CHECK)
266
267#else
268 noexcept
269#endif
270 {
271#if(CXSC_INDEX_CHECK)
272 if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const rmatrix_subv &, const civector_slice &)"));
273#endif
274 idotprecision tmp_re(0.0);
275 idotprecision tmp_im(0.0);
276 tmp_re.set_k(dp.get_k());
277 tmp_im.set_k(dp.get_k());
278 addDot(tmp_re,sl1,Re(sl2));
279 addDot(tmp_im,sl1,Im(sl2));
280 dp += cidotprecision(tmp_re,tmp_im);
281 }
282
283 void accumulate(cidotprecision &dp, const cvector & rv1, const civector &rv2)
284#if(CXSC_INDEX_CHECK)
285
286#else
287 noexcept
288#endif
289 {
290#if(CXSC_INDEX_CHECK)
291 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const cvector &, const civector &)"));
292#endif
293 addDot(dp,rv1,rv2);
294 }
295
296 void accumulate(cidotprecision &dp, const civector & rv1, const cvector &rv2)
297#if(CXSC_INDEX_CHECK)
298
299#else
300 noexcept
301#endif
302 {
303#if(CXSC_INDEX_CHECK)
304 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector &, const cvector &)"));
305#endif
306 addDot(dp,rv1,rv2);
307 }
308
309 void accumulate(cidotprecision &dp, const cvector_slice & sl, const civector &rv)
310#if(CXSC_INDEX_CHECK)
311
312#else
313 noexcept
314#endif
315 {
316#if(CXSC_INDEX_CHECK)
317 if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const cvector_slice &, const civector &)"));
318#endif
319 addDot(dp,sl,rv);
320 }
321
322 void accumulate(cidotprecision &dp,const civector_slice &sl,const cvector &rv)
323#if(CXSC_INDEX_CHECK)
324
325#else
326 noexcept
327#endif
328 {
329#if(CXSC_INDEX_CHECK)
330 if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector_slice &, const cvector &)"));
331#endif
332 addDot(dp,sl,rv);
333 }
334
335 void accumulate(cidotprecision &dp, const cvector &rv, const civector_slice &sl)
336#if(CXSC_INDEX_CHECK)
337
338#else
339 noexcept
340#endif
341 {
342#if(CXSC_INDEX_CHECK)
343 if(VecLen(rv)!=VecLen(sl)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const cvector &, const civector_slice &)"));
344#endif
345 addDot(dp,rv,sl);
346 }
347
348 void accumulate(cidotprecision &dp,const civector &rv,const cvector_slice &sl)
349#if(CXSC_INDEX_CHECK)
350
351#else
352 noexcept
353#endif
354 {
355#if(CXSC_INDEX_CHECK)
356 if(VecLen(rv)!=VecLen(sl)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector &, const cvector_slice &)"));
357#endif
358 addDot(dp,rv,sl);
359 }
360
361 void accumulate(cidotprecision &dp, const civector_slice & sl1, const cvector_slice &sl2)
362#if(CXSC_INDEX_CHECK)
363
364#else
365 noexcept
366#endif
367 {
368#if(CXSC_INDEX_CHECK)
369 if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector_slice &, const cvector_slice &)"));
370#endif
371 addDot(dp,sl1,sl2);
372 }
373
374 void accumulate(cidotprecision &dp, const cvector_slice & sl1, const civector_slice &sl2)
375#if(CXSC_INDEX_CHECK)
376
377#else
378 noexcept
379#endif
380 {
381#if(CXSC_INDEX_CHECK)
382 if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const cvector_slice &, const civector_slice &)"));
383#endif
384 addDot(dp,sl1,sl2);
385 }
386
387 void accumulate(cidotprecision &dp, const ivector & rv1, const civector &rv2)
388#if(CXSC_INDEX_CHECK)
389
390#else
391 noexcept
392#endif
393 {
394#if(CXSC_INDEX_CHECK)
395 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const ivector &, const civector &)"));
396#endif
397 idotprecision tmp_re(0.0);
398 idotprecision tmp_im(0.0);
399 tmp_re.set_k(dp.get_k());
400 tmp_im.set_k(dp.get_k());
401 addDot(tmp_re,rv1,Re(rv2));
402 addDot(tmp_im,rv1,Im(rv2));
403 dp += cidotprecision(tmp_re,tmp_im);
404 }
405
406 void accumulate(cidotprecision &dp, const civector & rv1, const ivector &rv2)
407#if(CXSC_INDEX_CHECK)
408
409#else
410 noexcept
411#endif
412 {
413#if(CXSC_INDEX_CHECK)
414 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector &, const ivector &)"));
415#endif
416 idotprecision tmp_re(0.0);
417 idotprecision tmp_im(0.0);
418 tmp_re.set_k(dp.get_k());
419 tmp_im.set_k(dp.get_k());
420 addDot(tmp_re,Re(rv1),rv2);
421 addDot(tmp_im,Im(rv1),rv2);
422 dp += cidotprecision(tmp_re,tmp_im);
423 }
424
425 void accumulate(cidotprecision &dp, const ivector_slice & sl, const civector &rv)
426#if(CXSC_INDEX_CHECK)
427
428#else
429 noexcept
430#endif
431 {
432#if(CXSC_INDEX_CHECK)
433 if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const ivector_slice &, const civector &)"));
434#endif
435 idotprecision tmp_re(0.0);
436 idotprecision tmp_im(0.0);
437 tmp_re.set_k(dp.get_k());
438 tmp_im.set_k(dp.get_k());
439 addDot(tmp_re,sl,Re(rv));
440 addDot(tmp_im,sl,Im(rv));
441 dp += cidotprecision(tmp_re,tmp_im);
442 }
443
444 void accumulate(cidotprecision &dp,const civector_slice &sl,const ivector &rv)
445#if(CXSC_INDEX_CHECK)
446
447#else
448 noexcept
449#endif
450 {
451#if(CXSC_INDEX_CHECK)
452 if(VecLen(sl)!=VecLen(rv)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector_slice &, const ivector &)"));
453#endif
454 idotprecision tmp_re(0.0);
455 idotprecision tmp_im(0.0);
456 tmp_re.set_k(dp.get_k());
457 tmp_im.set_k(dp.get_k());
458 addDot(tmp_re,Re(sl),rv);
459 addDot(tmp_im,Im(sl),rv);
460 dp += cidotprecision(tmp_re,tmp_im);
461 }
462
463 void accumulate(cidotprecision &dp, const ivector &rv, const civector_slice &sl)
464#if(CXSC_INDEX_CHECK)
465
466#else
467 noexcept
468#endif
469 {
470#if(CXSC_INDEX_CHECK)
471 if(VecLen(rv)!=VecLen(sl)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const ivector &, const civector_slice &)"));
472#endif
473 idotprecision tmp_re(0.0);
474 idotprecision tmp_im(0.0);
475 tmp_re.set_k(dp.get_k());
476 tmp_im.set_k(dp.get_k());
477 addDot(tmp_re,rv,Re(sl));
478 addDot(tmp_im,rv,Im(sl));
479 dp += cidotprecision(tmp_re,tmp_im);
480 }
481
482 void accumulate(cidotprecision &dp,const civector &rv,const ivector_slice &sl)
483#if(CXSC_INDEX_CHECK)
484
485#else
486 noexcept
487#endif
488 {
489#if(CXSC_INDEX_CHECK)
490 if(VecLen(rv)!=VecLen(sl)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector &, const ivector_slice &)"));
491#endif
492 idotprecision tmp_re(0.0);
493 idotprecision tmp_im(0.0);
494 tmp_re.set_k(dp.get_k());
495 tmp_im.set_k(dp.get_k());
496 addDot(tmp_re,Re(rv),sl);
497 addDot(tmp_im,Im(rv),sl);
498 dp += cidotprecision(tmp_re,tmp_im);
499 }
500
501 void accumulate(cidotprecision &dp, const civector_slice & sl1, const ivector_slice &sl2)
502#if(CXSC_INDEX_CHECK)
503
504#else
505 noexcept
506#endif
507 {
508#if(CXSC_INDEX_CHECK)
509 if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const civector_slice &, const ivector_slice &)"));
510#endif
511 idotprecision tmp_re(0.0);
512 idotprecision tmp_im(0.0);
513 tmp_re.set_k(dp.get_k());
514 tmp_im.set_k(dp.get_k());
515 addDot(tmp_re,Re(sl1),sl2);
516 addDot(tmp_im,Im(sl1),sl2);
517 dp += cidotprecision(tmp_re,tmp_im);
518 }
519
520 void accumulate(cidotprecision &dp, const ivector_slice & sl1, const civector_slice &sl2)
521#if(CXSC_INDEX_CHECK)
522
523#else
524 noexcept
525#endif
526 {
527#if(CXSC_INDEX_CHECK)
528 if(VecLen(sl1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const ivector_slice &, const civector_slice &)"));
529#endif
530 idotprecision tmp_re(0.0);
531 idotprecision tmp_im(0.0);
532 tmp_re.set_k(dp.get_k());
533 tmp_im.set_k(dp.get_k());
534 addDot(tmp_re,sl1,Re(sl2));
535 addDot(tmp_im,sl1,Im(sl2));
536 dp += cidotprecision(tmp_re,tmp_im);
537 }
538
539 //Summation
540 void accumulate(cidotprecision &dp, const civector& v) {
541 addSum(InfRe(dp),InfRe(v));
542 addSum(SupRe(dp),SupRe(v));
543 addSum(InfIm(dp),InfIm(v));
544 addSum(SupIm(dp),SupIm(v));
545 }
546} // namespace cxsc
547
The Data Type cidotprecision.
Definition cidot.hpp:58
int get_k() const
Get currently set precision for computation of dot products.
Definition cidot.hpp:89
The Data Type civector_slice.
The Data Type civector.
Definition civector.hpp:57
The Data Type cvector_slice.
Definition cvector.hpp:845
The Data Type cvector.
Definition cvector.hpp:58
The Data Type idotprecision.
Definition idot.hpp:48
void set_k(unsigned int i)
Set precision for computation of dot products.
Definition idot.hpp:88
The Data Type ivector_slice.
Definition ivector.hpp:963
The Data Type ivector.
Definition ivector.hpp:55
The Data Type rmatrix_subv.
Definition rmatrix.hpp:54
The Data Type rvector_slice.
Definition rvector.hpp:1064
The Data Type rvector.
Definition rvector.hpp:58
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition cdot.cpp:29
int VecLen(const scimatrix_subv &S)
Returns the length of the subvector.