Matrix_ArrayComplexSparseInline.cxx
1 // Copyright (C) 2003-2011 Marc DuruflĂ©
2 // Copyright (C) 2001-2011 Vivien Mallet
3 //
4 // This file is part of the linear-algebra library Seldon,
5 // http://seldon.sourceforge.net/.
6 //
7 // Seldon is free software; you can redistribute it and/or modify it under the
8 // terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 2.1 of the License, or (at your option)
10 // any later version.
11 //
12 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
15 // more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with Seldon. If not, see http://www.gnu.org/licenses/.
19 
20 
21 #ifndef SELDON_FILE_MATRIX_ARRAY_COMPLEX_SPARSE_INLINE_CXX
22 
23 #include "Matrix_ArrayComplexSparse.hxx"
24 
25 namespace Seldon
26 {
27 
28 
29  /****************
30  * CONSTRUCTORS *
31  ****************/
32 
33 
35 
38  template <class T, class Prop, class Storage, class Allocator>
41  : VirtualMatrix<T>(), val_real_(), val_imag_()
42  {
43  }
44 
45 
47 
52  template <class T, class Prop, class Storage, class Allocator>
54  Matrix_ArrayComplexSparse(int i, int j): VirtualMatrix<T>(i, j),
55  val_real_(Storage::GetFirst(i, j)), val_imag_(Storage::GetFirst(i, j))
56  {
57  }
58 
59 
60  /**************
61  * DESTRUCTOR *
62  **************/
63 
64 
66  template <class T, class Prop, class Storage, class Allocator>
69  {
70  Clear();
71  }
72 
73 
75 
78  template <class T, class Prop, class Storage, class Allocator>
80  {
81  this->m_ = 0;
82  this->n_ = 0;
83  val_real_.Clear();
84  val_imag_.Clear();
85  }
86 
87 
88  /*******************
89  * BASIC FUNCTIONS *
90  *******************/
91 
92 
94 
99  template <class T, class Prop, class Storage, class Allocator>
102  {
103  return (GetRealNonZeros()+GetImagNonZeros());
104  }
105 
106 
108 
113  template <class T, class Prop, class Storage, class Allocator>
116  {
117  return GetRealNonZeros();
118  }
119 
120 
122 
127  template <class T, class Prop, class Storage, class Allocator>
130  {
131  return GetImagNonZeros();
132  }
133 
134 
136 
141  template <class T, class Prop, class Storage, class Allocator>
144  {
145  return (GetRealNonZeros()+GetImagNonZeros());
146  }
147 
148 
150 
155  template <class T, class Prop, class Storage, class Allocator>
157  GetRealInd(int i) const
158  {
159  return val_real_(i).GetIndex();
160  }
161 
162 
164 
168  template <class T, class Prop, class Storage, class Allocator>
169  inline typename Allocator::value_type*
171  const
172  {
173  return val_real_(i).GetData();
174  }
175 
176 
178 
183  template <class T, class Prop, class Storage, class Allocator>
185  GetImagInd(int i) const
186  {
187  return val_imag_(i).GetIndex();
188  }
189 
190 
192 
196  template <class T, class Prop, class Storage, class Allocator>
197  inline typename Allocator::value_type*
199  const
200  {
201  return val_imag_(i).GetData();
202  }
203 
204 
205  /**********************************
206  * ELEMENT ACCESS AND AFFECTATION *
207  **********************************/
208 
209 
211 
217  template <class T, class Prop, class Storage, class Allocator>
218  inline const typename
219  Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::entry_type
221  (int i, int j) const
222  {
223 
224 #ifdef SELDON_CHECK_BOUNDS
225  CheckBounds(i, j, this->m_, this->n_, "Matrix");
226 #endif
227 
228  return entry_type(this->val_real_(Storage::GetFirst(i, j))
229  (Storage::GetSecond(i, j)),
230  this->val_imag_(Storage::GetFirst(i, j))
231  (Storage::GetSecond(i, j)) );
232  }
233 
234 
236 
242  template <class T, class Prop, class Storage, class Allocator>
243  inline typename
244  Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::entry_type&
246  ::Val(int i, int j)
247  {
248  throw Undefined("Matrix_ArrayComplexSparse::Val(int i, int j)");
249  }
250 
251 
253 
259  template <class T, class Prop, class Storage, class Allocator>
260  inline const typename
261  Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::entry_type&
263  ::Val(int i, int j) const
264  {
265  throw Undefined("Matrix_ArrayComplexSparse::Val(int i, int j)");
266  }
267 
268 
270 
276  template <class T, class Prop, class Storage, class Allocator>
277  inline typename
278  Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::entry_type&
280  ::Get(int i, int j)
281  {
282  throw Undefined("Matrix_ArrayComplexSparse::Get(int i, int j)");
283  }
284 
285 
287 
293  template <class T, class Prop, class Storage, class Allocator>
294  inline const typename
295  Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::entry_type&
297  ::Get(int i, int j) const
298  {
299  throw Undefined("Matrix_ArrayComplexSparse::Get(int i, int j)");
300  }
301 
302 
304 
309  template <class T, class Prop, class Storage, class Allocator>
310  inline typename Allocator::value_type&
312  ::ValReal(int i, int j)
313  {
314  return val_real_(Storage::GetFirst(i, j)).Val(Storage::GetSecond(i, j));
315  }
316 
317 
319 
324  template <class T, class Prop, class Storage, class Allocator>
325  inline const typename Allocator::value_type&
327  ::ValReal(int i, int j) const
328  {
329  return val_real_(Storage::GetFirst(i, j)).Val(Storage::GetSecond(i, j));
330  }
331 
332 
334 
339  template <class T, class Prop, class Storage, class Allocator>
340  inline typename Allocator::value_type&
342  ::ValImag(int i, int j)
343  {
344  return val_imag_(Storage::GetFirst(i, j)).Val(Storage::GetSecond(i, j));
345  }
346 
347 
349 
354  template <class T, class Prop, class Storage, class Allocator>
355  inline const typename Allocator::value_type&
357  ::ValImag(int i, int j) const
358  {
359  return val_imag_(Storage::GetFirst(i, j)).Val(Storage::GetSecond(i, j));
360  }
361 
362 
364 
369  template <class T, class Prop, class Storage, class Allocator>
370  inline typename Allocator::value_type&
372  ::GetReal(int i, int j)
373  {
374  return val_real_(Storage::GetFirst(i, j)).Get(Storage::GetSecond(i, j));
375  }
376 
377 
379 
384  template <class T, class Prop, class Storage, class Allocator>
385  inline const typename Allocator::value_type&
387  ::GetReal(int i, int j) const
388  {
389  return val_real_(Storage::GetFirst(i, j)).Get(Storage::GetSecond(i, j));
390  }
391 
392 
394 
399  template <class T, class Prop, class Storage, class Allocator>
400  inline typename Allocator::value_type&
402  ::GetImag(int i, int j)
403  {
404  return val_imag_(Storage::GetFirst(i, j)).Get(Storage::GetSecond(i, j));
405  }
406 
407 
409 
414  template <class T, class Prop, class Storage, class Allocator>
415  inline const typename Allocator::value_type&
417  ::GetImag(int i, int j) const
418  {
419  return val_imag_(Storage::GetFirst(i, j)).Get(Storage::GetSecond(i, j));
420  }
421 
422 
424 
429  template <class T, class Prop, class Storage, class Allocator>
430  inline const typename Allocator::value_type&
432  ValueReal(int i, int j) const
433  {
434 
435 #ifdef SELDON_CHECK_BOUNDS
436  CheckBounds(i, j, Storage::GetFirst(this->m_, this->n_),
437  this->val_real_(i).GetM(), "Matrix_ArrayComplexSparse");
438 #endif
439 
440  return val_real_(i).Value(j);
441  }
442 
443 
445 
450  template <class T, class Prop, class Storage, class Allocator>
451  inline typename Allocator::value_type&
453  ValueReal(int i, int j)
454  {
455 
456 #ifdef SELDON_CHECK_BOUNDS
457  CheckBounds(i, j, Storage::GetFirst(this->m_, this->n_),
458  this->val_real_(i).GetM(), "Matrix_ArrayComplexSparse");
459 #endif
460 
461  return val_real_(i).Value(j);
462  }
463 
464 
466 
471  template <class T, class Prop, class Storage, class Allocator>
473  IndexReal(int i, int j) const
474  {
475 
476 #ifdef SELDON_CHECK_BOUNDS
477  CheckBounds(i, j, Storage::GetFirst(this->m_, this->n_),
478  this->val_real_(i).GetM(), "Matrix_ArrayComplexSparse");
479 #endif
480 
481  return val_real_(i).Index(j);
482  }
483 
484 
486 
491  template <class T, class Prop, class Storage, class Allocator>
493  IndexReal(int i, int j)
494  {
495 
496 #ifdef SELDON_CHECK_BOUNDS
497  CheckBounds(i, j, Storage::GetFirst(this->m_, this->n_),
498  this->val_real_(i).GetM(), "Matrix_ArrayComplexSparse");
499 #endif
500 
501  return val_real_(i).Index(j);
502  }
503 
504 
506 
511  template <class T, class Prop, class Storage, class Allocator>
512  inline const typename Allocator::value_type&
514  ValueImag(int i, int j) const
515  {
516 
517 #ifdef SELDON_CHECK_BOUNDS
518  CheckBounds(i, j, Storage::GetFirst(this->m_, this->n_),
519  this->val_imag_(i).GetM(), "Matrix_ArrayComplexSparse");
520 #endif
521 
522  return val_imag_(i).Value(j);
523  }
524 
525 
527 
532  template <class T, class Prop, class Storage, class Allocator>
533  inline typename Allocator::value_type&
535  ValueImag (int i, int j)
536  {
537 
538 #ifdef SELDON_CHECK_BOUNDS
539  CheckBounds(i, j, Storage::GetFirst(this->m_, this->n_),
540  this->val_imag_(i).GetM(), "Matrix_ArrayComplexSparse");
541 #endif
542 
543  return val_imag_(i).Value(j);
544  }
545 
546 
548 
553  template <class T, class Prop, class Storage, class Allocator>
555  IndexImag(int i, int j) const
556  {
557 
558 #ifdef SELDON_CHECK_BOUNDS
559  CheckBounds(i, j, Storage::GetFirst(this->m_, this->n_),
560  this->val_imag_(i).GetM(), "Matrix_ArrayComplexSparse");
561 #endif
562 
563  return val_imag_(i).Index(j);
564  }
565 
566 
568 
573  template <class T, class Prop, class Storage, class Allocator>
575  IndexImag(int i, int j)
576  {
577 
578 #ifdef SELDON_CHECK_BOUNDS
579  CheckBounds(i, j, Storage::GetFirst(this->m_, this->n_),
580  this->val_imag_(i).GetM(), "Matrix_ArrayComplexSparse");
581 #endif
582 
583  return val_imag_(i).Index(j);
584  }
585 
586 
588 
594  template <class T, class Prop, class Storage, class Allocator>
596  SetRealData(int i, int n, value_type* val, int* ind)
597  {
598  val_real_(i).SetData(n, val, ind);
599  }
600 
601 
603 
609  template <class T, class Prop, class Storage, class Allocator>
611  SetImagData(int i, int n, value_type* val, int* ind)
612  {
613  val_imag_(i).SetData(n, val, ind);
614  }
615 
616 
618 
622  template <class T, class Prop, class Storage, class Allocator>
624  {
625  val_real_(i).Nullify();
626  }
627 
628 
630 
634  template <class T, class Prop, class Storage, class Allocator>
636  {
637  val_imag_(i).Nullify();
638  }
639 
640 
642 
647  template <class T, class Prop, class Storage, class Allocator>
650  {
651  this->m_ = m;
652  this->n_ = n;
653  val_real_.SetData(Storage::GetFirst(m, n), val);
654  }
655 
656 
658 
663  template <class T, class Prop, class Storage, class Allocator>
666  {
667  this->m_ = m;
668  this->n_ = n;
669  val_imag_.SetData(Storage::GetFirst(m, n), val);
670  }
671 
672 
674 
678  template <class T, class Prop, class Storage, class Allocator>
680  {
681  this->m_ = 0;
682  this->n_ = 0;
683  val_real_.Nullify();
684  }
685 
686 
688 
692  template <class T, class Prop, class Storage, class Allocator>
694  {
695  this->m_ = 0;
696  this->n_ = 0;
697  val_imag_.Nullify();
698  }
699 
700 
701 #ifdef SELDON_WITH_VIRTUAL
702  template <class T, class Prop, class Storage, class Allocator>
704  ::ApplySor(const SeldonTranspose& trans, Vector<Treal>& x, const Vector<Treal>& r,
705  const typename ClassComplexType<T>::Treal& omega,
706  int nb_iter, int stage_ssor) const
707  {
708  SOR(trans, static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this),
709  x, r, omega, nb_iter, stage_ssor);
710  }
711 
712  template <class T, class Prop, class Storage, class Allocator>
713  inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>
714  ::ApplySor(const SeldonTranspose& trans, Vector<Tcplx>& x, const Vector<Tcplx>& r,
715  const typename ClassComplexType<T>::Treal& omega,
716  int nb_iter, int stage_ssor) const
717  {
718  SOR(trans,
719  static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this),
720  x, r, omega, nb_iter, stage_ssor);
721  }
722 
723  template <class T, class Prop, class Storage, class Allocator>
724  inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>
725  ::MltAddVector(const Treal& alpha, const Vector<Treal>& x,
726  const Treal& beta, Vector<Treal>& y) const
727  {
728  cout << "Not defined for real numbers" << endl;
729  abort();
730  }
731 
732  template <class T, class Prop, class Storage, class Allocator>
733  inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>
734  ::MltAddVector(const Tcplx& alpha, const Vector<Tcplx>& x,
735  const Tcplx& beta, Vector<Tcplx>& y) const
736  {
737  MltAdd(alpha,
738  static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this),
739  x, beta, y);
740  }
741 
742  template <class T, class Prop, class Storage, class Allocator>
743  inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>
744  ::MltAddVector(const Treal& alpha, const SeldonTranspose& trans,
745  const Vector<Treal>& x,
746  const Treal& beta, Vector<Treal>& y) const
747  {
748  cout << "Not defined for real numbers" << endl;
749  abort();
750  }
751 
752  template <class T, class Prop, class Storage, class Allocator>
753  inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>
754  ::MltAddVector(const Tcplx& alpha, const SeldonTranspose& trans,
755  const Vector<Tcplx>& x,
756  const Tcplx& beta, Vector<Tcplx>& y) const
757  {
758  MltAdd(alpha, trans,
759  static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this),
760  x, beta, y);
761  }
762 
763  template <class T, class Prop, class Storage, class Allocator>
764  inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>
765  ::MltVector(const Vector<Treal>& x, Vector<Treal>& y) const
766  {
767  cout << "Not defined for real numbers" << endl;
768  abort();
769  }
770 
771  template <class T, class Prop, class Storage, class Allocator>
772  inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>
773  ::MltVector(const Vector<Tcplx>& x, Vector<Tcplx>& y) const
774  {
775  Mlt(static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this), x, y);
776  }
777 
778  template <class T, class Prop, class Storage, class Allocator>
779  inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>
780  ::MltVector(const SeldonTranspose& trans,
781  const Vector<Treal>& x, Vector<Treal>& y) const
782  {
783  cout << "Not defined for real numbers" << endl;
784  abort();
785  }
786 
787  template <class T, class Prop, class Storage, class Allocator>
788  inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>
789  ::MltVector(const SeldonTranspose& trans,
790  const Vector<Tcplx>& x, Vector<Tcplx>& y) const
791  {
792  Mlt(trans,
793  static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this), x, y);
794  }
795 
796  template <class T, class Prop, class Storage, class Allocator>
797  inline bool Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>
798  ::IsSymmetric() const
799  {
800  return IsSymmetricMatrix(static_cast<const Matrix<T, Prop, Storage,
801  Allocator>& >(*this));
802  }
803 #endif
804 
805 
807  // MATRIX<ARRAY_COLCOMPLEXSPARSE> //
809 
810 
812 
815  template <class T, class Prop, class Allocator>
817  Matrix_ArrayComplexSparse<T, Prop, ArrayColComplexSparse, Allocator>()
818  {
819  }
820 
821 
823 
828  template <class T, class Prop, class Allocator>
830  ::Matrix(int i, int j) :
831  Matrix_ArrayComplexSparse<T, Prop, ArrayColComplexSparse, Allocator>(i, j)
832  {
833  }
834 
835 
837  template <class T, class Prop, class Allocator>
840  {
841  this->val_real_(i).Clear();
842  }
843 
844 
846  template <class T, class Prop, class Allocator>
849  {
850  this->val_imag_(i).Clear();
851  }
852 
853 
855 
859  template <class T, class Prop, class Alloc> inline
861  ::ReallocateRealColumn(int i, int j)
862  {
863  this->val_real_(i).Reallocate(j);
864  }
865 
866 
868 
872  template <class T, class Prop, class Alloc> inline
873  void Matrix<T, Prop, ArrayColComplexSparse, Alloc>
874  ::ReallocateImagColumn(int i, int j)
875  {
876  this->val_imag_(i).Reallocate(j);
877  }
878 
879 
881 
885  template <class T, class Prop, class Allocator> inline
887  ::ResizeRealColumn(int i, int j)
888  {
889  this->val_real_(i).Resize(j);
890  }
891 
892 
894 
898  template <class T, class Prop, class Allocator> inline
900  ::ResizeImagColumn(int i, int j)
901  {
902  this->val_imag_(i).Resize(j);
903  }
904 
905 
907 
911  template <class T, class Prop, class Allocator> inline
913  ::SwapRealColumn(int i, int j)
914  {
915  Swap(this->val_real_(i), this->val_real_(j));
916  }
917 
918 
920 
924  template <class T, class Prop, class Allocator> inline
926  ::SwapImagColumn(int i, int j)
927  {
928  Swap(this->val_imag_(i), this->val_imag_(j));
929  }
930 
931 
933 
937  template <class T, class Prop, class Allocator>
939  ReplaceRealIndexColumn(int i, IVect& new_index)
940  {
941  for (int j = 0; j < this->val_real_(i).GetM(); j++)
942  this->val_real_(i).Index(j) = new_index(j);
943  }
944 
945 
947 
951  template <class T, class Prop, class Allocator>
953  ReplaceImagIndexColumn(int i, IVect& new_index)
954  {
955  for (int j = 0; j < this->val_imag_(i).GetM(); j++)
956  this->val_imag_(i).Index(j) = new_index(j);
957  }
958 
959 
961 
965  template <class T, class Prop, class Allocator>
967  GetRealColumnSize(int i) const
968  {
969  return this->val_real_(i).GetSize();
970  }
971 
972 
974 
978  template <class T, class Prop, class Allocator>
980  GetImagColumnSize(int i) const
981  {
982  return this->val_imag_(i).GetSize();
983  }
984 
985 
987  template <class T, class Prop, class Allocator> inline
989  ::PrintRealColumn(int i) const
990  {
991  this->val_real_(i).Print();
992  }
993 
994 
996  template <class T, class Prop, class Allocator> inline
998  ::PrintImagColumn(int i) const
999  {
1000  this->val_imag_(i).Print();
1001  }
1002 
1003 
1005 
1010  template <class T, class Prop, class Allocator> inline
1013  {
1014  this->val_real_(i).Assemble();
1015  }
1016 
1017 
1019 
1024  template <class T, class Prop, class Allocator> inline
1027  {
1028  this->val_imag_(i).Assemble();
1029  }
1030 
1031 
1033 
1038  template <class T, class Prop, class Allocator>
1040  AddInteraction(int i, int j, const entry_type& val)
1041  {
1042  if (real(val) != value_type(0))
1043  this->val_real_(j).AddInteraction(i, real(val));
1044 
1045  if (imag(val) != value_type(0))
1046  this->val_imag_(j).AddInteraction(i, imag(val));
1047  }
1048 
1049 
1051  // MATRIX<ARRAY_ROWCOMPLEXSPARSE> //
1053 
1054 
1056 
1059  template <class T, class Prop, class Allocator>
1061  Matrix_ArrayComplexSparse<T, Prop, ArrayRowComplexSparse, Allocator>()
1062  {
1063  }
1064 
1065 
1067 
1072  template <class T, class Prop, class Allocator>
1074  ::Matrix(int i, int j):
1075  Matrix_ArrayComplexSparse<T, Prop, ArrayRowComplexSparse, Allocator>(i, j)
1076  {
1077  }
1078 
1079 
1081  template <class T, class Prop, class Allocator>
1084  {
1085  this->val_real_(i).Clear();
1086  }
1087 
1088 
1090  template <class T, class Prop, class Allocator>
1093  {
1094  this->val_imag_(i).Clear();
1095  }
1096 
1097 
1099  template <class T, class Prop, class Allocator>
1102  {
1103  ClearRealRow(i);
1104  ClearImagRow(i);
1105  }
1106 
1107 
1109 
1114  template <class T, class Prop, class Allocator>
1116  ReallocateRealRow(int i, int j)
1117  {
1118  this->val_real_(i).Reallocate(j);
1119  }
1120 
1121 
1123 
1128  template <class T, class Prop, class Allocator>
1130  ReallocateImagRow(int i, int j)
1131  {
1132  this->val_imag_(i).Reallocate(j);
1133  }
1134 
1135 
1137 
1142  template <class T, class Prop, class Allocator> inline
1144  ::ResizeRealRow(int i, int j)
1145  {
1146  this->val_real_(i).Resize(j);
1147  }
1148 
1149 
1151 
1156  template <class T, class Prop, class Allocator> inline
1158  ::ResizeImagRow(int i, int j)
1159  {
1160  this->val_imag_(i).Resize(j);
1161  }
1162 
1163 
1165 
1169  template <class T, class Prop, class Allocator>
1171  ::SwapRealRow(int i,int j)
1172  {
1173  Swap(this->val_real_(i), this->val_real_(j));
1174  }
1175 
1176 
1178 
1182  template <class T, class Prop, class Allocator>
1184  ::SwapImagRow(int i, int j)
1185  {
1186  Swap(this->val_imag_(i), this->val_imag_(j));
1187  }
1188 
1189 
1191 
1195  template <class T, class Prop, class Allocator>
1197  ReplaceRealIndexRow(int i, IVect& new_index)
1198  {
1199  for (int j = 0; j < this->val_real_(i).GetM(); j++)
1200  this->val_real_(i).Index(j) = new_index(j);
1201  }
1202 
1203 
1205 
1209  template <class T, class Prop, class Allocator>
1211  ReplaceImagIndexRow(int i, IVect& new_index)
1212  {
1213  for (int j = 0; j < this->val_imag_(i).GetM(); j++)
1214  this->val_imag_(i).Index(j) = new_index(j);
1215  }
1216 
1217 
1219 
1223  template <class T, class Prop, class Allocator> inline
1225  ::GetRealRowSize(int i) const
1226  {
1227  return this->val_real_(i).GetSize();
1228  }
1229 
1230 
1232 
1236  template <class T, class Prop, class Allocator> inline
1238  ::GetImagRowSize(int i) const
1239  {
1240  return this->val_imag_(i).GetSize();
1241  }
1242 
1243 
1245  template <class T, class Prop, class Allocator> inline
1247  ::PrintRealRow(int i) const
1248  {
1249  this->val_real_(i).Print();
1250  }
1251 
1252 
1254  template <class T, class Prop, class Allocator> inline
1256  ::PrintImagRow(int i) const
1257  {
1258  this->val_imag_(i).Print();
1259  }
1260 
1261 
1263 
1268  template <class T, class Prop, class Allocator>
1271  {
1272  this->val_real_(i).Assemble();
1273  }
1274 
1275 
1277 
1282  template <class T, class Prop, class Allocator>
1285  {
1286  this->val_imag_(i).Assemble();
1287  }
1288 
1289 
1291 
1296  template <class T, class Prop, class Allocator>
1298  AddInteraction(int i, int j, const entry_type& val)
1299  {
1300  if (real(val) != value_type(0))
1301  this->val_real_(i).AddInteraction(j, real(val));
1302 
1303  if (imag(val) != value_type(0))
1304  this->val_imag_(i).AddInteraction(j, imag(val));
1305  }
1306 
1307 
1309  // MATRIX<ARRAY_COLSYMCOMPLEXSPARSE> //
1311 
1312 
1314 
1317  template <class T, class Prop, class Allocator>
1320  {
1321  }
1322 
1323 
1325 
1330  template <class T, class Prop, class Allocator>
1332  Matrix_ArrayComplexSparse<T, Prop, ArrayColSymComplexSparse, Allocator>(i, j)
1333  {
1334  }
1335 
1336 
1337  /**********************************
1338  * ELEMENT ACCESS AND AFFECTATION *
1339  **********************************/
1340 
1341 
1343 
1349  template <class T, class Prop, class Allocator>
1350  inline const typename
1353  const
1354  {
1355 #ifdef SELDON_CHECK_BOUNDS
1356  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1357 #endif
1358 
1359  if (i <= j)
1360  return entry_type(this->val_real_(j)(i), this->val_imag_(j)(i));
1361 
1362  return entry_type(this->val_real_(i)(j), this->val_imag_(i)(j));
1363  }
1364 
1365 
1367 
1372  template <class T, class Prop, class Allocator>
1373  inline typename Allocator::value_type&
1375  {
1376 #ifdef SELDON_CHECK_BOUNDS
1377  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1378 #endif
1379 
1380  if (i > j)
1381  return this->val_real_(i).Val(j);
1382 
1383  return this->val_real_(j).Val(i);
1384  }
1385 
1386 
1388 
1394  template <class T, class Prop, class Allocator>
1395  inline const typename Allocator::value_type&
1397  ::ValReal(int i, int j) const
1398  {
1399 #ifdef SELDON_CHECK_BOUNDS
1400  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1401 #endif
1402 
1403  if (i > j)
1404  return this->val_real_(j).Val(i);
1405 
1406  return this->val_real_(j).Val(i);
1407  }
1408 
1409 
1411 
1417  template <class T, class Prop, class Allocator>
1418  inline typename Allocator::value_type&
1420  {
1421 #ifdef SELDON_CHECK_BOUNDS
1422  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1423 #endif
1424 
1425  if (i <= j)
1426  return this->val_real_(j).Get(i);
1427 
1428  return this->val_real_(i).Get(j);
1429  }
1430 
1431 
1433 
1439  template <class T, class Prop, class Allocator>
1440  inline const typename Allocator::value_type&
1442  ::GetReal(int i, int j) const
1443  {
1444 #ifdef SELDON_CHECK_BOUNDS
1445  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1446 #endif
1447 
1448  if (i <= j)
1449  return this->val_real_(j).Get(i);
1450 
1451  return this->val_real_(i).Get(j);
1452  }
1453 
1454 
1456 
1462  template <class T, class Prop, class Allocator>
1463  inline typename Allocator::value_type&
1465  {
1466 #ifdef SELDON_CHECK_BOUNDS
1467  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1468 #endif
1469 
1470  if (i > j)
1471  return this->val_imag_(i).Val(j);
1472 
1473  return this->val_imag_(j).Val(i);
1474  }
1475 
1476 
1478 
1483  template <class T, class Prop, class Allocator>
1484  inline const typename Allocator::value_type&
1486  ::ValImag(int i, int j) const
1487  {
1488 #ifdef SELDON_CHECK_BOUNDS
1489  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1490 #endif
1491  if (i > j)
1492  return this->val_imag_(i).Val(j);
1493 
1494  return this->val_imag_(j).Val(i);
1495  }
1496 
1497 
1499 
1504  template <class T, class Prop, class Allocator>
1505  inline typename Allocator::value_type&
1507  {
1508 #ifdef SELDON_CHECK_BOUNDS
1509  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1510 #endif
1511 
1512  if (i <= j)
1513  return this->val_imag_(j).Get(i);
1514 
1515  return this->val_imag_(i).Get(j);
1516  }
1517 
1518 
1520 
1525  template <class T, class Prop, class Allocator>
1526  inline const typename Allocator::value_type&
1528  ::GetImag(int i, int j) const
1529  {
1530 #ifdef SELDON_CHECK_BOUNDS
1531  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1532 #endif
1533 
1534  if (i <= j)
1535  return this->val_imag_(j).Val(i);
1536 
1537  return this->val_imag_(i).Val(j);
1538  }
1539 
1540 
1542  template <class T, class Prop, class Allocator> inline
1544  {
1545  this->val_real_(i).Clear();
1546  }
1547 
1548 
1550  template <class T, class Prop, class Allocator> inline
1552  {
1553  this->val_imag_(i).Clear();
1554  }
1555 
1556 
1558 
1563  template <class T, class Prop, class Allocator>
1566  {
1567  this->val_real_(i).Reallocate(j);
1568  }
1569 
1570 
1572 
1577  template <class T, class Prop, class Allocator>
1580  {
1581  this->val_imag_(i).Reallocate(j);
1582  }
1583 
1584 
1586 
1590  template <class T, class Prop, class Allocator>
1592  ResizeRealColumn(int i, int j)
1593  {
1594  this->val_real_(i).Resize(j);
1595  }
1596 
1597 
1599 
1603  template <class T, class Prop, class Allocator>
1605  ResizeImagColumn(int i, int j)
1606  {
1607  this->val_imag_(i).Resize(j);
1608  }
1609 
1610 
1612 
1616  template <class T, class Prop, class Allocator>
1618  SwapRealColumn(int i, int j)
1619  {
1620  Swap(this->val_real_(i), this->val_real_(j));
1621  }
1622 
1623 
1625 
1629  template <class T, class Prop, class Allocator>
1631  SwapImagColumn(int i, int j)
1632  {
1633  Swap(this->val_imag_(i), this->val_imag_(j));
1634  }
1635 
1636 
1638 
1642  template <class T, class Prop, class Allocator>
1644  ReplaceRealIndexColumn(int i, IVect& new_index)
1645  {
1646  for (int j = 0; j < this->val_real_(i).GetM(); j++)
1647  this->val_real_(i).Index(j) = new_index(j);
1648  }
1649 
1650 
1652 
1656  template <class T, class Prop, class Allocator>
1658  ReplaceImagIndexColumn(int i, IVect& new_index)
1659  {
1660  for (int j = 0; j < this->val_imag_(i).GetM(); j++)
1661  this->val_imag_(i).Index(j) = new_index(j);
1662  }
1663 
1664 
1666 
1670  template <class T, class Prop, class Allocator>
1673  {
1674  return this->val_real_(i).GetSize();
1675  }
1676 
1677 
1679 
1683  template <class T, class Prop, class Allocator>
1686  {
1687  return this->val_imag_(i).GetSize();
1688  }
1689 
1690 
1692  template <class T, class Prop, class Allocator>
1694  PrintRealColumn(int i) const
1695  {
1696  this->val_real_(i).Print();
1697  }
1698 
1699 
1701  template <class T, class Prop, class Allocator>
1703  PrintImagColumn(int i) const
1704  {
1705  this->val_imag_(i).Print();
1706  }
1707 
1708 
1710 
1715  template <class T, class Prop, class Allocator>
1718  {
1719  this->val_real_(i).Assemble();
1720  }
1721 
1722 
1724 
1729  template <class T, class Prop, class Allocator>
1732  {
1733  this->val_imag_(i).Assemble();
1734  }
1735 
1736 
1738  // MATRIX<ARRAY_ROWSYMCOMPLEXSPARSE> //
1740 
1741 
1743 
1746  template <class T, class Prop, class Allocator>
1749  {
1750  }
1751 
1752 
1754 
1759  template <class T, class Prop, class Allocator>
1761  ::Matrix(int i, int j):
1762  Matrix_ArrayComplexSparse<T, Prop, ArrayRowSymComplexSparse, Allocator>(i, j)
1763  {
1764  }
1765 
1766 
1767  /**********************************
1768  * ELEMENT ACCESS AND AFFECTATION *
1769  **********************************/
1770 
1771 
1773 
1779  template <class T, class Prop, class Allocator>
1780  inline const typename
1783  const
1784  {
1785 
1786 #ifdef SELDON_CHECK_BOUNDS
1787  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1788 #endif
1789 
1790  if (i <= j)
1791  return entry_type(this->val_real_(i)(j), this->val_imag_(i)(j));
1792 
1793  return entry_type(this->val_real_(j)(i), this->val_imag_(j)(i));
1794  }
1795 
1796 
1798 
1803  template <class T, class Prop, class Allocator>
1804  inline typename Allocator::value_type&
1806  {
1807 #ifdef SELDON_CHECK_BOUNDS
1808  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1809 #endif
1810 
1811  if (i > j)
1812  return this->val_real_(j).Val(i);
1813 
1814  return this->val_real_(i).Val(j);
1815  }
1816 
1817 
1819 
1825  template <class T, class Prop, class Allocator>
1826  inline const typename Allocator::value_type&
1828  ::ValReal(int i, int j) const
1829  {
1830 #ifdef SELDON_CHECK_BOUNDS
1831  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1832 #endif
1833  if (i > j)
1834  return this->val_real_(j).Val(i);
1835 
1836  return this->val_real_(i).Val(j);
1837  }
1838 
1839 
1841 
1847  template <class T, class Prop, class Allocator>
1848  inline typename Allocator::value_type&
1850  {
1851 #ifdef SELDON_CHECK_BOUNDS
1852  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1853 #endif
1854 
1855  if (i <= j)
1856  return this->val_real_(i).Get(j);
1857 
1858  return this->val_real_(j).Get(i);
1859  }
1860 
1861 
1863 
1869  template <class T, class Prop, class Allocator>
1870  inline const typename Allocator::value_type&
1872  ::GetReal(int i, int j) const
1873  {
1874 #ifdef SELDON_CHECK_BOUNDS
1875  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1876 #endif
1877 
1878  if (i <= j)
1879  return this->val_real_(i).Get(j);
1880 
1881  return this->val_real_(j).Get(i);
1882  }
1883 
1884 
1886 
1892  template <class T, class Prop, class Allocator>
1893  inline typename Allocator::value_type&
1895  {
1896 #ifdef SELDON_CHECK_BOUNDS
1897  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1898 #endif
1899  if (i > j)
1900  return this->val_imag_(j).Val(i);
1901 
1902  return this->val_imag_(i).Val(j);
1903  }
1904 
1905 
1907 
1912  template <class T, class Prop, class Allocator>
1913  inline const typename Allocator::value_type&
1915  ::ValImag(int i, int j) const
1916  {
1917 #ifdef SELDON_CHECK_BOUNDS
1918  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1919 #endif
1920 
1921  if (i > j)
1922  return this->val_imag_(j).Val(i);
1923 
1924  return this->val_imag_(i).Val(j);
1925  }
1926 
1927 
1929 
1934  template <class T, class Prop, class Allocator>
1935  inline typename Allocator::value_type&
1937  {
1938 #ifdef SELDON_CHECK_BOUNDS
1939  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1940 #endif
1941 
1942  if (i <= j)
1943  return this->val_imag_(i).Get(j);
1944 
1945  return this->val_imag_(j).Get(i);
1946  }
1947 
1948 
1950 
1955  template <class T, class Prop, class Allocator>
1956  inline const typename Allocator::value_type&
1958  ::GetImag(int i, int j) const
1959  {
1960 #ifdef SELDON_CHECK_BOUNDS
1961  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1962 #endif
1963 
1964  if (i <= j)
1965  return this->val_imag_(i).Val(j);
1966 
1967  return this->val_imag_(j).Val(i);
1968  }
1969 
1970 
1972  template <class T, class Prop, class Allocator>
1974  {
1975  this->val_real_(i).Clear();
1976  }
1977 
1978 
1980  template <class T, class Prop, class Allocator>
1982  {
1983  this->val_imag_(i).Clear();
1984  }
1985 
1986 
1988  template <class T, class Prop, class Allocator>
1991  {
1992  ClearRealRow(i);
1993  ClearImagRow(i);
1994  }
1995 
1996 
1998 
2003  template <class T, class Prop, class Allocator>
2006  {
2007  this->val_real_(i).Reallocate(j);
2008  }
2009 
2010 
2012 
2017  template <class T, class Prop, class Allocator>
2020  {
2021  this->val_imag_(i).Reallocate(j);
2022  }
2023 
2024 
2026 
2030  template <class T, class Prop, class Allocator>
2032  ResizeRealRow(int i,int j)
2033  {
2034  this->val_real_(i).Resize(j);
2035  }
2036 
2037 
2039 
2043  template <class T, class Prop, class Allocator>
2045  ResizeImagRow(int i,int j)
2046  {
2047  this->val_imag_(i).Resize(j);
2048  }
2049 
2050 
2052 
2056  template <class T, class Prop, class Allocator>
2058  SwapRealRow(int i,int j)
2059  {
2060  Swap(this->val_real_(i), this->val_real_(j));
2061  }
2062 
2063 
2065 
2069  template <class T, class Prop, class Allocator>
2071  SwapImagRow(int i,int j)
2072  {
2073  Swap(this->val_imag_(i), this->val_imag_(j));
2074  }
2075 
2076 
2078 
2082  template <class T, class Prop, class Allocator>
2084  ReplaceRealIndexRow(int i, IVect& new_index)
2085  {
2086  for (int j = 0; j < this->val_real_(i).GetM(); j++)
2087  this->val_real_(i).Index(j) = new_index(j);
2088  }
2089 
2090 
2092 
2096  template <class T, class Prop, class Allocator>
2098  ReplaceImagIndexRow(int i,IVect& new_index)
2099  {
2100  for (int j = 0; j < this->val_imag_(i).GetM(); j++)
2101  this->val_imag_(i).Index(j) = new_index(j);
2102  }
2103 
2104 
2106 
2110  template <class T, class Prop, class Allocator>
2113  const
2114  {
2115  return this->val_real_(i).GetSize();
2116  }
2117 
2118 
2120 
2124  template <class T, class Prop, class Allocator>
2126  ::GetImagRowSize(int i) const
2127  {
2128  return this->val_imag_(i).GetSize();
2129  }
2130 
2131 
2133  template <class T, class Prop, class Allocator>
2135  ::PrintRealRow(int i) const
2136  {
2137  this->val_real_(i).Print();
2138  }
2139 
2140 
2142  template <class T, class Prop, class Allocator>
2144  ::PrintImagRow(int i) const
2145  {
2146  this->val_imag_(i).Print();
2147  }
2148 
2149 
2151 
2156  template <class T, class Prop, class Allocator>
2159  {
2160  this->val_real_(i).Assemble();
2161  }
2162 
2163 
2165 
2170  template <class T, class Prop, class Allocator>
2173  {
2174  this->val_imag_(i).Assemble();
2175  }
2176 
2177 } // namespace Seldon
2178 
2179 #define SELDON_FILE_MATRIX_ARRAY_COMPLEX_SPARSE_INLINE_CXX
2180 #endif
Seldon::SeldonTranspose
Definition: MatrixFlag.hxx:32
Seldon::Matrix_ArrayComplexSparse::Clear
void Clear()
Clears the matrix.
Definition: Matrix_ArrayComplexSparseInline.cxx:79
Seldon::Matrix_ArrayComplexSparse
Sparse Array-matrix class.
Definition: Matrix_ArrayComplexSparse.hxx:176
Seldon::ArrayColSymComplexSparse
Definition: Storage.hxx:458
Seldon::Matrix_ArrayComplexSparse::Matrix_ArrayComplexSparse
Matrix_ArrayComplexSparse()
Default constructor.
Definition: Matrix_ArrayComplexSparseInline.cxx:40
Seldon::ArrayColComplexSparse
Definition: Storage.hxx:454
Seldon::Vector
Definition: SeldonHeader.hxx:207
Seldon::IsSymmetricMatrix
bool IsSymmetricMatrix(const Matrix< T, Prop, Storage, Allocator > &A)
returns true if the matrix is symmetric
Definition: Functions_BaseInline.cxx:778
Seldon::Matrix
Definition: SeldonHeader.hxx:226
Seldon::ArrayRowComplexSparse
Definition: Storage.hxx:446
Seldon::Matrix_ArrayComplexSparse::Get
entry_type & Get(int i, int j)
Unavailable access method.
Definition: Matrix_ArrayComplexSparseInline.cxx:280
Seldon::Undefined
Definition: Errors.hxx:62
Seldon::ArrayRowSymComplexSparse
Definition: Storage.hxx:450
Seldon::Matrix< T, Prop, ArrayColComplexSparse, Allocator >::ResizeRealColumn
void ResizeRealColumn(int i, int j)
Reallocates column i.
Definition: Matrix_ArrayComplexSparseInline.cxx:887
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::Swap
void Swap(Vector< T, Storage, Allocator > &X, Vector< T, Storage, Allocator > &Y)
Swaps X and Y without copying all elements.
Definition: Functions_Vector.cxx:348
Seldon::VirtualMatrix
Abstract base class for all matrices.
Definition: Matrix_Base.hxx:42
Seldon::Matrix_ArrayComplexSparse::Val
entry_type & Val(int i, int j)
Unavailable access method.
Definition: Matrix_ArrayComplexSparseInline.cxx:246