28 #include "cmatrix.hpp"
30 #include "cmatrix.inl"
31 #include "cvecrmat.inl"
36 #include "imatrix.hpp"
37 #include "ivector.hpp"
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]);
50 M[i][j] = -
abs(A[i][j]);
61 int lbi =
Lb(A,1), ubi =
Ub(A,1);
62 int lbj =
Lb(A,2), ubj =
Ub(A,2);
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 );
76 for (n =
Lb(A,1); n <=
Ub(A,1); n++)
Col(res,n) =
Row(A,n);
94 if(
VecLen(rv1)!=
VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM(
"void accumulate(cdotprecision&, const cmatrix_subv &, const cmatrix_subv &)"));
96 addDot_op(dp,rv1,rv2);
101 addDot_op(dp,rv1,rv2);
106 #if(CXSC_INDEX_CHECK)
112 #if(CXSC_INDEX_CHECK)
113 if(
VecLen(rv1)!=
VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM(
"void accumulate(cdotprecision&, const cvector &, const cmatrix_subv &)"));
120 addDot_op(dp,rv1,rv2);
125 #if(CXSC_INDEX_CHECK)
131 #if(CXSC_INDEX_CHECK)
132 if(
VecLen(rv1)!=
VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM(
"void accumulate(cdotprecision&, const cmatrix_subv &, const cvector &)"));
139 addDot_op(dp,rv1,rv2);
144 #if(CXSC_INDEX_CHECK)
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 &)"));
158 addDot_op(dp,sl1,rv2);
163 #if(CXSC_INDEX_CHECK)
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 &)"));
177 addDot_op(dp,rv1,sl2);
181 #if(CXSC_INDEX_CHECK)
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 &)"));
197 #if(CXSC_INDEX_CHECK)
203 #if(CXSC_INDEX_CHECK)
204 if(
VecLen(rv1)!=
VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM(
"void accumulate(cidotprecision&, const cvector &, const cmatrix_subv &)"));
213 #if(CXSC_INDEX_CHECK)
219 #if(CXSC_INDEX_CHECK)
220 if(
VecLen(rv1)!=
VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM(
"void accumulate(cidotprecision&, const cmatrix_subv &, const cvector &)"));
229 #if(CXSC_INDEX_CHECK)
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 &)"));
245 #if(CXSC_INDEX_CHECK)
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 &)"));
261 #if(CXSC_INDEX_CHECK)
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 &)"));
270 addDot(Re(dp),rv1,Re(rv2));
271 addDot(Im(dp),rv1,Im(rv2));
276 addDot_op(Re(dp),rv1,Re(rv2));
277 addDot_op(Im(dp),rv1,Im(rv2));
281 #if(CXSC_INDEX_CHECK)
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 &)"));
290 addDot(Re(dp),rv1,Re(rv2));
291 addDot(Im(dp),rv1,Im(rv2));
296 addDot_op(Re(dp),rv1,Re(rv2));
297 addDot_op(Im(dp),rv1,Im(rv2));
302 #if(CXSC_INDEX_CHECK)
308 #if(CXSC_INDEX_CHECK)
309 if(
VecLen(rv1)!=
VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM(
"void accumulate(cdotprecision&, const rmatrix_subv &, const cvector &)"));
311 addDot(Re(dp),rv1,Re(rv2));
312 addDot(Im(dp),rv1,Im(rv2));
317 addDot_op(Re(dp),rv1,Re(rv2));
318 addDot_op(Im(dp),rv1,Im(rv2));
323 #if(CXSC_INDEX_CHECK)
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 &)"));
332 addDot(Re(dp),Re(rv1),rv2);
333 addDot(Im(dp),Im(rv1),rv2);
338 addDot_op(Re(dp),Re(rv1),rv2);
339 addDot_op(Im(dp),Im(rv1),rv2);
343 #if(CXSC_INDEX_CHECK)
349 #if(CXSC_INDEX_CHECK)
350 if(
VecLen(rv1)!=
VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM(
"void accumulate(cdotprecision&, const cvector &, const rmatrix_subv &)"));
352 addDot(Re(dp),Re(rv1),rv2);
353 addDot(Im(dp),Im(rv1),rv2);
358 addDot_op(Re(dp),Re(rv1),rv2);
359 addDot_op(Im(dp),Im(rv1),rv2);
363 #if(CXSC_INDEX_CHECK)
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 &)"));
372 addDot(Re(dp),Re(rv1),rv2);
373 addDot(Im(dp),Im(rv1),rv2);
378 addDot_op(Re(dp),Re(rv1),rv2);
379 addDot_op(Im(dp),Im(rv1),rv2);
383 #if(CXSC_INDEX_CHECK)
389 #if(CXSC_INDEX_CHECK)
390 if(
VecLen(rv1)!=
VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM(
"void accumulate(cdotprecision&, const rvector &, const cmatrix_subv &)"));
392 addDot(Re(dp),rv1,Re(rv2));
393 addDot(Im(dp),rv1,Im(rv2));
398 addDot_op(Re(dp),rv1,Re(rv2));
399 addDot_op(Im(dp),rv1,Im(rv2));
403 #if(CXSC_INDEX_CHECK)
409 #if(CXSC_INDEX_CHECK)
410 if(
VecLen(rv1)!=
VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM(
"void accumulate(cdotprecision&, const cmatrix_subv &, const rvector &)"));
412 addDot(Re(dp),Re(rv1),rv2);
413 addDot(Im(dp),Im(rv1),rv2);
418 addDot_op(Re(dp),Re(rv1),rv2);
419 addDot_op(Im(dp),Im(rv1),rv2);
423 #if(CXSC_INDEX_CHECK)
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 &)"));
432 addDot(Re(dp),sl1,Re(rv2));
433 addDot(Im(dp),sl1,Im(rv2));
438 addDot_op(Re(dp),sl1,Re(rv2));
439 addDot_op(Im(dp),sl1,Im(rv2));
443 #if(CXSC_INDEX_CHECK)
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 &)"));
452 addDot(Re(dp),Re(rv1),sl2);
453 addDot(Im(dp),Im(rv1),sl2);
458 addDot_op(Re(dp),Re(rv1),sl2);
459 addDot_op(Im(dp),Im(rv1),sl2);
463 #if(CXSC_INDEX_CHECK)
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 &)"));
474 addDot(Re(tmp),rv1,Re(rv2));
475 addDot(Im(tmp),rv1,Im(rv2));
480 #if(CXSC_INDEX_CHECK)
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 &)"));
491 addDot(Re(tmp),Re(rv1),rv2);
492 addDot(Im(tmp),Im(rv1),rv2);
497 #if(CXSC_INDEX_CHECK)
503 #if(CXSC_INDEX_CHECK)
504 if(
VecLen(rv1)!=
VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM(
"void accumulate(cidotprecision&, const rvector &, const cmatrix_subv &)"));
508 addDot(Re(tmp),rv1,Re(rv2));
509 addDot(Im(tmp),rv1,Im(rv2));
514 #if(CXSC_INDEX_CHECK)
520 #if(CXSC_INDEX_CHECK)
521 if(
VecLen(rv1)!=
VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM(
"void accumulate(cidotprecision&, const cmatrix_subv &, const rvector &)"));
525 addDot(Re(tmp),Re(rv1),rv2);
526 addDot(Im(tmp),Im(rv1),rv2);
531 #if(CXSC_INDEX_CHECK)
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 &)"));
542 addDot(Re(tmp),sl1,Re(rv2));
543 addDot(Im(tmp),sl1,Im(rv2));
548 #if(CXSC_INDEX_CHECK)
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 &)"));
559 addDot(Re(tmp),Re(rv1),sl2);
560 addDot(Im(tmp),Im(rv1),sl2);
565 #if(CXSC_INDEX_CHECK)
571 #if(CXSC_INDEX_CHECK)
572 if(
VecLen(rv1)!=
VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM(
"void accumulate(cidotprecision&, const imatrix_subv &, const cvector &)"));
578 addDot(tmp_re,rv1,Re(rv2));
579 addDot(tmp_im,rv1,Im(rv2));
584 #if(CXSC_INDEX_CHECK)
590 #if(CXSC_INDEX_CHECK)
591 if(
VecLen(rv1)!=
VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM(
"void accumulate(cidotprecision&, const cvector &, const imatrix_subv &)"));
597 addDot(tmp_re,Re(rv1),rv2);
598 addDot(tmp_im,Im(rv1),rv2);
602 #if(CXSC_INDEX_CHECK)
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 &)"));
615 addDot(tmp_re,rv1,Re(rv2));
616 addDot(tmp_im,rv1,Im(rv2));
621 #if(CXSC_INDEX_CHECK)
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 &)"));
634 addDot(tmp_re,Re(rv1),rv2);
635 addDot(tmp_im,Im(rv1),rv2);
640 #if(CXSC_INDEX_CHECK)
646 #if(CXSC_INDEX_CHECK)
647 if(
VecLen(rv1)!=
VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM(
"void accumulate(cidotprecision&, const cmatrix_subv &, const ivector &)"));
653 addDot(tmp_re,Re(rv1),rv2);
654 addDot(tmp_im,Im(rv1),rv2);
659 #if(CXSC_INDEX_CHECK)
665 #if(CXSC_INDEX_CHECK)
666 if(
VecLen(rv1)!=
VecLen(rv2)) cxscthrow(OP_WITH_WRONG_DIM(
"void accumulate(cidotprecision&, const ivector &, const cmatrix_subv &)"));
672 addDot(tmp_re,rv1,Re(rv2));
673 addDot(tmp_im,rv1,Im(rv2));
678 #if(CXSC_INDEX_CHECK)
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 &)"));
691 addDot(tmp_re,Re(rv1),rv2);
692 addDot(tmp_im,Im(rv1),rv2);
697 #if(CXSC_INDEX_CHECK)
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 &)"));
710 addDot(tmp_re,rv1,Re(rv2));
711 addDot(tmp_im,rv1,Im(rv2));
The Data Type cdotprecision.
void set_k(unsigned int i)
Set precision for computation of dot products.
The Data Type cidotprecision.
int get_k() const
Get currently set precision for computation of dot products.
The Data Type cmatrix_subv.
The Data Type cvector_slice.
The Data Type idotprecision.
void set_k(unsigned int i)
Set precision for computation of dot products.
The Data Type imatrix_subv.
The Data Type ivector_slice.
The Data Type rmatrix_subv.
The Data Type rvector_slice.
The namespace cxsc, providing all functionality of the class library C-XSC.
cimatrix_subv Col(cimatrix &m, const int &i) noexcept
Returns one column of the matrix as a vector.
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...
rmatrix CompMat(const cimatrix &A)
Returns Ostrowski's comparison matrix.
cimatrix transp(const cimatrix &A)
Returns the transposed matrix.
cimatrix_subv Row(cimatrix &m, const int &i) noexcept
Returns one row of the matrix as a vector.
int Ub(const cimatrix &rm, const int &i) noexcept
Returns the upper bound index.
void DoubleSize(cimatrix &A)
Doubles the size of the matrix.
cimatrix Id(const cimatrix &A)
Returns the Identity matrix.
ivector abs(const cimatrix_subv &mv) noexcept
Returns the absolute value of the matrix.
void Resize(cimatrix &A) noexcept
Resizes the matrix.
int Lb(const cimatrix &rm, const int &i) noexcept
Returns the lower bound index.