C-XSC - A C++ Class Library for Extended Scientific Computing 2.5.4
cmatrix.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: cmatrix.cpp,v 1.27 2014/01/30 17:23:44 cxsc Exp $ */
25
26#define _CXSC_CPP
27
28#include "cmatrix.hpp"
29#include "matrix.inl"
30#include "cmatrix.inl"
31#include "cvecrmat.inl"
32
33#include "cdotk.inl"
34
35#include "idotk.inl"
36#include "imatrix.hpp"
37#include "ivector.hpp"
38
39namespace cxsc {
40
41//Ostrowskis comparison matrix
42rmatrix CompMat ( const cmatrix& A) {
43 rmatrix M(Lb(A,1), Ub(A,1), Lb(A,2), Ub(A,2));
44
45 for(int i=Lb(A,1) ; i<=Ub(A,1) ; i++) {
46 for(int j=Lb(A,2) ; j<=Ub(A,2) ; j++) {
47 if(i-Lb(A,1) == j-Lb(A,2))
48 M[i][j] = abs(A[i][j]);
49 else
50 M[i][j] = -abs(A[i][j]);
51 }
52 }
53
54 return M;
55}
56
57
58cmatrix Id ( cmatrix& A ) // Complex identity matrix
59{ //-------------------------
60 int i,j;
61 int lbi = Lb(A,1), ubi = Ub(A,1);
62 int lbj = Lb(A,2), ubj = Ub(A,2);
63 cmatrix B(lbi,ubi,lbj,ubj);
64
65 for (i = lbi; i <= ubi; i++)
66 for (j = lbj; j <= ubj; j++)
67 B[i][j] = complex( (i==j) ? 1.0 : 0.0 );
68 return B;
69}
70
71cmatrix transp ( const cmatrix& A ) // Transposed matrix
72{ //------------------
73 int n;
74 cmatrix res(Lb(A,2),Ub(A,2),Lb(A,1),Ub(A,1));
75
76 for (n = Lb(A,1); n <= Ub(A,1); n++) Col(res,n) = Row(A,n);
77 return res;
78}
79
81{
82 int n = Lb(A,1);
83 Resize(A,n,2*Ub(A,1)-n+1,Lb(A,2),Ub(A,2));
84}
85
86 void accumulate(cdotprecision &dp, const cmatrix_subv & rv1, const cmatrix_subv &rv2)
87#if(CXSC_INDEX_CHECK)
88
89#else
90 noexcept
91#endif
92 {
93#if(CXSC_INDEX_CHECK)
94 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const cmatrix_subv &, const cmatrix_subv &)"));
95#endif
96 addDot_op(dp,rv1,rv2);
97 }
98
99 void accumulate_approx(cdotprecision &dp, const cmatrix_subv & rv1, const cmatrix_subv &rv2)
100 {
101 addDot_op(dp,rv1,rv2);
102 }
103
104
105 void accumulate(cdotprecision &dp, const cvector & rv1, const cmatrix_subv &rv2)
106#if(CXSC_INDEX_CHECK)
107
108#else
109 noexcept
110#endif
111 {
112#if(CXSC_INDEX_CHECK)
113 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const cvector &, const cmatrix_subv &)"));
114#endif
115 addDot(dp,rv1,rv2);
116 }
117
118 void accumulate_approx(cdotprecision &dp, const cvector & rv1, const cmatrix_subv &rv2)
119 {
120 addDot_op(dp,rv1,rv2);
121 }
122
123
124 void accumulate(cdotprecision &dp, const cmatrix_subv & rv1, const cvector &rv2)
125#if(CXSC_INDEX_CHECK)
126
127#else
128 noexcept
129#endif
130 {
131#if(CXSC_INDEX_CHECK)
132 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const cmatrix_subv &, const cvector &)"));
133#endif
134 addDot(dp,rv1,rv2);
135 }
136
137 void accumulate_approx(cdotprecision &dp, const cmatrix_subv & rv1, const cvector &rv2)
138 {
139 addDot_op(dp,rv1,rv2);
140 }
141
142
143 void accumulate(cdotprecision &dp, const cvector_slice & sl1, const cmatrix_subv &rv2)
144#if(CXSC_INDEX_CHECK)
145
146#else
147 noexcept
148#endif
149 {
150#if(CXSC_INDEX_CHECK)
151 if(VecLen(sl1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const cvector_slice &, const cmatrix_subv &)"));
152#endif
153 addDot(dp,sl1,rv2);
154 }
155
157 {
158 addDot_op(dp,sl1,rv2);
159 }
160
161
162 void accumulate(cdotprecision &dp, const cmatrix_subv & rv1, const cvector_slice &sl2)
163#if(CXSC_INDEX_CHECK)
164
165#else
166 noexcept
167#endif
168 {
169#if(CXSC_INDEX_CHECK)
170 if(VecLen(rv1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const cmatrix_subv &, const cvector_slice &)"));
171#endif
172 addDot(dp,rv1,sl2);
173 }
174
176 {
177 addDot_op(dp,rv1,sl2);
178 }
179
180 void accumulate(cidotprecision &dp, const cmatrix_subv & rv1, const cmatrix_subv &rv2)
181#if(CXSC_INDEX_CHECK)
182
183#else
184 noexcept
185#endif
186 {
187#if(CXSC_INDEX_CHECK)
188 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const cmatrix_subv &, const cmatrix_subv &)"));
189#endif
190 cdotprecision tmp(0.0);
191 tmp.set_k(dp.get_k());
192 addDot(tmp,rv1,rv2);
193 dp += tmp;
194 }
195
196 void accumulate(cidotprecision &dp, const cvector & rv1, const cmatrix_subv &rv2)
197#if(CXSC_INDEX_CHECK)
198
199#else
200 noexcept
201#endif
202 {
203#if(CXSC_INDEX_CHECK)
204 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const cvector &, const cmatrix_subv &)"));
205#endif
206 cdotprecision tmp(0.0);
207 tmp.set_k(dp.get_k());
208 addDot(tmp,rv1,rv2);
209 dp += tmp;
210 }
211
212 void accumulate(cidotprecision &dp, const cmatrix_subv & rv1, const cvector &rv2)
213#if(CXSC_INDEX_CHECK)
214
215#else
216 noexcept
217#endif
218 {
219#if(CXSC_INDEX_CHECK)
220 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const cmatrix_subv &, const cvector &)"));
221#endif
222 cdotprecision tmp(0.0);
223 tmp.set_k(dp.get_k());
224 addDot(tmp,rv1,rv2);
225 dp += tmp;
226 }
227
228 void accumulate(cidotprecision &dp, const cvector_slice & sl1, const cmatrix_subv &rv2)
229#if(CXSC_INDEX_CHECK)
230
231#else
232 noexcept
233#endif
234 {
235#if(CXSC_INDEX_CHECK)
236 if(VecLen(sl1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const cvector_slice &, const cmatrix_subv &)"));
237#endif
238 cdotprecision tmp(0.0);
239 tmp.set_k(dp.get_k());
240 addDot(tmp,sl1,rv2);
241 dp += tmp;
242 }
243
244 void accumulate(cidotprecision &dp, const cmatrix_subv & rv1, const cvector_slice &sl2)
245#if(CXSC_INDEX_CHECK)
246
247#else
248 noexcept
249#endif
250 {
251#if(CXSC_INDEX_CHECK)
252 if(VecLen(rv1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const cmatrix_subv &, const cvector_slice &)"));
253#endif
254 cdotprecision tmp(0.0);
255 tmp.set_k(dp.get_k());
256 addDot(tmp,rv1,sl2);
257 dp += tmp;
258 }
259
260 void accumulate(cdotprecision &dp, const rmatrix_subv & rv1, const cmatrix_subv &rv2)
261#if(CXSC_INDEX_CHECK)
262
263#else
264 noexcept
265#endif
266 {
267#if(CXSC_INDEX_CHECK)
268 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const rmatrix_subv &, const cmatrix_subv &)"));
269#endif
270 addDot(Re(dp),rv1,Re(rv2));
271 addDot(Im(dp),rv1,Im(rv2));
272 }
273
274 void accumulate_approx(cdotprecision &dp, const rmatrix_subv & rv1, const cmatrix_subv &rv2)
275 {
276 addDot_op(Re(dp),rv1,Re(rv2));
277 addDot_op(Im(dp),rv1,Im(rv2));
278 }
279
280 void accumulate(cdotprecision &dp, const rmatrix_subv & rv1, const cvector_slice &rv2)
281#if(CXSC_INDEX_CHECK)
282
283#else
284 noexcept
285#endif
286 {
287#if(CXSC_INDEX_CHECK)
288 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const rmatrix_subv &, const cvector_slice &)"));
289#endif
290 addDot(Re(dp),rv1,Re(rv2));
291 addDot(Im(dp),rv1,Im(rv2));
292 }
293
295 {
296 addDot_op(Re(dp),rv1,Re(rv2));
297 addDot_op(Im(dp),rv1,Im(rv2));
298 }
299
300
301 void accumulate(cdotprecision &dp, const rmatrix_subv & rv1, const cvector &rv2)
302#if(CXSC_INDEX_CHECK)
303
304#else
305 noexcept
306#endif
307 {
308#if(CXSC_INDEX_CHECK)
309 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const rmatrix_subv &, const cvector &)"));
310#endif
311 addDot(Re(dp),rv1,Re(rv2));
312 addDot(Im(dp),rv1,Im(rv2));
313 }
314
315 void accumulate_approx(cdotprecision &dp, const rmatrix_subv & rv1, const cvector &rv2)
316 {
317 addDot_op(Re(dp),rv1,Re(rv2));
318 addDot_op(Im(dp),rv1,Im(rv2));
319 }
320
321
322 void accumulate(cdotprecision &dp, const cmatrix_subv & rv1, const rmatrix_subv &rv2)
323#if(CXSC_INDEX_CHECK)
324
325#else
326 noexcept
327#endif
328 {
329#if(CXSC_INDEX_CHECK)
330 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const cmatrix_subv &, const rmatrix_subv &)"));
331#endif
332 addDot(Re(dp),Re(rv1),rv2);
333 addDot(Im(dp),Im(rv1),rv2);
334 }
335
336 void accumulate_approx(cdotprecision &dp, const cmatrix_subv & rv1, const rmatrix_subv &rv2)
337 {
338 addDot_op(Re(dp),Re(rv1),rv2);
339 addDot_op(Im(dp),Im(rv1),rv2);
340 }
341
342 void accumulate(cdotprecision &dp, const cvector & rv1, const rmatrix_subv &rv2)
343#if(CXSC_INDEX_CHECK)
344
345#else
346 noexcept
347#endif
348 {
349#if(CXSC_INDEX_CHECK)
350 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const cvector &, const rmatrix_subv &)"));
351#endif
352 addDot(Re(dp),Re(rv1),rv2);
353 addDot(Im(dp),Im(rv1),rv2);
354 }
355
356 void accumulate_approx(cdotprecision &dp, const cvector & rv1, const rmatrix_subv &rv2)
357 {
358 addDot_op(Re(dp),Re(rv1),rv2);
359 addDot_op(Im(dp),Im(rv1),rv2);
360 }
361
362 void accumulate(cdotprecision &dp, const cvector_slice & rv1, const rmatrix_subv &rv2)
363#if(CXSC_INDEX_CHECK)
364
365#else
366 noexcept
367#endif
368 {
369#if(CXSC_INDEX_CHECK)
370 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const cvector_slice &, const rmatrix_subv &)"));
371#endif
372 addDot(Re(dp),Re(rv1),rv2);
373 addDot(Im(dp),Im(rv1),rv2);
374 }
375
377 {
378 addDot_op(Re(dp),Re(rv1),rv2);
379 addDot_op(Im(dp),Im(rv1),rv2);
380 }
381
382 void accumulate(cdotprecision &dp, const rvector & rv1, const cmatrix_subv &rv2)
383#if(CXSC_INDEX_CHECK)
384
385#else
386 noexcept
387#endif
388 {
389#if(CXSC_INDEX_CHECK)
390 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const rvector &, const cmatrix_subv &)"));
391#endif
392 addDot(Re(dp),rv1,Re(rv2));
393 addDot(Im(dp),rv1,Im(rv2));
394 }
395
396 void accumulate_approx(cdotprecision &dp, const rvector & rv1, const cmatrix_subv &rv2)
397 {
398 addDot_op(Re(dp),rv1,Re(rv2));
399 addDot_op(Im(dp),rv1,Im(rv2));
400 }
401
402 void accumulate(cdotprecision &dp, const cmatrix_subv & rv1, const rvector &rv2)
403#if(CXSC_INDEX_CHECK)
404
405#else
406 noexcept
407#endif
408 {
409#if(CXSC_INDEX_CHECK)
410 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const cmatrix_subv &, const rvector &)"));
411#endif
412 addDot(Re(dp),Re(rv1),rv2);
413 addDot(Im(dp),Im(rv1),rv2);
414 }
415
416 void accumulate_approx(cdotprecision &dp, const cmatrix_subv & rv1, const rvector &rv2)
417 {
418 addDot_op(Re(dp),Re(rv1),rv2);
419 addDot_op(Im(dp),Im(rv1),rv2);
420 }
421
422 void accumulate(cdotprecision &dp, const rvector_slice & sl1, const cmatrix_subv &rv2)
423#if(CXSC_INDEX_CHECK)
424
425#else
426 noexcept
427#endif
428 {
429#if(CXSC_INDEX_CHECK)
430 if(VecLen(sl1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const rvector_slice &, const cmatrix_subv &)"));
431#endif
432 addDot(Re(dp),sl1,Re(rv2));
433 addDot(Im(dp),sl1,Im(rv2));
434 }
435
437 {
438 addDot_op(Re(dp),sl1,Re(rv2));
439 addDot_op(Im(dp),sl1,Im(rv2));
440 }
441
442 void accumulate(cdotprecision &dp, const cmatrix_subv & rv1, const rvector_slice &sl2)
443#if(CXSC_INDEX_CHECK)
444
445#else
446 noexcept
447#endif
448 {
449#if(CXSC_INDEX_CHECK)
450 if(VecLen(rv1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cdotprecision&, const cmatrix_subv &, const rvector_slice &)"));
451#endif
452 addDot(Re(dp),Re(rv1),sl2);
453 addDot(Im(dp),Im(rv1),sl2);
454 }
455
457 {
458 addDot_op(Re(dp),Re(rv1),sl2);
459 addDot_op(Im(dp),Im(rv1),sl2);
460 }
461
462 void accumulate(cidotprecision &dp, const rmatrix_subv & rv1, const cmatrix_subv &rv2)
463#if(CXSC_INDEX_CHECK)
464
465#else
466 noexcept
467#endif
468 {
469#if(CXSC_INDEX_CHECK)
470 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const rmatrix_subv &, const cmatrix_subv &)"));
471#endif
472 cdotprecision tmp(0.0);
473 tmp.set_k(dp.get_k());
474 addDot(Re(tmp),rv1,Re(rv2));
475 addDot(Im(tmp),rv1,Im(rv2));
476 dp += tmp;
477 }
478
479 void accumulate(cidotprecision &dp, const cmatrix_subv & rv1, const rmatrix_subv &rv2)
480#if(CXSC_INDEX_CHECK)
481
482#else
483 noexcept
484#endif
485 {
486#if(CXSC_INDEX_CHECK)
487 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const cmatrix_subv &, const rmatrix_subv &)"));
488#endif
489 cdotprecision tmp(0.0);
490 tmp.set_k(dp.get_k());
491 addDot(Re(tmp),Re(rv1),rv2);
492 addDot(Im(tmp),Im(rv1),rv2);
493 dp += tmp;
494 }
495
496 void accumulate(cidotprecision &dp, const rvector & rv1, const cmatrix_subv &rv2)
497#if(CXSC_INDEX_CHECK)
498
499#else
500 noexcept
501#endif
502 {
503#if(CXSC_INDEX_CHECK)
504 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const rvector &, const cmatrix_subv &)"));
505#endif
506 cdotprecision tmp(0.0);
507 tmp.set_k(dp.get_k());
508 addDot(Re(tmp),rv1,Re(rv2));
509 addDot(Im(tmp),rv1,Im(rv2));
510 dp += tmp;
511 }
512
513 void accumulate(cidotprecision &dp, const cmatrix_subv & rv1, const rvector &rv2)
514#if(CXSC_INDEX_CHECK)
515
516#else
517 noexcept
518#endif
519 {
520#if(CXSC_INDEX_CHECK)
521 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const cmatrix_subv &, const rvector &)"));
522#endif
523 cdotprecision tmp(0.0);
524 tmp.set_k(dp.get_k());
525 addDot(Re(tmp),Re(rv1),rv2);
526 addDot(Im(tmp),Im(rv1),rv2);
527 dp += tmp;
528 }
529
530 void accumulate(cidotprecision &dp, const rvector_slice & sl1, const cmatrix_subv &rv2)
531#if(CXSC_INDEX_CHECK)
532
533#else
534 noexcept
535#endif
536 {
537#if(CXSC_INDEX_CHECK)
538 if(VecLen(sl1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const rvector_slice &, const cmatrix_subv &)"));
539#endif
540 cdotprecision tmp(0.0);
541 tmp.set_k(dp.get_k());
542 addDot(Re(tmp),sl1,Re(rv2));
543 addDot(Im(tmp),sl1,Im(rv2));
544 dp += tmp;
545 }
546
547 void accumulate(cidotprecision &dp, const cmatrix_subv & rv1, const rvector_slice &sl2)
548#if(CXSC_INDEX_CHECK)
549
550#else
551 noexcept
552#endif
553 {
554#if(CXSC_INDEX_CHECK)
555 if(VecLen(rv1)!=VecLen(sl2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const cmatrix_subv &, const rvector_slice &)"));
556#endif
557 cdotprecision tmp(0.0);
558 tmp.set_k(dp.get_k());
559 addDot(Re(tmp),Re(rv1),sl2);
560 addDot(Im(tmp),Im(rv1),sl2);
561 dp += tmp;
562 }
563
564 void accumulate(cidotprecision &dp, const imatrix_subv & rv1, const cvector &rv2)
565#if(CXSC_INDEX_CHECK)
566
567#else
568 noexcept
569#endif
570 {
571#if(CXSC_INDEX_CHECK)
572 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const imatrix_subv &, const cvector &)"));
573#endif
574 idotprecision tmp_re(0.0);
575 idotprecision tmp_im(0.0);
576 tmp_re.set_k(dp.get_k());
577 tmp_im.set_k(dp.get_k());
578 addDot(tmp_re,rv1,Re(rv2));
579 addDot(tmp_im,rv1,Im(rv2));
580 dp += cidotprecision(tmp_re,tmp_im);
581 }
582
583 void accumulate(cidotprecision &dp, const cvector & rv1, const imatrix_subv &rv2)
584#if(CXSC_INDEX_CHECK)
585
586#else
587 noexcept
588#endif
589 {
590#if(CXSC_INDEX_CHECK)
591 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const cvector &, const imatrix_subv &)"));
592#endif
593 idotprecision tmp_re(0.0);
594 idotprecision tmp_im(0.0);
595 tmp_re.set_k(dp.get_k());
596 tmp_im.set_k(dp.get_k());
597 addDot(tmp_re,Re(rv1),rv2);
598 addDot(tmp_im,Im(rv1),rv2);
599 dp += cidotprecision(tmp_re,tmp_im); }
600
601 void accumulate(cidotprecision &dp, const imatrix_subv & rv1, const cvector_slice &rv2)
602#if(CXSC_INDEX_CHECK)
603
604#else
605 noexcept
606#endif
607 {
608#if(CXSC_INDEX_CHECK)
609 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const imatrix_subv &, const cvector_slice &)"));
610#endif
611 idotprecision tmp_re(0.0);
612 idotprecision tmp_im(0.0);
613 tmp_re.set_k(dp.get_k());
614 tmp_im.set_k(dp.get_k());
615 addDot(tmp_re,rv1,Re(rv2));
616 addDot(tmp_im,rv1,Im(rv2));
617 dp += cidotprecision(tmp_re,tmp_im);
618 }
619
620 void accumulate(cidotprecision &dp, const cvector_slice & rv1, const imatrix_subv &rv2)
621#if(CXSC_INDEX_CHECK)
622
623#else
624 noexcept
625#endif
626 {
627#if(CXSC_INDEX_CHECK)
628 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const cvector_slice &, const imatrix_subv &)"));
629#endif
630 idotprecision tmp_re(0.0);
631 idotprecision tmp_im(0.0);
632 tmp_re.set_k(dp.get_k());
633 tmp_im.set_k(dp.get_k());
634 addDot(tmp_re,Re(rv1),rv2);
635 addDot(tmp_im,Im(rv1),rv2);
636 dp += cidotprecision(tmp_re,tmp_im);
637 }
638
639 void accumulate(cidotprecision &dp, const cmatrix_subv & rv1, const ivector &rv2)
640#if(CXSC_INDEX_CHECK)
641
642#else
643 noexcept
644#endif
645 {
646#if(CXSC_INDEX_CHECK)
647 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const cmatrix_subv &, const ivector &)"));
648#endif
649 idotprecision tmp_re(0.0);
650 idotprecision tmp_im(0.0);
651 tmp_re.set_k(dp.get_k());
652 tmp_im.set_k(dp.get_k());
653 addDot(tmp_re,Re(rv1),rv2);
654 addDot(tmp_im,Im(rv1),rv2);
655 dp += cidotprecision(tmp_re,tmp_im);
656 }
657
658 void accumulate(cidotprecision &dp, const ivector & rv1, const cmatrix_subv &rv2)
659#if(CXSC_INDEX_CHECK)
660
661#else
662 noexcept
663#endif
664 {
665#if(CXSC_INDEX_CHECK)
666 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const ivector &, const cmatrix_subv &)"));
667#endif
668 idotprecision tmp_re(0.0);
669 idotprecision tmp_im(0.0);
670 tmp_re.set_k(dp.get_k());
671 tmp_im.set_k(dp.get_k());
672 addDot(tmp_re,rv1,Re(rv2));
673 addDot(tmp_im,rv1,Im(rv2));
674 dp += cidotprecision(tmp_re,tmp_im);
675 }
676
677 void accumulate(cidotprecision &dp, const cmatrix_subv & rv1, const ivector_slice &rv2)
678#if(CXSC_INDEX_CHECK)
679
680#else
681 noexcept
682#endif
683 {
684#if(CXSC_INDEX_CHECK)
685 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const cmatrix_subv &, const ivector_slice &)"));
686#endif
687 idotprecision tmp_re(0.0);
688 idotprecision tmp_im(0.0);
689 tmp_re.set_k(dp.get_k());
690 tmp_im.set_k(dp.get_k());
691 addDot(tmp_re,Re(rv1),rv2);
692 addDot(tmp_im,Im(rv1),rv2);
693 dp += cidotprecision(tmp_re,tmp_im);
694 }
695
696 void accumulate(cidotprecision &dp, const ivector_slice & rv1, const cmatrix_subv &rv2)
697#if(CXSC_INDEX_CHECK)
698
699#else
700 noexcept
701#endif
702 {
703#if(CXSC_INDEX_CHECK)
704 if(VecLen(rv1)!=VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM("void accumulate(cidotprecision&, const ivector_slice &, const cmatrix_subv &)"));
705#endif
706 idotprecision tmp_re(0.0);
707 idotprecision tmp_im(0.0);
708 tmp_re.set_k(dp.get_k());
709 tmp_im.set_k(dp.get_k());
710 addDot(tmp_re,rv1,Re(rv2));
711 addDot(tmp_im,rv1,Im(rv2));
712 dp += cidotprecision(tmp_re,tmp_im);
713 }
714
715} // namespace cxsc
716
The Data Type cdotprecision.
Definition cdot.hpp:61
void set_k(unsigned int i)
Set precision for computation of dot products.
Definition cdot.hpp:93
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 cmatrix_subv.
Definition cmatrix.hpp:54
The Data Type cmatrix.
Definition cmatrix.hpp:514
The Scalar Type complex.
Definition complex.hpp:50
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 imatrix_subv.
Definition imatrix.hpp:56
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 rmatrix.
Definition rmatrix.hpp:471
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.
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
cimatrix_subv Col(cimatrix &m, const int &i) noexcept
Returns one column of the matrix as a vector.
Definition cimatrix.inl:242
rmatrix CompMat(const cimatrix &A)
Returns Ostrowski's comparison matrix.
Definition cimatrix.cpp:45
cimatrix transp(const cimatrix &A)
Returns the transposed matrix.
Definition cimatrix.cpp:74
int Ub(const cimatrix &rm, const int &i) noexcept
Returns the upper bound index.
cimatrix_subv Row(cimatrix &m, const int &i) noexcept
Returns one row of the matrix as a vector.
Definition cimatrix.inl:231
void DoubleSize(cimatrix &A)
Doubles the size of the matrix.
Definition cimatrix.cpp:83
cimatrix Id(const cimatrix &A)
Returns the Identity matrix.
Definition cimatrix.cpp:61
ivector abs(const cimatrix_subv &mv) noexcept
Returns the absolute value of the matrix.
Definition cimatrix.inl:737
void Resize(cimatrix &A) noexcept
Resizes the matrix.
int Lb(const cimatrix &rm, const int &i) noexcept
Returns the lower bound index.