00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SELDON_FILE_MATRIX_ARRAY_COMPLEX_SPARSE_CXX
00022
00023 #include "Matrix_ArrayComplexSparse.hxx"
00024
00025 namespace Seldon
00026 {
00027
00028
00029
00030
00031
00032
00033
00035
00038 template <class T, class Prop, class Storage, class Allocator>
00039 inline Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00040 Matrix_ArrayComplexSparse()
00041 : val_real_(), val_imag_()
00042 {
00043 this->m_ = 0;
00044 this->n_ = 0;
00045 }
00046
00047
00049
00054 template <class T, class Prop, class Storage, class Allocator>
00055 inline Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00056 Matrix_ArrayComplexSparse(int i, int j):
00057 val_real_(Storage::GetFirst(i, j)), val_imag_(Storage::GetFirst(i, j))
00058 {
00059 this->m_ = i;
00060 this->n_ = j;
00061 }
00062
00063
00064
00065
00066
00067
00068
00070 template <class T, class Prop, class Storage, class Allocator>
00071 inline Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00072 ~Matrix_ArrayComplexSparse()
00073 {
00074 this->m_ = 0;
00075 this->n_ = 0;
00076 }
00077
00078
00080
00083 template <class T, class Prop, class Storage, class Allocator>
00084 inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::Clear()
00085 {
00086 this->~Matrix_ArrayComplexSparse();
00087 }
00088
00089
00090
00091
00092
00093
00094
00096
00102 template <class T, class Prop, class Storage, class Allocator>
00103 inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00104 Reallocate(int i, int j)
00105 {
00106
00107 Clear();
00108
00109 this->m_ = i;
00110 this->n_ = j;
00111
00112 int n = Storage::GetFirst(i,j);
00113 val_real_.Reallocate(n);
00114 val_imag_.Reallocate(n);
00115 }
00116
00117
00119
00125 template <class T, class Prop, class Storage, class Allocator>
00126 inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00127 Resize(int i, int j)
00128 {
00129 int n = Storage::GetFirst(this->m_, n_);
00130 int new_n = Storage::GetFirst(i, j);
00131 if (n != new_n)
00132 {
00133 Vector<Vector<T, VectSparse, Allocator>, VectFull,
00134 NewAlloc<Vector<T, VectSparse, Allocator> > > new_val_real;
00135
00136 Vector<Vector<T, VectSparse, Allocator>, VectFull,
00137 NewAlloc<Vector<T, VectSparse, Allocator> > > new_val_imag;
00138
00139 new_val_real.Reallocate(new_n);
00140 new_val_imag.Reallocate(new_n);
00141
00142 for (int k = 0 ; k < min(n, new_n) ; k++)
00143 {
00144 Swap(new_val_real(k), this->val_real_(k));
00145 Swap(new_val_imag(k), this->val_imag_(k));
00146 }
00147
00148 val_real_.SetData(new_n, new_val_real.GetData());
00149 val_imag_.SetData(new_n, new_val_imag.GetData());
00150 new_val_real.Nullify();
00151 new_val_imag.Nullify();
00152
00153 }
00154
00155 this->m_ = i;
00156 this->n_ = j;
00157 }
00158
00159
00160
00161
00162
00163
00164
00166
00169 template <class T, class Prop, class Storage, class Allocator>
00170 inline int Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>
00171 ::GetM() const
00172 {
00173 return m_;
00174 }
00175
00176
00178
00181 template <class T, class Prop, class Storage, class Allocator>
00182 inline int Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>
00183 ::GetN() const
00184 {
00185 return n_;
00186 }
00187
00188
00190
00194 template <class T, class Prop, class Storage, class Allocator>
00195 inline int Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>
00196 ::GetM(const SeldonTranspose& status) const
00197 {
00198 if (status.NoTrans())
00199 return m_;
00200 else
00201 return n_;
00202 }
00203
00204
00206
00210 template <class T, class Prop, class Storage, class Allocator>
00211 inline int Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>
00212 ::GetN(const SeldonTranspose& status) const
00213 {
00214 if (status.NoTrans())
00215 return n_;
00216 else
00217 return m_;
00218 }
00219
00220
00222
00225 template <class T, class Prop, class Storage, class Allocator>
00226 inline int Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00227 GetRealNonZeros() const
00228 {
00229 int nnz = 0;
00230 for (int i = 0; i < this->val_real_.GetM(); i++)
00231 nnz += this->val_real_(i).GetM();
00232
00233 return nnz;
00234 }
00235
00236
00238
00241 template <class T, class Prop, class Storage, class Allocator>
00242 inline int Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00243 GetImagNonZeros() const
00244 {
00245 int nnz = 0;
00246 for (int i = 0; i < this->val_imag_.GetM(); i++)
00247 nnz += this->val_imag_(i).GetM();
00248
00249 return nnz;
00250 }
00251
00252
00254
00259 template <class T, class Prop, class Storage, class Allocator>
00260 inline int Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00261 GetRealDataSize() const
00262 {
00263 return GetRealNonZeros();
00264 }
00265
00266
00268
00273 template <class T, class Prop, class Storage, class Allocator>
00274 inline int Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00275 GetImagDataSize() const
00276 {
00277 return GetImagNonZeros();
00278 }
00279
00280
00282
00287 template <class T, class Prop, class Storage, class Allocator>
00288 inline int Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00289 GetDataSize() const
00290 {
00291 return (GetRealNonZeros()+GetImagNonZeros());
00292 }
00293
00294
00296
00301 template <class T, class Prop, class Storage, class Allocator>
00302 inline int* Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00303 GetRealInd(int i) const
00304 {
00305 return val_real_(i).GetIndex();
00306 }
00307
00308
00310
00314 template <class T, class Prop, class Storage, class Allocator> inline T*
00315 Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::GetRealData(int i)
00316 const
00317 {
00318 return val_real_(i).GetData();
00319 }
00320
00321
00323
00328 template <class T, class Prop, class Storage, class Allocator>
00329 inline int* Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00330 GetImagInd(int i) const
00331 {
00332 return val_imag_(i).GetIndex();
00333 }
00334
00335
00337
00341 template <class T, class Prop, class Storage, class Allocator> inline T*
00342 Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::GetImagData(int i)
00343 const
00344 {
00345 return val_imag_(i).GetData();
00346 }
00347
00348
00349
00350
00351
00352
00353
00355
00361 template <class T, class Prop, class Storage, class Allocator>
00362 inline complex<T>
00363 Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::operator()
00364 (int i, int j) const
00365 {
00366
00367 #ifdef SELDON_CHECK_BOUNDS
00368 if (i < 0 || i >= this->m_)
00369 throw WrongRow("Matrix::operator()", "Index should be in [0, "
00370 + to_str(this->m_-1) + "], but is equal to "
00371 + to_str(i) + ".");
00372
00373 if (j < 0 || j >= this->n_)
00374 throw WrongCol("Matrix::operator()", "Index should be in [0, "
00375 + to_str(this->n_-1) + "], but is equal to "
00376 + to_str(j) + ".");
00377 #endif
00378
00379 return complex<T>(this->val_real_(Storage::GetFirst(i, j))
00380 (Storage::GetSecond(i, j)),
00381 this->val_imag_(Storage::GetFirst(i, j))
00382 (Storage::GetSecond(i, j)) );
00383 }
00384
00385
00387
00393 template <class T, class Prop, class Storage, class Allocator>
00394 inline complex<T>&
00395 Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>
00396 ::Val(int i, int j)
00397 {
00398 throw Undefined("Matrix_ArrayComplexSparse::Val(int i, int j)");
00399 }
00400
00402
00408 template <class T, class Prop, class Storage, class Allocator>
00409 inline const complex<T>&
00410 Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>
00411 ::Val(int i, int j) const
00412 {
00413 throw Undefined("Matrix_ArrayComplexSparse::Val(int i, int j)");
00414 }
00415
00416
00418
00423 template <class T, class Prop, class Storage, class Allocator>
00424 inline const T& Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00425 ValueReal(int i, int j) const
00426 {
00427
00428 #ifdef SELDON_CHECK_BOUNDS
00429 if (i < 0 || i >= this->m_)
00430 throw WrongRow("Matrix_ArraySparse::value", "Index should be in [0, "
00431 + to_str(this->m_-1) + "], but is equal to "
00432 + to_str(i) + ".");
00433
00434 if (j < 0 || j >= this->val_real_(i).GetM())
00435 throw WrongCol("Matrix_ArraySparse::value", "Index should be in [0, " +
00436 to_str(this->val_real_(i).GetM()-1) + "], but is equal to "
00437 + to_str(j) + ".");
00438 #endif
00439
00440 return val_real_(i).Value(j);
00441 }
00442
00443
00445
00450 template <class T, class Prop, class Storage, class Allocator>
00451 inline T&
00452 Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00453 ValueReal(int i, int j)
00454 {
00455
00456 #ifdef SELDON_CHECK_BOUNDS
00457 if (i < 0 || i >= this->m_)
00458 throw WrongRow("Matrix_ArraySparse::value", "Index should be in [0, "
00459 + to_str(this->m_-1) + "], but is equal to "
00460 + to_str(i) + ".");
00461 if (j < 0 || j >= this->val_real_(i).GetM())
00462 throw WrongCol("Matrix_ArraySparse::value", "Index should be in [0, " +
00463 to_str(this->val_real_(i).GetM()-1) + "], but is equal to "
00464 + to_str(j) + ".");
00465 #endif
00466
00467 return val_real_(i).Value(j);
00468 }
00469
00470
00472
00477 template <class T, class Prop, class Storage, class Allocator>
00478 inline int Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00479 IndexReal(int i, int j) const
00480 {
00481
00482 #ifdef SELDON_CHECK_BOUNDS
00483 if (i < 0 || i >= this->m_)
00484 throw WrongRow("Matrix_ArraySparse::index", "Index should be in [0, "
00485 + to_str(this->m_-1) + "], but is equal to "
00486 + to_str(i) + ".");
00487
00488 if (j < 0 || j >= this->val_real_(i).GetM())
00489 throw WrongCol("Matrix_ArraySparse::index", "Index should be in [0, " +
00490 to_str(this->val_real_(i).GetM()-1) + "], but is equal to "
00491 + to_str(j) + ".");
00492 #endif
00493
00494 return val_real_(i).Index(j);
00495 }
00496
00497
00499
00504 template <class T, class Prop, class Storage, class Allocator>
00505 inline int& Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00506 IndexReal(int i, int j)
00507 {
00508
00509 #ifdef SELDON_CHECK_BOUNDS
00510 if (i < 0 || i >= this->m_)
00511 throw WrongRow("Matrix_ArraySparse::index", "Index should be in [0, "
00512 + to_str(this->m_-1) + "], but is equal to "
00513 + to_str(i) + ".");
00514
00515 if (j < 0 || j >= this->val_real_(i).GetM())
00516 throw WrongCol("Matrix_ArraySparse::index", "Index should be in [0, "
00517 + to_str(this->val_real_(i).GetM()-1)
00518 + "], but is equal to " + to_str(j) + ".");
00519 #endif
00520
00521 return val_real_(i).Index(j);
00522 }
00523
00524
00526
00531 template <class T, class Prop, class Storage, class Allocator>
00532 inline const T& Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00533 ValueImag(int i, int j) const
00534 {
00535
00536 #ifdef SELDON_CHECK_BOUNDS
00537 if (i < 0 || i >= this->m_)
00538 throw WrongRow("Matrix_ArraySparse::value", "Index should be in [0, "
00539 + to_str(this->m_-1) + "], but is equal to "
00540 + to_str(i) + ".");
00541
00542 if (j < 0 || j >= this->val_imag_(i).GetM())
00543 throw WrongCol("Matrix_ArraySparse::value", "Index should be in [0, " +
00544 to_str(this->val_imag_(i).GetM()-1) + "], but is equal to "
00545 + to_str(j) + ".");
00546 #endif
00547
00548 return val_imag_(i).Value(j);
00549 }
00550
00551
00553
00558 template <class T, class Prop, class Storage, class Allocator>
00559 inline T& Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00560 ValueImag (int i, int j)
00561 {
00562
00563 #ifdef SELDON_CHECK_BOUNDS
00564 if (i < 0 || i >= this->m_)
00565 throw WrongRow("Matrix_ArraySparse::value", "Index should be in [0, "
00566 + to_str(this->m_-1) + "], but is equal to "
00567 + to_str(i) + ".");
00568
00569 if (j < 0 || j >= this->val_imag_(i).GetM())
00570 throw WrongCol("Matrix_ArraySparse::value", "Index should be in [0, " +
00571 to_str(this->val_imag_(i).GetM()-1) + "], but is equal to "
00572 + to_str(j) + ".");
00573 #endif
00574
00575 return val_imag_(i).Value(j);
00576 }
00577
00578
00580
00585 template <class T, class Prop, class Storage, class Allocator>
00586 inline int Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00587 IndexImag(int i, int j) const
00588 {
00589
00590 #ifdef SELDON_CHECK_BOUNDS
00591 if (i < 0 || i >= this->m_)
00592 throw WrongRow("Matrix_ArraySparse::index", "Index should be in [0, "
00593 + to_str(this->m_-1) + "], but is equal to "
00594 + to_str(i) + ".");
00595
00596 if (j < 0 || j >= this->val_imag_(i).GetM())
00597 throw WrongCol("Matrix_ArraySparse::index", "Index should be in [0, " +
00598 to_str(this->val_imag_(i).GetM()-1) + "], but is equal to "
00599 + to_str(j) + ".");
00600 #endif
00601
00602 return val_imag_(i).Index(j);
00603 }
00604
00605
00607
00612 template <class T, class Prop, class Storage, class Allocator>
00613 inline int& Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00614 IndexImag(int i, int j)
00615 {
00616
00617 #ifdef SELDON_CHECK_BOUNDS
00618 if (i < 0 || i >= this->m_)
00619 throw WrongRow("Matrix_ArrayComplexSparse::index",
00620 "Index should be in [0, " + to_str(this->m_-1)
00621 + "], but is equal to " + to_str(i) + ".");
00622
00623 if (j < 0 || j >= this->val_imag_(i).GetM())
00624 throw WrongCol("Matrix_ArraySparse::index", "Index should be in [0, " +
00625 to_str(this->val_imag_(i).GetM()-1) + "], but is equal to "
00626 + to_str(j) + ".");
00627 #endif
00628
00629 return val_imag_(i).Index(j);
00630 }
00631
00632
00634
00640 template <class T, class Prop, class Storage, class Allocator>
00641 inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00642 SetRealData(int i, int n, T* val, int* ind)
00643 {
00644 val_real_(i).SetData(n, val, ind);
00645 }
00646
00647
00649
00655 template <class T, class Prop, class Storage, class Allocator>
00656 inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00657 SetImagData(int i, int n, T* val, int* ind)
00658 {
00659 val_imag_(i).SetData(n, val, ind);
00660 }
00661
00662
00664
00668 template <class T, class Prop, class Storage, class Allocator>
00669 inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::NullifyReal(int i)
00670 {
00671 val_real_(i).Nullify();
00672 }
00673
00674
00676
00680 template <class T, class Prop, class Storage, class Allocator>
00681 inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::NullifyImag(int i)
00682 {
00683 val_imag_(i).Nullify();
00684 }
00685
00686
00688
00693 template <class T, class Prop, class Storage, class Allocator>
00694 inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00695 SetRealData(int m, int n, Vector<T, VectSparse, Allocator>* val)
00696 {
00697 m_ = m;
00698 n_ = n;
00699 val_real_.SetData(Storage::GetFirst(m, n), val);
00700 }
00701
00702
00704
00709 template <class T, class Prop, class Storage, class Allocator>
00710 inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00711 SetImagData(int m, int n, Vector<T, VectSparse, Allocator>* val)
00712 {
00713 m_ = m;
00714 n_ = n;
00715 val_imag_.SetData(Storage::GetFirst(m, n), val);
00716 }
00717
00718
00720
00724 template <class T, class Prop, class Storage, class Allocator>
00725 inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::NullifyReal()
00726 {
00727 m_ = 0;
00728 n_ = 0;
00729 val_real_.Nullify();
00730 }
00731
00732
00734
00738 template <class T, class Prop, class Storage, class Allocator>
00739 inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::NullifyImag()
00740 {
00741 m_ = 0;
00742 n_ = 0;
00743 val_imag_.Nullify();
00744 }
00745
00746
00747
00748
00749
00750
00751
00753
00758 template <class T, class Prop, class Storage, class Allocator>
00759 void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::Print() const
00760 {
00761 if (Storage::GetFirst(1, 0) == 1)
00762 for (int i = 0; i < this->m_; i++)
00763 {
00764 for (int j = 0; j < this->val_real_(i).GetM(); j++)
00765 cout << (i+1) << " " << this->val_real_(i).Index(j)+1
00766 << " " << this->val_real_(i).Value(j) << endl;
00767
00768 for (int j = 0; j < this->val_imag_(i).GetM(); j++)
00769 cout << (i+1) << " " << this->val_imag_(i).Index(j)+1
00770 << " (0, " << this->val_imag_(i).Value(j) << ")"<<endl;
00771 }
00772 else
00773 for (int i = 0; i < this->n_; i++)
00774 {
00775 for (int j = 0; j < this->val_real_(i).GetM(); j++)
00776 cout << this->val_real_(i).Index(j)+1 << " " << i+1
00777 << " " << this->val_real_(i).Value(j) << endl;
00778
00779 for (int j = 0; j < this->val_imag_(i).GetM(); j++)
00780 cout << this->val_imag_(i).Index(j)+1 << " " << i+1
00781 << " (0, " << this->val_imag_(i).Value(j) << ")"<<endl;
00782 }
00783 }
00784
00785
00787
00791 template <class T, class Prop, class Storage, class Allocator>
00792 void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00793 WriteText(string FileName) const
00794 {
00795 ofstream FileStream; FileStream.precision(14);
00796 FileStream.open(FileName.c_str());
00797
00798 #ifdef SELDON_CHECK_IO
00799
00800 if (!FileStream.is_open())
00801 throw IOError("Matrix_ArrayComplexSparse::WriteText(string FileName)",
00802 string("Unable to open file \"") + FileName + "\".");
00803 #endif
00804
00805 this->WriteText(FileStream);
00806
00807 FileStream.close();
00808 }
00809
00810
00812
00816 template <class T, class Prop, class Storage, class Allocator>
00817 void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00818 WriteText(ostream& FileStream) const
00819 {
00820
00821 #ifdef SELDON_CHECK_IO
00822
00823 if (!FileStream.good())
00824 throw IOError("Matrix_ArrayComplexSparse::"
00825 "WriteText(ofstream& FileStream)",
00826 "Stream is not ready.");
00827 #endif
00828
00829
00830 IVect IndRow, IndCol; Vector<complex<T> > Value;
00831 const Matrix<T, Prop, Storage, Allocator>& leaf_class =
00832 static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this);
00833
00834 ConvertMatrix_to_Coordinates(leaf_class, IndRow, IndCol,
00835 Value, 1, true);
00836
00837 for (int i = 0; i < IndRow.GetM(); i++)
00838 FileStream << IndRow(i) << " " << IndCol(i) << " " << Value(i) << '\n';
00839 }
00840
00841
00843
00849 template <class T, class Prop, class Storage, class Allocator>
00850 void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::Assemble()
00851 {
00852 for (int i = 0; i < m_ ; i++)
00853 {
00854 val_real_(i).Assemble();
00855 val_imag_(i).Assemble();
00856 }
00857 }
00858
00859
00861 template <class T, class Prop, class Storage, class Allocator>
00862 inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00863 SetIdentity()
00864 {
00865 this->n_ = this->m_;
00866 for (int i = 0; i < this->m_; i++)
00867 {
00868 val_real_(i).Reallocate(1);
00869 val_real_(i).Index(0) = i;
00870 val_real_(i).Value(0) = T(1);
00871 }
00872 }
00873
00874
00876 template <class T, class Prop, class Storage, class Allocator>
00877 inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::Zero()
00878 {
00879 for (int i = 0; i < this->m_; i++)
00880 {
00881 val_real_(i).Zero();
00882 val_imag_(i).Zero();
00883 }
00884 }
00885
00886
00888 template <class T, class Prop, class Storage, class Allocator>
00889 inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::Fill()
00890 {
00891 int value = 0;
00892 for (int i = 0; i < this->m_; i++)
00893 {
00894 for (int j = 0; j < val_real_(i).GetM(); j++)
00895 val_real_(i).Value(j) = value++;
00896
00897 for (int j = 0; j < val_imag_(i).GetM(); j++)
00898 val_imag_(i).Value(j) = value++;
00899 }
00900 }
00901
00902
00904 template <class T, class Prop, class Storage, class Allo> template<class T0>
00905 inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allo>::
00906 Fill(const complex<T0>& x)
00907 {
00908 for (int i = 0; i < this->m_; i++)
00909 {
00910 val_real_(i).Fill(real(x));
00911 val_imag_(i).Fill(imag(x));
00912 }
00913 }
00914
00915
00917 template <class T, class Prop, class Storage, class Allocator>
00918 template <class T0>
00919 inline Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>&
00920 Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::operator=
00921 (const complex<T0>& x)
00922 {
00923 this->Fill(x);
00924 }
00925
00926
00928 template <class T, class Prop, class Storage, class Allocator>
00929 inline void Matrix_ArrayComplexSparse<T, Prop, Storage, Allocator>::
00930 FillRand()
00931 {
00932 for (int i = 0; i < this->m_; i++)
00933 {
00934 val_real_(i).FillRand();
00935 val_imag_(i).FillRand();
00936 }
00937 }
00938
00939
00941
00943
00944
00946
00949 template <class T, class Prop, class Allocator>
00950 inline Matrix<T, Prop, ArrayColComplexSparse, Allocator>::Matrix() throw():
00951 Matrix_ArrayComplexSparse<T, Prop, ArrayColComplexSparse, Allocator>()
00952 {
00953 }
00954
00955
00957
00962 template <class T, class Prop, class Allocator>
00963 inline Matrix<T, Prop, ArrayColComplexSparse, Allocator>::Matrix(int i, int j):
00964 Matrix_ArrayComplexSparse<T, Prop, ArrayColComplexSparse, Allocator>(i, j)
00965 {
00966 }
00967
00968
00970 template <class T, class Prop, class Allocator>
00971 inline void Matrix<T, Prop, ArrayColComplexSparse, Allocator>::ClearRealColumn(int i)
00972 {
00973 this->val_real_(i).Clear();
00974 }
00975
00976
00978 template <class T, class Prop, class Allocator>
00979 inline void Matrix<T, Prop, ArrayColComplexSparse, Allocator>::ClearImagColumn(int i)
00980 {
00981 this->val_imag_(i).Clear();
00982 }
00983
00984
00986
00990 template <class T, class Prop, class Alloc> inline
00991 void Matrix<T, Prop, ArrayColComplexSparse, Alloc>::ReallocateRealColumn(int i,int j)
00992 {
00993 this->val_real_(i).Reallocate(j);
00994 }
00995
00996
00998
01002 template <class T, class Prop, class Alloc> inline
01003 void Matrix<T, Prop, ArrayColComplexSparse, Alloc>::ReallocateImagColumn(int i,int j)
01004 {
01005 this->val_imag_(i).Reallocate(j);
01006 }
01007
01008
01010
01014 template <class T, class Prop, class Allocator> inline
01015 void Matrix<T, Prop, ArrayColComplexSparse, Allocator>::ResizeRealColumn(int i,int j)
01016 {
01017 this->val_real_(i).Resize(j);
01018 }
01019
01020
01022
01026 template <class T, class Prop, class Allocator> inline
01027 void Matrix<T, Prop, ArrayColComplexSparse, Allocator>::ResizeImagColumn(int i,int j)
01028 {
01029 this->val_imag_(i).Resize(j);
01030 }
01031
01032
01034
01038 template <class T, class Prop, class Allocator> inline
01039 void Matrix<T, Prop, ArrayColComplexSparse, Allocator>::SwapRealColumn(int i,int j)
01040 {
01041 Swap(this->val_real_(i), this->val_real_(j));
01042 }
01043
01044
01046
01050 template <class T, class Prop, class Allocator> inline
01051 void Matrix<T, Prop, ArrayColComplexSparse, Allocator>::SwapImagColumn(int i,int j)
01052 {
01053 Swap(this->val_imag_(i), this->val_imag_(j));
01054 }
01055
01056
01058
01062 template <class T, class Prop, class Allocator>
01063 inline void Matrix<T, Prop, ArrayColComplexSparse, Allocator>::
01064 ReplaceRealIndexColumn(int i, IVect& new_index)
01065 {
01066 for (int j = 0; j < this->val_real_(i).GetM(); j++)
01067 this->val_real_(i).Index(j) = new_index(j);
01068 }
01069
01070
01072
01076 template <class T, class Prop, class Allocator>
01077 inline void Matrix<T, Prop, ArrayColComplexSparse, Allocator>::
01078 ReplaceImagIndexColumn(int i, IVect& new_index)
01079 {
01080 for (int j = 0; j < this->val_imag_(i).GetM(); j++)
01081 this->val_imag_(i).Index(j) = new_index(j);
01082 }
01083
01084
01086
01090 template <class T, class Prop, class Allocator>
01091 inline int Matrix<T, Prop, ArrayColComplexSparse, Allocator>::
01092 GetRealColumnSize(int i) const
01093 {
01094 return this->val_real_(i).GetSize();
01095 }
01096
01097
01099
01103 template <class T, class Prop, class Allocator>
01104 inline int Matrix<T, Prop, ArrayColComplexSparse, Allocator>::
01105 GetImagColumnSize(int i) const
01106 {
01107 return this->val_imag_(i).GetSize();
01108 }
01109
01110
01112 template <class T, class Prop, class Allocator> inline
01113 void Matrix<T, Prop, ArrayColComplexSparse, Allocator>::PrintRealColumn(int i) const
01114 {
01115 this->val_real_(i).Print();
01116 }
01117
01118
01120 template <class T, class Prop, class Allocator> inline
01121 void Matrix<T, Prop, ArrayColComplexSparse, Allocator>::PrintImagColumn(int i) const
01122 {
01123 this->val_imag_(i).Print();
01124 }
01125
01126
01128
01133 template <class T, class Prop, class Allocator> inline
01134 void Matrix<T, Prop, ArrayColComplexSparse, Allocator>::AssembleRealColumn(int i)
01135 {
01136 this->val_real_(i).Assemble();
01137 }
01138
01139
01141
01146 template <class T, class Prop, class Allocator> inline
01147 void Matrix<T, Prop, ArrayColComplexSparse, Allocator>::AssembleImagColumn(int i)
01148 {
01149 this->val_imag_(i).Assemble();
01150 }
01151
01152
01154
01159 template <class T, class Prop, class Allocator>
01160 inline void Matrix<T, Prop, ArrayColComplexSparse, Allocator>::
01161 AddInteraction(int i, int j, const complex<T>& val)
01162 {
01163 if (real(val) != T(0))
01164 this->val_real_(j).AddInteraction(i, real(val));
01165
01166 if (imag(val) != T(0))
01167 this->val_imag_(j).AddInteraction(i, imag(val));
01168 }
01169
01170
01172
01178 template <class T, class Prop, class Allocator> template <class Alloc1>
01179 inline void Matrix<T, Prop, ArrayColComplexSparse, Allocator>::
01180 AddInteractionRow(int i, int nb, const IVect& col,
01181 const Vector<complex<T>, VectFull, Alloc1>& val)
01182 {
01183 for (int j = 0; j < nb; j++)
01184 AddInteraction(i, col(j), val(j));
01185 }
01186
01187
01189
01195 template <class T, class Prop, class Allocator> template <class Alloc1>
01196 inline void Matrix<T, Prop, ArrayColComplexSparse, Allocator>::
01197 AddInteractionColumn(int i, int nb, const IVect& row,
01198 const Vector<complex<T>, VectFull, Alloc1>& val)
01199 {
01200 int nb_real = 0;
01201 int nb_imag = 0;
01202 IVect row_real(nb), row_imag(nb);
01203 Vector<T> val_real(nb), val_imag(nb);
01204 for (int j = 0; j < nb; j++)
01205 {
01206 if (real(val(j)) != T(0))
01207 {
01208 row_real(nb_real) = row(j);
01209 val_real(nb_real) = real(val(j));
01210 nb_real++;
01211 }
01212
01213 if (imag(val(j)) != T(0))
01214 {
01215 row_imag(nb_imag) = row(j);
01216 val_imag(nb_imag) = imag(val(j));
01217 nb_imag++;
01218 }
01219 }
01220
01221 this->val_real_(i).AddInteractionRow(nb_real, row_real, val_real);
01222 this->val_imag_(i).AddInteractionRow(nb_imag, row_imag, val_imag);
01223 }
01224
01225
01227
01229
01230
01232
01235 template <class T, class Prop, class Allocator>
01236 inline Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::Matrix() throw():
01237 Matrix_ArrayComplexSparse<T, Prop, ArrayRowComplexSparse, Allocator>()
01238 {
01239 }
01240
01241
01243
01248 template <class T, class Prop, class Allocator>
01249 inline Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::Matrix(int i, int j):
01250 Matrix_ArrayComplexSparse<T, Prop, ArrayRowComplexSparse, Allocator>(i, j)
01251 {
01252 }
01253
01254
01256 template <class T, class Prop, class Allocator>
01257 inline void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::ClearRealRow(int i)
01258 {
01259 this->val_real_(i).Clear();
01260 }
01261
01262
01264 template <class T, class Prop, class Allocator>
01265 inline void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::ClearImagRow(int i)
01266 {
01267 this->val_imag_(i).Clear();
01268 }
01269
01270
01272
01277 template <class T, class Prop, class Allocator>
01278 inline void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::
01279 ReallocateRealRow(int i, int j)
01280 {
01281 this->val_real_(i).Reallocate(j);
01282 }
01283
01284
01286
01291 template <class T, class Prop, class Allocator>
01292 inline void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::
01293 ReallocateImagRow(int i, int j)
01294 {
01295 this->val_imag_(i).Reallocate(j);
01296 }
01297
01298
01300
01305 template <class T, class Prop, class Allocator> inline
01306 void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::ResizeRealRow(int i, int j)
01307 {
01308 this->val_real_(i).Resize(j);
01309 }
01310
01311
01313
01318 template <class T, class Prop, class Allocator> inline
01319 void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::ResizeImagRow(int i, int j)
01320 {
01321 this->val_imag_(i).Resize(j);
01322 }
01323
01324
01326
01330 template <class T, class Prop, class Allocator>
01331 inline void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::SwapRealRow(int i,int j)
01332 {
01333 Swap(this->val_real_(i), this->val_real_(j));
01334 }
01335
01336
01338
01342 template <class T, class Prop, class Allocator>
01343 inline void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::SwapImagRow(int i,int j)
01344 {
01345 Swap(this->val_imag_(i), this->val_imag_(j));
01346 }
01347
01348
01350
01354 template <class T, class Prop, class Allocator>
01355 inline void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::
01356 ReplaceRealIndexRow(int i, IVect& new_index)
01357 {
01358 for (int j = 0; j < this->val_real_(i).GetM(); j++)
01359 this->val_real_(i).Index(j) = new_index(j);
01360 }
01361
01362
01364
01368 template <class T, class Prop, class Allocator>
01369 inline void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::
01370 ReplaceImagIndexRow(int i, IVect& new_index)
01371 {
01372 for (int j = 0; j < this->val_imag_(i).GetM(); j++)
01373 this->val_imag_(i).Index(j) = new_index(j);
01374 }
01375
01376
01378
01382 template <class T, class Prop, class Allocator> inline
01383 int Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::GetRealRowSize(int i) const
01384 {
01385 return this->val_real_(i).GetSize();
01386 }
01387
01388
01390
01394 template <class T, class Prop, class Allocator> inline
01395 int Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::GetImagRowSize(int i) const
01396 {
01397 return this->val_imag_(i).GetSize();
01398 }
01399
01400
01402 template <class T, class Prop, class Allocator> inline
01403 void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::PrintRealRow(int i) const
01404 {
01405 this->val_real_(i).Print();
01406 }
01407
01408
01410 template <class T, class Prop, class Allocator> inline
01411 void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::PrintImagRow(int i) const
01412 {
01413 this->val_imag_(i).Print();
01414 }
01415
01416
01418
01423 template <class T, class Prop, class Allocator>
01424 inline void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::AssembleRealRow(int i)
01425 {
01426 this->val_real_(i).Assemble();
01427 }
01428
01429
01431
01436 template <class T, class Prop, class Allocator>
01437 inline void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::AssembleImagRow(int i)
01438 {
01439 this->val_imag_(i).Assemble();
01440 }
01441
01442
01444
01449 template <class T, class Prop, class Allocator>
01450 inline void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::
01451 AddInteraction(int i, int j, const complex<T>& val)
01452 {
01453 if (real(val) != T(0))
01454 this->val_real_(i).AddInteraction(j, real(val));
01455
01456 if (imag(val) != T(0))
01457 this->val_imag_(i).AddInteraction(j, imag(val));
01458 }
01459
01460
01462
01468 template <class T, class Prop, class Allocator> template <class Alloc1>
01469 inline void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::
01470 AddInteractionRow(int i, int nb, const IVect& col,
01471 const Vector<complex<T>, VectFull, Alloc1>& val)
01472 {
01473 if (nb <= 0)
01474 return;
01475
01476 int nb_real = 0;
01477 int nb_imag = 0;
01478 IVect col_real(nb), col_imag(nb);
01479 Vector<T> val_real(nb), val_imag(nb);
01480 for (int j = 0; j < nb; j++)
01481 {
01482 if (real(val(j)) != T(0))
01483 {
01484 col_real(nb_real) = col(j);
01485 val_real(nb_real) = real(val(j));
01486 nb_real++;
01487 }
01488
01489 if (imag(val(j)) != T(0))
01490 {
01491 col_imag(nb_imag) = col(j);
01492 val_imag(nb_imag) = imag(val(j));
01493 nb_imag++;
01494 }
01495 }
01496
01497 this->val_real_(i).AddInteractionRow(nb_real, col_real, val_real);
01498 this->val_imag_(i).AddInteractionRow(nb_imag, col_imag, val_imag);
01499 }
01500
01501
01503
01509 template <class T, class Prop, class Allocator> template <class Alloc1>
01510 inline void Matrix<T, Prop, ArrayRowComplexSparse, Allocator>::
01511 AddInteractionColumn(int i, int nb, const IVect& row,
01512 const Vector<complex<T>, VectFull, Alloc1>& val)
01513 {
01514 for (int j = 0; j < nb; j++)
01515 AddInteraction(row(j), i, val(j));
01516 }
01517
01518
01520
01522
01523
01525
01528 template <class T, class Prop, class Allocator>
01529 inline Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::Matrix() throw():
01530 Matrix_ArrayComplexSparse<T, Prop, ArrayColSymComplexSparse, Allocator>()
01531 {
01532 }
01533
01534
01536
01541 template <class T, class Prop, class Allocator>
01542 inline Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::Matrix(int i, int j):
01543 Matrix_ArrayComplexSparse<T, Prop, ArrayColSymComplexSparse, Allocator>(i, j)
01544 {
01545 }
01546
01547
01548
01549
01550
01551
01552
01554
01560 template <class T, class Prop, class Allocator>
01561 inline complex<T>
01562 Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::operator() (int i, int j)
01563 const
01564 {
01565
01566 #ifdef SELDON_CHECK_BOUNDS
01567 if (i < 0 || i >= this->m_)
01568 throw WrongRow("Matrix::operator()", "Index should be in [0, "
01569 + to_str(this->m_-1) + "], but is equal to "
01570 + to_str(i) + ".");
01571 if (j < 0 || j >= this->n_)
01572 throw WrongCol("Matrix::operator()", "Index should be in [0, "
01573 + to_str(this->n_-1) + "], but is equal to "
01574 + to_str(j) + ".");
01575 #endif
01576
01577 if (i <= j)
01578 return complex<T>(this->val_real_(j)(i), this->val_imag_(j)(i));
01579
01580 return complex<T>(this->val_real_(i)(j), this->val_imag_(i)(j));
01581 }
01582
01583
01585 template <class T, class Prop, class Allocator> inline
01586 void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::ClearRealColumn(int i)
01587 {
01588 this->val_real_(i).Clear();
01589 }
01590
01591
01593 template <class T, class Prop, class Allocator> inline
01594 void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::ClearImagColumn(int i)
01595 {
01596 this->val_imag_(i).Clear();
01597 }
01598
01599
01601
01606 template <class T, class Prop, class Allocator>
01607 inline void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01608 ReallocateRealColumn(int i, int j)
01609 {
01610 this->val_real_(i).Reallocate(j);
01611 }
01612
01613
01615
01620 template <class T, class Prop, class Allocator>
01621 inline void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01622 ReallocateImagColumn(int i, int j)
01623 {
01624 this->val_imag_(i).Reallocate(j);
01625 }
01626
01627
01629
01633 template <class T, class Prop, class Allocator>
01634 inline void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01635 ResizeRealColumn(int i, int j)
01636 {
01637 this->val_real_(i).Resize(j);
01638 }
01639
01640
01642
01646 template <class T, class Prop, class Allocator>
01647 inline void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01648 ResizeImagColumn(int i, int j)
01649 {
01650 this->val_imag_(i).Resize(j);
01651 }
01652
01653
01655
01659 template <class T, class Prop, class Allocator>
01660 inline void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01661 SwapRealColumn(int i, int j)
01662 {
01663 Swap(this->val_real_(i), this->val_real_(j));
01664 }
01665
01666
01668
01672 template <class T, class Prop, class Allocator>
01673 inline void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01674 SwapImagColumn(int i, int j)
01675 {
01676 Swap(this->val_imag_(i), this->val_imag_(j));
01677 }
01678
01679
01681
01685 template <class T, class Prop, class Allocator>
01686 inline void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01687 ReplaceRealIndexColumn(int i, IVect& new_index)
01688 {
01689 for (int j = 0; j < this->val_real_(i).GetM(); j++)
01690 this->val_real_(i).Index(j) = new_index(j);
01691 }
01692
01693
01695
01699 template <class T, class Prop, class Allocator>
01700 inline void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01701 ReplaceImagIndexColumn(int i, IVect& new_index)
01702 {
01703 for (int j = 0; j < this->val_imag_(i).GetM(); j++)
01704 this->val_imag_(i).Index(j) = new_index(j);
01705 }
01706
01707
01709
01713 template <class T, class Prop, class Allocator>
01714 inline int Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01715 GetRealColumnSize(int i) const
01716 {
01717 return this->val_real_(i).GetSize();
01718 }
01719
01720
01722
01726 template <class T, class Prop, class Allocator>
01727 inline int Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01728 GetImagColumnSize(int i) const
01729 {
01730 return this->val_imag_(i).GetSize();
01731 }
01732
01733
01735 template <class T, class Prop, class Allocator>
01736 inline void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01737 PrintRealColumn(int i) const
01738 {
01739 this->val_real_(i).Print();
01740 }
01741
01742
01744 template <class T, class Prop, class Allocator>
01745 inline void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01746 PrintImagColumn(int i) const
01747 {
01748 this->val_imag_(i).Print();
01749 }
01750
01751
01753
01758 template <class T, class Prop, class Allocator>
01759 inline void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01760 AssembleRealColumn(int i)
01761 {
01762 this->val_real_(i).Assemble();
01763 }
01764
01765
01767
01772 template <class T, class Prop, class Allocator>
01773 inline void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01774 AssembleImagColumn(int i)
01775 {
01776 this->val_imag_(i).Assemble();
01777 }
01778
01779
01781
01786 template <class T, class Prop, class Allocator>
01787 inline void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01788 AddInteraction(int i, int j, const complex<T>& val)
01789 {
01790 if (i <= j)
01791 {
01792 if (real(val) != T(0))
01793 this->val_real_(j).AddInteraction(i, real(val));
01794
01795 if (imag(val) != T(0))
01796 this->val_imag_(j).AddInteraction(i, imag(val));
01797 }
01798 }
01799
01800
01802
01808 template <class T, class Prop, class Allocator> template <class Alloc1>
01809 inline void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01810 AddInteractionRow(int i, int nb, const IVect& col,
01811 const Vector<complex<T>, VectFull, Alloc1>& val)
01812 {
01813 AddInteractionColumn(i, nb, col, val);
01814 }
01815
01816
01818
01824 template <class T, class Prop, class Allocator> template <class Alloc1>
01825 inline void Matrix<T, Prop, ArrayColSymComplexSparse, Allocator>::
01826 AddInteractionColumn(int i, int nb, const IVect& row,
01827 const Vector<complex<T>, VectFull, Alloc1>& val)
01828 {
01829 int nb_real = 0;
01830 int nb_imag = 0;
01831 IVect row_real(nb), row_imag(nb);
01832 Vector<T> val_real(nb), val_imag(nb);
01833 for (int j = 0; j < nb; j++)
01834 if (row(j) <= i)
01835 {
01836 if (real(val(j)) != T(0))
01837 {
01838 row_real(nb_real) = row(j);
01839 val_real(nb_real) = real(val(j));
01840 nb_real++;
01841 }
01842
01843 if (imag(val(j)) != T(0))
01844 {
01845 row_imag(nb_imag) = row(j);
01846 val_imag(nb_imag) = imag(val(j));
01847 nb_imag++;
01848 }
01849 }
01850
01851 this->val_real_(i).AddInteractionRow(nb_real, row_real, val_real);
01852 this->val_imag_(i).AddInteractionRow(nb_imag, row_imag, val_imag);
01853 }
01854
01855
01857
01859
01860
01862
01865 template <class T, class Prop, class Allocator>
01866 inline Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::Matrix() throw():
01867 Matrix_ArrayComplexSparse<T, Prop, ArrayRowSymComplexSparse, Allocator>()
01868 {
01869 }
01870
01871
01873
01878 template <class T, class Prop, class Allocator>
01879 inline Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::Matrix(int i, int j):
01880 Matrix_ArrayComplexSparse<T, Prop, ArrayRowSymComplexSparse, Allocator>(i, j)
01881 {
01882 }
01883
01884
01885
01886
01887
01888
01889
01891
01897 template <class T, class Prop, class Allocator>
01898 inline complex<T>
01899 Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::operator() (int i, int j)
01900 const
01901 {
01902
01903 #ifdef SELDON_CHECK_BOUNDS
01904 if (i < 0 || i >= this->m_)
01905 throw WrongRow("Matrix_ArraySparse::operator()", "Index should be in [0, "
01906 + to_str(this->m_-1) + "], but is equal to "
01907 + to_str(i) + ".");
01908 if (j < 0 || j >= this->n_)
01909 throw WrongCol("Matrix_ArraySparse::operator()", "Index should be in [0, "
01910 + to_str(this->n_-1) + "], but is equal to "
01911 + to_str(j) + ".");
01912 #endif
01913
01914 if (i <= j)
01915 return complex<T>(this->val_real_(i)(j), this->val_imag_(i)(j));
01916
01917 return complex<T>(this->val_real_(j)(i), this->val_imag_(j)(i));
01918 }
01919
01920
01922 template <class T, class Prop, class Allocator>
01923 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::ClearRealRow(int i)
01924 {
01925 this->val_real_(i).Clear();
01926 }
01927
01928
01930 template <class T, class Prop, class Allocator>
01931 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::ClearImagRow(int i)
01932 {
01933 this->val_imag_(i).Clear();
01934 }
01935
01936
01938
01943 template <class T, class Prop, class Allocator>
01944 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::
01945 ReallocateRealRow(int i,int j)
01946 {
01947 this->val_real_(i).Reallocate(j);
01948 }
01949
01950
01952
01957 template <class T, class Prop, class Allocator>
01958 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::
01959 ReallocateImagRow(int i,int j)
01960 {
01961 this->val_imag_(i).Reallocate(j);
01962 }
01963
01964
01966
01970 template <class T, class Prop, class Allocator>
01971 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::
01972 ResizeRealRow(int i,int j)
01973 {
01974 this->val_real_(i).Resize(j);
01975 }
01976
01977
01979
01983 template <class T, class Prop, class Allocator>
01984 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::
01985 ResizeImagRow(int i,int j)
01986 {
01987 this->val_imag_(i).Resize(j);
01988 }
01989
01990
01992
01996 template <class T, class Prop, class Allocator>
01997 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::
01998 SwapRealRow(int i,int j)
01999 {
02000 Swap(this->val_real_(i), this->val_real_(j));
02001 }
02002
02003
02005
02009 template <class T, class Prop, class Allocator>
02010 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::
02011 SwapImagRow(int i,int j)
02012 {
02013 Swap(this->val_imag_(i), this->val_imag_(j));
02014 }
02015
02016
02018
02022 template <class T, class Prop, class Allocator>
02023 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::
02024 ReplaceRealIndexRow(int i, IVect& new_index)
02025 {
02026 for (int j = 0; j < this->val_real_(i).GetM(); j++)
02027 this->val_real_(i).Index(j) = new_index(j);
02028 }
02029
02030
02032
02036 template <class T, class Prop, class Allocator>
02037 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::
02038 ReplaceImagIndexRow(int i,IVect& new_index)
02039 {
02040 for (int j = 0; j < this->val_imag_(i).GetM(); j++)
02041 this->val_imag_(i).Index(j) = new_index(j);
02042 }
02043
02044
02046
02050 template <class T, class Prop, class Allocator>
02051 inline int Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::GetRealRowSize(int i)
02052 const
02053 {
02054 return this->val_real_(i).GetSize();
02055 }
02056
02057
02059
02063 template <class T, class Prop, class Allocator>
02064 inline int Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::GetImagRowSize(int i)
02065 const
02066 {
02067 return this->val_imag_(i).GetSize();
02068 }
02069
02070
02072 template <class T, class Prop, class Allocator>
02073 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::PrintRealRow(int i)
02074 const
02075 {
02076 this->val_real_(i).Print();
02077 }
02078
02079
02081 template <class T, class Prop, class Allocator>
02082 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::PrintImagRow(int i)
02083 const
02084 {
02085 this->val_imag_(i).Print();
02086 }
02087
02088
02090
02095 template <class T, class Prop, class Allocator>
02096 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::AssembleRealRow(int i)
02097 {
02098 this->val_real_(i).Assemble();
02099 }
02100
02101
02103
02108 template <class T, class Prop, class Allocator>
02109 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::AssembleImagRow(int i)
02110 {
02111 this->val_imag_(i).Assemble();
02112 }
02113
02114
02116
02121 template <class T, class Prop, class Allocator>
02122 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::
02123 AddInteraction(int i, int j, const complex<T>& val)
02124 {
02125 if (i <= j)
02126 {
02127 if (real(val) != T(0))
02128 this->val_real_(i).AddInteraction(j, real(val));
02129
02130 if (imag(val) != T(0))
02131 this->val_imag_(i).AddInteraction(j, imag(val));
02132 }
02133 }
02134
02135
02137
02143 template <class T, class Prop, class Allocator> template <class Alloc1>
02144 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::
02145 AddInteractionRow(int i, int nb, const IVect& col,
02146 const Vector<complex<T>, VectFull, Alloc1>& val)
02147 {
02148 int nb_real = 0;
02149 int nb_imag = 0;
02150 IVect col_real(nb), col_imag(nb);
02151 Vector<T> val_real(nb), val_imag(nb);
02152 for (int j = 0; j < nb; j++)
02153 if (i <= col(j))
02154 {
02155 if (real(val(j)) != T(0))
02156 {
02157 col_real(nb_real) = col(j);
02158 val_real(nb_real) = real(val(j));
02159 nb_real++;
02160 }
02161
02162 if (imag(val(j)) != T(0))
02163 {
02164 col_imag(nb_imag) = col(j);
02165 val_imag(nb_imag) = imag(val(j));
02166 nb_imag++;
02167 }
02168 }
02169
02170 this->val_real_(i).AddInteractionRow(nb_real, col_real, val_real);
02171 this->val_imag_(i).AddInteractionRow(nb_imag, col_imag, val_imag);
02172 }
02173
02174
02176
02182 template <class T, class Prop, class Allocator> template <class Alloc1>
02183 inline void Matrix<T, Prop, ArrayRowSymComplexSparse, Allocator>::
02184 AddInteractionColumn(int i, int nb, const IVect& row,
02185 const Vector<complex<T>,VectFull,Alloc1>& val)
02186 {
02187
02188 AddInteractionRow(i, nb, row, val);
02189 }
02190
02191 }
02192
02193 #define SELDON_FILE_MATRIX_ARRAY_COMPLEX_SPARSE_CXX
02194 #endif