Matrix_ArrayComplexSparse.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_CXX
22 
23 #include "Matrix_ArrayComplexSparse.hxx"
24 
25 namespace Seldon
26 {
27 
28 
30 
33  template <class T, class Prop, class Storage, class Allocator>
36  {
37  long nnz = 0;
38  for (int i = 0; i < this->val_real_.GetM(); i++)
39  nnz += this->val_real_(i).GetM();
40 
41  return nnz;
42  }
43 
44 
46 
49  template <class T, class Prop, class Storage, class Allocator>
52  {
53  int nnz = 0;
54  for (int i = 0; i < this->val_imag_.GetM(); i++)
55  nnz += this->val_imag_(i).GetM();
56 
57  return nnz;
58  }
59 
60 
62  template<class T, class Prop, class Storage, class Allocator>
65  {
66  size_t taille = sizeof(*this) + sizeof(pointer)*this->val_real_.GetM();
67  taille += sizeof(pointer)*this->val_imag_.GetM();
68  for (int i = 0; i < val_real_.GetM(); i++)
69  taille += val_real_(i).GetMemorySize();
70 
71  for (int i = 0; i < val_imag_.GetM(); i++)
72  taille += val_imag_(i).GetMemorySize();
73 
74  return taille;
75  }
76 
77 
78  /*********************
79  * MEMORY MANAGEMENT *
80  *********************/
81 
82 
84 
90  template <class T, class Prop, class Storage, class Allocator>
92  Reallocate(int i, int j)
93  {
94  // Clears previous entries.
95  Clear();
96 
97  this->m_ = i;
98  this->n_ = j;
99 
100  int n = Storage::GetFirst(i,j);
101  val_real_.Reallocate(n);
102  val_imag_.Reallocate(n);
103  }
104 
105 
107 
113  template <class T, class Prop, class Storage, class Allocator>
115  Resize(int i, int j)
116  {
117  int n = Storage::GetFirst(this->m_, this->n_);
118  int new_n = Storage::GetFirst(i, j);
119  if (n != new_n)
120  {
123 
126 
127  new_val_real.Reallocate(new_n);
128  new_val_imag.Reallocate(new_n);
129 
130  for (int k = 0 ; k < min(n, new_n) ; k++)
131  {
132  Swap(new_val_real(k), this->val_real_(k));
133  Swap(new_val_imag(k), this->val_imag_(k));
134  }
135 
136  val_real_.SetData(new_n, new_val_real.GetData());
137  val_imag_.SetData(new_n, new_val_imag.GetData());
138  new_val_real.Nullify();
139  new_val_imag.Nullify();
140 
141  }
142 
143  this->m_ = i;
144  this->n_ = j;
145  }
146 
147 
148  /************************
149  * CONVENIENT FUNCTIONS *
150  ************************/
151 
152 
154 
159  template <class T, class Prop, class Storage, class Allocator>
160  void
162  ::Set(int i, int j, const entry_type& x)
163  {
164  if (real(x) != value_type(0))
165  val_real_(Storage::GetFirst(i, j)).Get(Storage::GetSecond(i, j)) = real(x);
166  else
167  {
168  if (val_real_(Storage::GetFirst(i, j))
169  (Storage::GetSecond(i, j)) != value_type(0))
170  val_real_(Storage::GetFirst(i, j)).
171  Get(Storage::GetSecond(i, j)) = value_type(0);
172  }
173 
174  if (imag(x) != value_type(0))
175  val_imag_(Storage::GetFirst(i, j)).
176  Get(Storage::GetSecond(i, j)) = imag(x);
177  else
178  {
179  if (val_imag_(Storage::GetFirst(i, j))
180  (Storage::GetSecond(i, j)) != value_type(0))
181  val_imag_(Storage::GetFirst(i, j)).
182  Get(Storage::GetSecond(i, j)) = value_type(0);
183  }
184 
185  }
186 
187 
189 
194  template <class T, class Prop, class Storage, class Allocator>
196  {
197  if (Storage::GetFirst(1, 0) == 1)
198  for (int i = 0; i < this->m_; i++)
199  {
200  for (int j = 0; j < this->val_real_(i).GetM(); j++)
201  cout << (i+1) << " " << this->val_real_(i).Index(j)+1
202  << " " << this->val_real_(i).Value(j) << endl;
203 
204  for (int j = 0; j < this->val_imag_(i).GetM(); j++)
205  cout << (i+1) << " " << this->val_imag_(i).Index(j)+1
206  << " (0, " << this->val_imag_(i).Value(j) << ")"<<endl;
207  }
208  else
209  for (int i = 0; i < this->n_; i++)
210  {
211  for (int j = 0; j < this->val_real_(i).GetM(); j++)
212  cout << this->val_real_(i).Index(j)+1 << " " << i+1
213  << " " << this->val_real_(i).Value(j) << endl;
214 
215  for (int j = 0; j < this->val_imag_(i).GetM(); j++)
216  cout << this->val_imag_(i).Index(j)+1 << " " << i+1
217  << " (0, " << this->val_imag_(i).Value(j) << ")"<<endl;
218  }
219  }
220 
221 
223 
230  template <class T, class Prop, class Storage, class Allocator>
232  ::Write(string FileName) const
233  {
234  ofstream FileStream;
235  FileStream.open(FileName.c_str(), ofstream::binary);
236 
237 #ifdef SELDON_CHECK_IO
238  // Checks if the file was opened.
239  if (!FileStream.is_open())
240  throw IOError("Matrix_ArrayComplexSparse::Write(string FileName)",
241  string("Unable to open file \"") + FileName + "\".");
242 #endif
243 
244  this->Write(FileStream);
245 
246  FileStream.close();
247  }
248 
249 
251 
258  template <class T, class Prop, class Storage, class Allocator>
260  ::Write(ostream& FileStream) const
261  {
262 
263 #ifdef SELDON_CHECK_IO
264  // Checks if the stream is ready.
265  if (!FileStream.good())
266  throw IOError("Matrix_ArrayComplexSparse::Write(ofstream& FileStream)",
267  "Stream is not ready.");
268 #endif
269 
270  FileStream.write(reinterpret_cast<char*>(const_cast<int*>(&this->m_)),
271  sizeof(int));
272 
273  FileStream.write(reinterpret_cast<char*>(const_cast<int*>(&this->n_)),
274  sizeof(int));
275 
276  for (int i = 0; i < val_real_.GetM(); i++)
277  {
278  val_real_(i).Write(FileStream);
279  val_imag_(i).Write(FileStream);
280  }
281  }
282 
283 
285 
289  template <class T, class Prop, class Storage, class Allocator>
291  ::WriteText(string FileName, bool cplx) const
292  {
293  ofstream FileStream; FileStream.precision(14);
294  FileStream.open(FileName.c_str());
295 
296  // changing precision
297  FileStream.precision(cout.precision());
298 
299 #ifdef SELDON_CHECK_IO
300  // Checks if the file was opened.
301  if (!FileStream.is_open())
302  throw IOError("Matrix_ArrayComplexSparse::WriteText(string FileName)",
303  string("Unable to open file \"") + FileName + "\".");
304 #endif
305 
306  this->WriteText(FileStream, cplx);
307 
308  FileStream.close();
309  }
310 
311 
313 
317  template <class T, class Prop, class Storage, class Allocator>
319  ::WriteText(ostream& FileStream, bool cplx) const
320  {
321 
322 #ifdef SELDON_CHECK_IO
323  // Checks if the stream is ready.
324  if (!FileStream.good())
325  throw IOError("Matrix_ArrayComplexSparse::"
326  "WriteText(ofstream& FileStream)",
327  "Stream is not ready.");
328 #endif
329 
330  // Conversion to coordinate format (1-index convention).
331  const Matrix<T, Prop, Storage, Allocator>& leaf_class =
332  static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this);
333 
334  entry_type zero; int index = 1;
335  WriteCoordinateMatrix(leaf_class, FileStream, zero, index, cplx);
336  }
337 
338 
340 
344  template <class T, class Prop, class Storage, class Allocator>
346  ::Read(string FileName)
347  {
348  ifstream FileStream;
349  FileStream.open(FileName.c_str(), ifstream::binary);
350 
351 #ifdef SELDON_CHECK_IO
352  // Checks if the file was opened.
353  if (!FileStream.is_open())
354  throw IOError("Matrix_ArrayComplexSparse::Read(string FileName)",
355  string("Unable to open file \"") + FileName + "\".");
356 #endif
357 
358  this->Read(FileStream);
359 
360  FileStream.close();
361  }
362 
363 
365 
369  template <class T, class Prop, class Storage, class Allocator>
371  ::Read(istream& FileStream)
372  {
373 
374 #ifdef SELDON_CHECK_IO
375  // Checks if the stream is ready.
376  if (!FileStream.good())
377  throw IOError("Matrix_ArraySparse::Read(ofstream& FileStream)",
378  "Stream is not ready.");
379 #endif
380 
381  FileStream.read(reinterpret_cast<char*>(const_cast<int*>(&this->m_)),
382  sizeof(int));
383 
384  FileStream.read(reinterpret_cast<char*>(const_cast<int*>(&this->n_)),
385  sizeof(int));
386 
387  val_real_.Reallocate(Storage::GetFirst(this->m_, this->n_));
388  val_imag_.Reallocate(Storage::GetFirst(this->m_, this->n_));
389  for (int i = 0; i < val_real_.GetM(); i++)
390  {
391  val_real_(i).Read(FileStream);
392  val_imag_(i).Read(FileStream);
393  }
394 
395 #ifdef SELDON_CHECK_IO
396  // Checks if data was read.
397  if (!FileStream.good())
398  throw IOError("Matrix_ArraySparse::Read(istream& FileStream)",
399  string("Input operation failed.")
400  + string(" The input file may have been removed")
401  + " or may not contain enough data.");
402 #endif
403 
404  }
405 
406 
408 
412  template <class T, class Prop, class Storage, class Allocator>
414  ::ReadText(string FileName, bool cplx)
415  {
416  ifstream FileStream;
417  FileStream.open(FileName.c_str());
418 
419 #ifdef SELDON_CHECK_IO
420  // Checks if the file was opened.
421  if (!FileStream.is_open())
422  throw IOError("Matrix_ArraySparse::ReadText(string FileName)",
423  string("Unable to open file \"") + FileName + "\".");
424 #endif
425 
426  this->ReadText(FileStream, cplx);
427 
428  FileStream.close();
429  }
430 
431 
433 
437  template <class T, class Prop, class Storage, class Allocator>
439  ::ReadText(istream& FileStream, bool cplx)
440  {
442  static_cast<Matrix<T, Prop, Storage, Allocator>& >(*this);
443 
444  entry_type zero; int index = 1;
445  ReadCoordinateMatrix(leaf_class, FileStream, zero, index, -1, cplx);
446  }
447 
448 
450 
456  template <class T, class Prop, class Storage, class Allocator>
458  {
459  for (int i = 0; i < Storage::GetFirst(this->m_, this->n_); i++)
460  {
461  val_real_(i).Assemble();
462  val_imag_(i).Assemble();
463  }
464  }
465 
466 
468  template <class T, class Prop, class Storage, class Allocator> template<class T0>
470  ::RemoveSmallEntry(const T0& epsilon)
471  {
472  for (int i = 0; i < val_real_.GetM(); i++)
473  val_real_(i).RemoveSmallEntry(epsilon);
474 
475  for (int i = 0; i < val_imag_.GetM(); i++)
476  val_imag_(i).RemoveSmallEntry(epsilon);
477  }
478 
479 
481  template <class T, class Prop, class Storage, class Allocator>
484  {
485  this->n_ = this->m_;
486  for (int i = 0; i < this->m_; i++)
487  {
488  val_imag_(i).Clear();
489  val_real_(i).Reallocate(1);
490  val_real_(i).Index(0) = i;
491  val_real_(i).Value(0) = value_type(1);
492  }
493  }
494 
495 
497  template <class T, class Prop, class Storage, class Allocator>
499  {
500  for (int i = 0; i < Storage::GetFirst(this->m_, this->n_); i++)
501  {
502  val_real_(i).Zero();
503  val_imag_(i).Zero();
504  }
505  }
506 
507 
509  template <class T, class Prop, class Storage, class Allocator>
511  {
512  long value = 0;
513  for (int i = 0; i < Storage::GetFirst(this->m_, this->n_); i++)
514  {
515  for (int j = 0; j < val_real_(i).GetM(); j++)
516  SetComplexReal(value++, val_real_(i).Value(j));
517 
518  for (int j = 0; j < val_imag_(i).GetM(); j++)
519  SetComplexReal(value++, val_imag_(i).Value(j));
520  }
521  }
522 
523 
525 
529  template <class T, class Prop, class Storage, class Allo> template<class T0>
531  Fill(const complex<T0>& x)
532  {
533  for (int i = 0; i < Storage::GetFirst(this->m_, this->n_); i++)
534  {
535  val_real_(i).Fill(real(x));
536  val_imag_(i).Fill(imag(x));
537  }
538  }
539 
540 
542  template <class T, class Prop, class Storage, class Allocator>
543  template <class T0>
546  (const complex<T0>& x)
547  {
548  this->Fill(x);
549  }
550 
551 
553  template <class T, class Prop, class Storage, class Allocator>
555  {
556 #ifndef SELDON_WITHOUT_REINIT_RANDOM
557  srand(time(NULL));
558 #endif
559  for (int i = 0; i < Storage::GetFirst(this->m_, this->n_); i++)
560  {
561  val_real_(i).FillRand();
562  val_imag_(i).FillRand();
563  }
564  }
565 
566 
568  // MATRIX<ARRAY_COLCOMPLEXSPARSE> //
570 
571 
573 
579  template <class T, class Prop, class Allocator>
581  AddInteractionRow(int i, int nb, const IVect& col,
582  const Vector<entry_type>& val, bool sorted)
583  {
584  for (int j = 0; j < nb; j++)
585  AddInteraction(i, col(j), val(j));
586  }
587 
588 
590 
596  template <class T, class Prop, class Allocator>
598  AddInteractionColumn(int i, int nb, const IVect& row,
599  const Vector<entry_type>& val, bool sorted)
600  {
601  int nb_real = 0;
602  int nb_imag = 0;
603  IVect row_real(nb), row_imag(nb);
604  Vector<value_type> val_real(nb), val_imag(nb);
605  for (int j = 0; j < nb; j++)
606  {
607  if (real(val(j)) != value_type(0))
608  {
609  row_real(nb_real) = row(j);
610  val_real(nb_real) = real(val(j));
611  nb_real++;
612  }
613 
614  if (imag(val(j)) != value_type(0))
615  {
616  row_imag(nb_imag) = row(j);
617  val_imag(nb_imag) = imag(val(j));
618  nb_imag++;
619  }
620  }
621 
622  this->val_real_(i).AddInteractionRow(nb_real, row_real, val_real, sorted);
623  this->val_imag_(i).AddInteractionRow(nb_imag, row_imag, val_imag, sorted);
624  }
625 
626 
628  // MATRIX<ARRAY_ROWCOMPLEXSPARSE> //
630 
631 
633 
639  template <class T, class Prop, class Allocator>
641  AddInteractionRow(int i, int nb, const IVect& col,
642  const Vector<entry_type>& val, bool sorted)
643  {
644  if (nb <= 0)
645  return;
646 
647  int nb_real = 0;
648  int nb_imag = 0;
649  IVect col_real(nb), col_imag(nb);
650  Vector<value_type> val_real(nb), val_imag(nb);
651  for (int j = 0; j < nb; j++)
652  {
653  if (real(val(j)) != value_type(0))
654  {
655  col_real(nb_real) = col(j);
656  val_real(nb_real) = real(val(j));
657  nb_real++;
658  }
659 
660  if (imag(val(j)) != value_type(0))
661  {
662  col_imag(nb_imag) = col(j);
663  val_imag(nb_imag) = imag(val(j));
664  nb_imag++;
665  }
666  }
667 
668  this->val_real_(i).AddInteractionRow(nb_real, col_real, val_real, sorted);
669  this->val_imag_(i).AddInteractionRow(nb_imag, col_imag, val_imag, sorted);
670  }
671 
672 
674 
680  template <class T, class Prop, class Allocator>
682  AddInteractionColumn(int i, int nb, const IVect& row,
683  const Vector<entry_type>& val, bool sorted)
684  {
685  for (int j = 0; j < nb; j++)
686  AddInteraction(row(j), i, val(j));
687  }
688 
689 
691  // MATRIX<ARRAY_COLSYMCOMPLEXSPARSE> //
693 
694 
696 
701  template <class T, class Prop, class Allocator>
703  ::Set(int i, int j, const entry_type& x)
704  {
705  if (i <= j)
706  {
707  if (real(x) != value_type(0))
708  this->val_real_(j).Get(i) = real(x);
709  else
710  {
711  if (this->val_real_(j)(i) != value_type(0))
712  this->val_real_(j).Get(i) = value_type(0);
713  }
714 
715  if (imag(x) != value_type(0))
716  this->val_imag_(j).Get(i) = imag(x);
717  else
718  {
719  if (this->val_imag_(j)(i) != value_type(0))
720  this->val_imag_(j).Get(i) = value_type(0);
721  }
722  }
723  else
724  {
725  if (real(x) != value_type(0))
726  this->val_real_(i).Get(j) = real(x);
727  else
728  {
729  if (this->val_real_(i)(j) != value_type(0))
730  this->val_real_(i).Get(j) = value_type(0);
731  }
732 
733  if (imag(x) != value_type(0))
734  this->val_imag_(i).Get(j) = imag(x);
735  else
736  {
737  if (this->val_imag_(i)(j) != value_type(0))
738  this->val_imag_(i).Get(j) = value_type(0);
739  }
740  }
741  }
742 
743 
745 
750  template <class T, class Prop, class Allocator>
752  AddInteraction(int i, int j, const entry_type& val)
753  {
754  if (i <= j)
755  {
756  if (real(val) != value_type(0))
757  this->val_real_(j).AddInteraction(i, real(val));
758 
759  if (imag(val) != value_type(0))
760  this->val_imag_(j).AddInteraction(i, imag(val));
761  }
762  }
763 
764 
766 
772  template <class T, class Prop, class Allocator>
774  AddInteractionRow(int i, int nb, const IVect& col,
775  const Vector<entry_type>& val, bool sorted)
776  {
777  for (int j = 0; j < nb; j++)
778  AddInteraction(i, col(j), val(j));
779  }
780 
781 
783 
789  template <class T, class Prop, class Allocator>
791  AddInteractionColumn(int i, int nb, const IVect& row,
792  const Vector<entry_type>& val, bool sorted)
793  {
794  int nb_real = 0;
795  int nb_imag = 0;
796  IVect row_real(nb), row_imag(nb);
797  Vector<value_type> val_real(nb), val_imag(nb);
798  for (int j = 0; j < nb; j++)
799  if (row(j) <= i)
800  {
801  if (real(val(j)) != value_type(0))
802  {
803  row_real(nb_real) = row(j);
804  val_real(nb_real) = real(val(j));
805  nb_real++;
806  }
807 
808  if (imag(val(j)) != value_type(0))
809  {
810  row_imag(nb_imag) = row(j);
811  val_imag(nb_imag) = imag(val(j));
812  nb_imag++;
813  }
814  }
815 
816  this->val_real_(i).AddInteractionRow(nb_real, row_real, val_real, sorted);
817  this->val_imag_(i).AddInteractionRow(nb_imag, row_imag, val_imag, sorted);
818  }
819 
820 
822  // MATRIX<ARRAY_ROWSYMCOMPLEXSPARSE> //
824 
825 
827 
832  template <class T, class Prop, class Allocator>
834  ::Set(int i, int j, const entry_type& x)
835  {
836  if (i <= j)
837  {
838  if (real(x) != value_type(0))
839  this->val_real_(i).Get(j) = real(x);
840  else
841  {
842  if (this->val_real_(i)(j) != value_type(0))
843  this->val_real_(i).Get(j) = value_type(0);
844  }
845 
846  if (imag(x) != value_type(0))
847  this->val_imag_(i).Get(j) = imag(x);
848  else
849  {
850  if (this->val_imag_(i)(j) != value_type(0))
851  this->val_imag_(i).Get(j) = value_type(0);
852  }
853  }
854  else
855  {
856  if (real(x) != value_type(0))
857  this->val_real_(j).Get(i) = real(x);
858  else
859  {
860  if (this->val_real_(j)(i) != value_type(0))
861  this->val_real_(j).Get(i) = value_type(0);
862  }
863 
864  if (imag(x) != value_type(0))
865  this->val_imag_(j).Get(i) = imag(x);
866  else
867  {
868  if (this->val_imag_(j)(i) != value_type(0))
869  this->val_imag_(j).Get(i) = value_type(0);
870  }
871  }
872  }
873 
874 
876 
881  template <class T, class Prop, class Allocator>
883  AddInteraction(int i, int j, const entry_type& val)
884  {
885  if (i <= j)
886  {
887  if (real(val) != value_type(0))
888  this->val_real_(i).AddInteraction(j, real(val));
889 
890  if (imag(val) != value_type(0))
891  this->val_imag_(i).AddInteraction(j, imag(val));
892  }
893  }
894 
895 
897 
903  template <class T, class Prop, class Allocator>
905  AddInteractionRow(int i, int nb, const IVect& col,
906  const Vector<entry_type>& val, bool sorted)
907  {
908  int nb_real = 0;
909  int nb_imag = 0;
910  IVect col_real(nb), col_imag(nb);
911  Vector<value_type> val_real(nb), val_imag(nb);
912  for (int j = 0; j < nb; j++)
913  if (i <= col(j))
914  {
915  if (real(val(j)) != value_type(0))
916  {
917  col_real(nb_real) = col(j);
918  val_real(nb_real) = real(val(j));
919  nb_real++;
920  }
921 
922  if (imag(val(j)) != value_type(0))
923  {
924  col_imag(nb_imag) = col(j);
925  val_imag(nb_imag) = imag(val(j));
926  nb_imag++;
927  }
928  }
929 
930  this->val_real_(i).AddInteractionRow(nb_real, col_real, val_real, sorted);
931  this->val_imag_(i).AddInteractionRow(nb_imag, col_imag, val_imag, sorted);
932  }
933 
934 
936 
942  template <class T, class Prop, class Allocator>
944  AddInteractionColumn(int i, int nb, const IVect& row,
945  const Vector<entry_type>& val, bool sorted)
946  {
947  for (int j = 0; j < nb; j++)
948  AddInteraction(row(j), i, val(j));
949  }
950 
951 } // namespace Seldon
952 
953 #define SELDON_FILE_MATRIX_ARRAY_COMPLEX_SPARSE_CXX
954 #endif
Seldon::Matrix_ArrayComplexSparse::Resize
void Resize(int i, int j)
Reallocates additional memory to resize the matrix.
Definition: Matrix_ArrayComplexSparse.cxx:115
Seldon::Matrix_ArrayComplexSparse::WriteText
void WriteText(string FileName, bool cplx=false) const
Writes the matrix in a file.
Definition: Matrix_ArrayComplexSparse.cxx:291
Seldon::Matrix_ArrayComplexSparse
Sparse Array-matrix class.
Definition: Matrix_ArrayComplexSparse.hxx:176
Seldon::Matrix_ArrayComplexSparse::FillRand
void FillRand()
Non-zero entries take a random value.
Definition: Matrix_ArrayComplexSparse.cxx:554
Seldon::Vector
Definition: SeldonHeader.hxx:207
Seldon::Matrix_ArrayComplexSparse::Write
void Write(string FileName) const
Writes the matrix in a file.
Definition: Matrix_ArrayComplexSparse.cxx:232
Seldon::Matrix
Definition: SeldonHeader.hxx:226
Seldon::Matrix_ArrayComplexSparse::Read
void Read(string FileName)
Reads the matrix from a file.
Definition: Matrix_ArrayComplexSparse.cxx:346
Seldon::Matrix_ArrayComplexSparse::GetMemorySize
size_t GetMemorySize() const
returns size of matrix in bytes
Definition: Matrix_ArrayComplexSparse.cxx:64
Seldon::NewAlloc
Definition: Allocator.hxx:91
Seldon::Matrix_ArrayComplexSparse::Reallocate
void Reallocate(int i, int j)
Reallocates memory to resize the matrix.
Definition: Matrix_ArrayComplexSparse.cxx:92
Seldon::VectFull
Definition: StorageInline.cxx:74
Seldon::Matrix_ArrayComplexSparse::RemoveSmallEntry
void RemoveSmallEntry(const T0 &epsilon)
removes small entries
Definition: Matrix_ArrayComplexSparse.cxx:470
Seldon::Matrix_ArrayComplexSparse::Set
void Set(int i, int j, const entry_type &x)
Sets element (i, j) of matrix.
Definition: Matrix_ArrayComplexSparse.cxx:162
Seldon::Matrix_ArrayComplexSparse::Fill
void Fill()
Non-zero entries are filled with values 0, 1, 2, 3 ...
Definition: Matrix_ArrayComplexSparse.cxx:510
Seldon::Matrix_ArrayComplexSparse::SetIdentity
void SetIdentity()
Matrix is initialized to the identity matrix.
Definition: Matrix_ArrayComplexSparse.cxx:483
Seldon::Matrix_ArrayComplexSparse::Assemble
void Assemble()
Assembles the matrix.
Definition: Matrix_ArrayComplexSparse.cxx:457
Seldon::Matrix_ArrayComplexSparse::GetImagNonZeros
long GetImagNonZeros() const
Returns the number of non-zero elements (imaginary part).
Definition: Matrix_ArrayComplexSparse.cxx:51
Seldon::Matrix_ArrayComplexSparse::Print
void Print() const
Displays the matrix on the standard output.
Definition: Matrix_ArrayComplexSparse.cxx:195
Seldon::Matrix_ArrayComplexSparse::GetRealNonZeros
long GetRealNonZeros() const
Returns the number of non-zero elements (real part).
Definition: Matrix_ArrayComplexSparse.cxx:35
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::IOError
Definition: Errors.hxx:150
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::Matrix_ArrayComplexSparse::ReadText
void ReadText(string FileName, bool cplx=false)
Reads the matrix from a file.
Definition: Matrix_ArrayComplexSparse.cxx:414
Seldon::SetComplexReal
void SetComplexReal(int n, std::complex< T > &number)
Sets a complex number to (n, 0).
Definition: CommonInline.cxx:234
Seldon::Matrix_ArrayComplexSparse::Zero
void Zero()
Non-zero entries are set to 0 (but not removed).
Definition: Matrix_ArrayComplexSparse.cxx:498