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