Matrix_Pointers.cxx
1 // Copyright (C) 2001-2011 Vivien Mallet
2 // Copyright (C) 2003-2011 Marc DuruflĂ©
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_POINTERS_CXX
22 
23 #include "Matrix_Pointers.hxx"
24 
25 namespace Seldon
26 {
27 
28 
30 
34  template <class T, class Prop, class Storage, class Allocator>
36  ::Matrix_Pointers(int i, int j): Matrix_Base<T, Allocator>(i, j)
37  {
38 
39 #ifdef SELDON_CHECK_MEMORY
40  try
41  {
42 #endif
43 
44  me_ = reinterpret_cast<pointer*>( calloc(Storage::GetFirst(i, j),
45  sizeof(pointer)) );
46 
47 #ifdef SELDON_CHECK_MEMORY
48  }
49  catch (...)
50  {
51  this->m_ = 0;
52  this->n_ = 0;
53  me_ = NULL;
54  this->data_ = NULL;
55  }
56  if (me_ == NULL && i != 0 && j != 0)
57  throw NoMemory("Matrix_Pointers::Matrix_Pointers(int, int)",
58  string("Unable to allocate memory for a matrix of size ")
59  + to_str(static_cast<long int>(i)
60  * static_cast<long int>(j)
61  * static_cast<long int>(sizeof(T)))
62  + " bytes (" + to_str(i) + " x " + to_str(j)
63  + " elements).");
64 #endif
65 
66 #ifdef SELDON_CHECK_MEMORY
67  try
68  {
69 #endif
70 
71  this->data_ = Allocator::allocate(long(i) * long(j), this);
72 
73 #ifdef SELDON_CHECK_MEMORY
74  }
75  catch (...)
76  {
77  this->m_ = 0;
78  this->n_ = 0;
79  free(me_);
80  me_ = NULL;
81  this->data_ = NULL;
82  }
83  if (this->data_ == NULL && i != 0 && j != 0)
84  throw NoMemory("Matrix_Pointers::Matrix_Pointers(int, int)",
85  string("Unable to allocate memory for a matrix of size ")
86  + to_str(static_cast<long int>(i)
87  * static_cast<long int>(j)
88  * static_cast<long int>(sizeof(T)))
89  + " bytes (" + to_str(i) + " x " + to_str(j)
90  + " elements).");
91 #endif
92 
93  pointer ptr = this->data_;
94  long lgth = Storage::GetSecond(i, j);
95  for (int k = 0; k < Storage::GetFirst(i, j); k++, ptr += lgth)
96  me_[k] = ptr;
97 
98  }
99 
100 
102  template <class T, class Prop, class Storage, class Allocator>
105  Matrix_Base<T, Allocator>(A)
106  {
107  this->m_ = 0;
108  this->n_ = 0;
109  this->data_ = NULL;
110  this->me_ = NULL;
111 
112  this->Copy(A);
113  }
114 
115 
117 
121  template <class T, class Prop, class Storage, class Allocator>
123  {
124 #ifdef SELDON_CHECK_MEMORY
125  try
126  {
127 #endif
128 
129  if (this->data_ != NULL)
130  {
131  Allocator::deallocate(this->data_, long(this->m_) * long(this->n_));
132  this->data_ = NULL;
133  }
134 
135 #ifdef SELDON_CHECK_MEMORY
136  }
137  catch (...)
138  {
139  this->data_ = NULL;
140  }
141 #endif
142 
143 #ifdef SELDON_CHECK_MEMORY
144  try
145  {
146 #endif
147 
148  if (me_ != NULL)
149  {
150  free(me_);
151  me_ = NULL;
152  }
153 
154 #ifdef SELDON_CHECK_MEMORY
155  }
156  catch (...)
157  {
158  this->m_ = 0;
159  this->n_ = 0;
160  me_ = NULL;
161  }
162 #endif
163 
164  this->m_ = 0;
165  this->n_ = 0;
166  }
167 
168 
169  /*********************
170  * MEMORY MANAGEMENT *
171  *********************/
172 
173 
175 
181  template <class T, class Prop, class Storage, class Allocator>
183  ::Reallocate(int i, int j)
184  {
185 
186  if (i != this->m_ || j != this->n_)
187  {
188  this->m_ = i;
189  this->n_ = j;
190 
191 #ifdef SELDON_CHECK_MEMORY
192  try
193  {
194 #endif
195 
196  me_ = reinterpret_cast<pointer*>( realloc(me_,
197  Storage::GetFirst(i, j)
198  * sizeof(pointer)) );
199 
200 #ifdef SELDON_CHECK_MEMORY
201  }
202  catch (...)
203  {
204  this->m_ = 0;
205  this->n_ = 0;
206  me_ = NULL;
207  this->data_ = NULL;
208  }
209  if (me_ == NULL && i != 0 && j != 0)
210  throw NoMemory("Matrix_Pointers::Reallocate(int, int)",
211  string("Unable to reallocate memory for")
212  + " a matrix of size "
213  + to_str(static_cast<long int>(i)
214  * static_cast<long int>(j)
215  * static_cast<long int>(sizeof(T)))
216  + " bytes (" + to_str(i) + " x " + to_str(j)
217  + " elements).");
218 #endif
219 
220 #ifdef SELDON_CHECK_MEMORY
221  try
222  {
223 #endif
224  long taille = long(i)*long(j);
225  this->data_ =
226  reinterpret_cast<pointer>(Allocator::
227  reallocate(this->data_, taille,
228  this));
229 
230 #ifdef SELDON_CHECK_MEMORY
231  }
232  catch (...)
233  {
234  this->m_ = 0;
235  this->n_ = 0;
236  free(me_);
237  me_ = NULL;
238  this->data_ = NULL;
239  }
240  if (this->data_ == NULL && i != 0 && j != 0)
241  throw NoMemory("Matrix_Pointers::Reallocate(int, int)",
242  string("Unable to reallocate memory")
243  + " for a matrix of size "
244  + to_str(static_cast<long int>(i)
245  * static_cast<long int>(j)
246  * static_cast<long int>(sizeof(T)))
247  + " bytes (" + to_str(i) + " x " + to_str(j)
248  + " elements).");
249 #endif
250 
251  pointer ptr = this->data_;
252  long lgth = Storage::GetSecond(i, j);
253  for (int k = 0; k < Storage::GetFirst(i, j); k++, ptr += lgth)
254  me_[k] = ptr;
255  }
256  }
257 
258 
261 
275  template <class T, class Prop, class Storage, class Allocator>
277  ::SetData(int i, int j,
279  ::pointer data)
280  {
281  this->Clear();
282 
283  this->m_ = i;
284  this->n_ = j;
285 
286 #ifdef SELDON_CHECK_MEMORY
287  try
288  {
289 #endif
290 
291  me_ = reinterpret_cast<pointer*>( calloc(Storage::GetFirst(i, j),
292  sizeof(pointer)) );
293 
294 #ifdef SELDON_CHECK_MEMORY
295  }
296  catch (...)
297  {
298  this->m_ = 0;
299  this->n_ = 0;
300  me_ = NULL;
301  this->data_ = NULL;
302  return;
303  }
304  if (me_ == NULL)
305  {
306  this->m_ = 0;
307  this->n_ = 0;
308  this->data_ = NULL;
309  return;
310  }
311 #endif
312 
313  this->data_ = data;
314 
315  pointer ptr = this->data_;
316  long lgth = Storage::GetSecond(i, j);
317  for (int k = 0; k < Storage::GetFirst(i, j); k++, ptr += lgth)
318  me_[k] = ptr;
319  }
320 
321 
323 
328  template <class T, class Prop, class Storage, class Allocator>
330  {
331  this->m_ = 0;
332  this->n_ = 0;
333 
334 #ifdef SELDON_CHECK_MEMORY
335  try
336  {
337 #endif
338 
339  if (me_ != NULL)
340  {
341  free(me_);
342  me_ = NULL;
343  }
344 
345 #ifdef SELDON_CHECK_MEMORY
346  }
347  catch (...)
348  {
349  this->m_ = 0;
350  this->n_ = 0;
351  me_ = NULL;
352  }
353 #endif
354 
355  this->data_ = NULL;
356  }
357 
358 
360 
367  template <class T, class Prop, class Storage, class Allocator>
369  ::Resize(int i, int j)
370  {
371 
372  if (i == this->m_ && j == this->n_)
373  return;
374 
375  // Storing the old values of the matrix.
376  int iold = Storage::GetFirst(this->m_, this->n_);
377  int jold = Storage::GetSecond(this->m_, this->n_);
378  Vector<value_type, VectFull, Allocator> xold(this->GetDataSize());
379  for (long k = 0; k < this->GetDataSize(); k++)
380  xold(k) = this->data_[k];
381 
382  // Reallocation.
383  int inew = Storage::GetFirst(i, j);
384  int jnew = Storage::GetSecond(i, j);
385  this->Reallocate(i,j);
386 
387  // Filling the matrix with its old values.
388  int imin = min(iold, inew), jmin = min(jold, jnew);
389  for (int k = 0; k < imin; k++)
390  for (int l = 0; l < jmin; l++)
391  this->data_[k*jnew+l] = xold(l+jold*k);
392  }
393 
394 
395  /************************
396  * CONVENIENT FUNCTIONS *
397  ************************/
398 
399 
401 
405  template <class T, class Prop, class Storage, class Allocator>
407  {
408  Allocator::memoryset(this->data_, char(0),
409  this->GetDataSize() * sizeof(value_type));
410  }
411 
412 
414  template <class T, class Prop, class Storage, class Allocator>
416  {
417  T zero, one;
418  SetComplexZero(zero);
419  SetComplexOne(one);
420 
421  Fill(zero);
422 
423  for (int i = 0; i < min(this->m_, this->n_); i++)
424  (*this)(i,i) = one;
425  }
426 
427 
429 
433  template <class T, class Prop, class Storage, class Allocator>
435  {
436  for (long i = 0; i < this->GetDataSize(); i++)
437  SetComplexReal(i, this->data_[i]);
438  }
439 
440 
442 
445  template <class T, class Prop, class Storage, class Allocator>
446  template <class T0>
448  {
449  T x_; SetComplexReal(x, x_);
450  for (long i = 0; i < this->GetDataSize(); i++)
451  this->data_[i] = x_;
452  }
453 
455 
458  template <class T, class Prop, class Storage, class Allocator>
459  template <class T0>
462  {
463  this->Fill(x);
464 
465  return *this;
466  }
467 
468 
470 
473  template <class T, class Prop, class Storage, class Allocator>
475  {
476 #ifndef SELDON_WITHOUT_REINIT_RANDOM
477  srand(time(NULL));
478 #endif
479  for (long i = 0; i < this->GetDataSize(); i++)
480  SetComplexReal(rand(), this->data_[i]);
481  }
482 
483 
485 
490  template <class T, class Prop, class Storage, class Allocator>
492  {
493  for (int i = 0; i < this->m_; i++)
494  {
495  for (int j = 0; j < this->n_; j++)
496  cout << (*this)(i, j) << "\t";
497  cout << endl;
498  }
499  }
500 
501 
503 
514  template <class T, class Prop, class Storage, class Allocator>
516  int m, int n) const
517  {
518  for (int i = a; i < min(this->m_, a+m); i++)
519  {
520  for (int j = b; j < min(this->n_, b+n); j++)
521  cout << (*this)(i, j) << "\t";
522  cout << endl;
523  }
524  }
525 
526 
528 
536  template <class T, class Prop, class Storage, class Allocator>
538  {
539  Print(0, 0, l, l);
540  }
541 
542 
543  /**************************
544  * INPUT/OUTPUT FUNCTIONS *
545  **************************/
546 
547 #ifdef SELDON_WITH_HDF5
548 
556  template <class T, class Prop, class Storage, class Allocator>
558  ::WriteHDF5(string FileName, string group_name, string dataset_name) const
559  {
560  throw IOError("Matrix_Pointers::WriteHDF5(string FileName)",
561  string("Unable to write matrix in \"") + FileName + "\".");
562  }
563 #endif
564 
565 
567 
572  template <class T, class Prop, class Storage, class Allocator>
574  ::Append(string FileName) const
575  {
576  ofstream FileStream;
577  FileStream.open(FileName.c_str(), ofstream::binary | ios::app);
578 
579 #ifdef SELDON_CHECK_IO
580  // Checks if the file was opened.
581  if (!FileStream.is_open())
582  throw IOError("Matrix_Pointers::Write(string FileName)",
583  string("Unable to open file \"") + FileName + "\".");
584 #endif
585 
586  this->Write(FileStream, false);
587 
588  FileStream.close();
589  }
590 
591 
593 
602  template <class T, class Prop, class Storage, class Allocator>
604  ::Write(string FileName, bool with_size) const
605  {
606  ofstream FileStream;
607  FileStream.open(FileName.c_str(), ofstream::binary);
608 
609 #ifdef SELDON_CHECK_IO
610  // Checks if the file was opened.
611  if (!FileStream.is_open())
612  throw IOError("Matrix_Pointers::Write(string FileName)",
613  string("Unable to open file \"") + FileName + "\".");
614 #endif
615 
616  this->Write(FileStream, with_size);
617 
618  FileStream.close();
619  }
620 
621 
623 
632  template <class T, class Prop, class Storage, class Allocator>
634  ::Write(ostream& FileStream, bool with_size) const
635  {
636 
637 #ifdef SELDON_CHECK_IO
638  // Checks if the stream is ready.
639  if (!FileStream.good())
640  throw IOError("Matrix_Pointers::Write(ostream& FileStream)",
641  "The stream is not ready.");
642 #endif
643 
644  if (with_size)
645  {
646  FileStream.write(reinterpret_cast<char*>(const_cast<int*>(&this->m_)),
647  sizeof(int));
648  FileStream.write(reinterpret_cast<char*>(const_cast<int*>(&this->n_)),
649  sizeof(int));
650  }
651 
652  FileStream.write(reinterpret_cast<char*>(this->data_),
653  long(this->m_) * long(this->n_) * sizeof(value_type));
654 
655 #ifdef SELDON_CHECK_IO
656  // Checks if data was written.
657  if (!FileStream.good())
658  throw IOError("Matrix_Pointers::Write(ostream& FileStream)",
659  "Output operation failed.");
660 #endif
661 
662  }
663 
664 
666 
673  template <class T, class Prop, class Storage, class Allocator>
675  ::WriteText(string FileName) const
676  {
677  ofstream FileStream;
678  FileStream.precision(cout.precision());
679  FileStream.flags(cout.flags());
680  FileStream.open(FileName.c_str());
681 
682 #ifdef SELDON_CHECK_IO
683  // Checks if the file was opened.
684  if (!FileStream.is_open())
685  throw IOError("Matrix_Pointers::WriteText(string FileName)",
686  string("Unable to open file \"") + FileName + "\".");
687 #endif
688 
689  this->WriteText(FileStream);
690 
691  FileStream.close();
692  }
693 
694 
696 
703  template <class T, class Prop, class Storage, class Allocator>
705  ::WriteText(ostream& FileStream) const
706  {
707 
708 #ifdef SELDON_CHECK_IO
709  // Checks if the file is ready.
710  if (!FileStream.good())
711  throw IOError("Matrix_Pointers::WriteText(ostream& FileStream)",
712  "The stream is not ready.");
713 #endif
714 
715  int i, j;
716  for (i = 0; i < this->GetM(); i++)
717  {
718  for (j = 0; j < this->GetN(); j++)
719  FileStream << (*this)(i, j) << '\t';
720  FileStream << endl;
721  }
722 
723 #ifdef SELDON_CHECK_IO
724  // Checks if data was written.
725  if (!FileStream.good())
726  throw IOError("Matrix_Pointers::WriteText(ostream& FileStream)",
727  "Output operation failed.");
728 #endif
729 
730  }
731 
732 
734 
744  template <class T, class Prop, class Storage, class Allocator>
746  ::Read(string FileName, bool with_size)
747  {
748  ifstream FileStream;
749  FileStream.open(FileName.c_str(), ifstream::binary);
750 
751 #ifdef SELDON_CHECK_IO
752  // Checks if the file was opened.
753  if (!FileStream.is_open())
754  throw IOError("Matrix_Pointers::Read(string FileName)",
755  string("Unable to open file \"") + FileName + "\".");
756 #endif
757 
758  this->Read(FileStream, with_size);
759 
760  FileStream.close();
761  }
762 
763 
765 
775  template <class T, class Prop, class Storage, class Allocator>
777  ::Read(istream& FileStream, bool with_size)
778  {
779 
780 #ifdef SELDON_CHECK_IO
781  // Checks if the stream is ready.
782  if (!FileStream.good())
783  throw IOError("Matrix_Pointers::Read(istream& FileStream)",
784  "The stream is not ready.");
785 #endif
786 
787  if (with_size)
788  {
789  int new_m, new_n;
790  FileStream.read(reinterpret_cast<char*>(&new_m), sizeof(int));
791  FileStream.read(reinterpret_cast<char*>(&new_n), sizeof(int));
792  this->Reallocate(new_m, new_n);
793  }
794 
795  FileStream.read(reinterpret_cast<char*>(this->data_),
796  long(this->GetM()) * long(this->GetN())
797  * sizeof(value_type));
798 
799 #ifdef SELDON_CHECK_IO
800  // Checks if data was read.
801  if (!FileStream.good())
802  throw IOError("Matrix_Pointers::Read(istream& FileStream)",
803  "Input operation failed.");
804 #endif
805 
806  }
807 
808 
810 
814  template <class T, class Prop, class Storage, class Allocator>
816  {
817  ifstream FileStream;
818  FileStream.open(FileName.c_str());
819 
820 #ifdef SELDON_CHECK_IO
821  // Checks if the file was opened.
822  if (!FileStream.is_open())
823  throw IOError("Matrix_Pointers::ReadText(string FileName)",
824  string("Unable to open file \"") + FileName + "\".");
825 #endif
826 
827  this->ReadText(FileStream);
828 
829  FileStream.close();
830  }
831 
832 
834 
838  template <class T, class Prop, class Storage, class Allocator>
840  ::ReadText(istream& FileStream)
841  {
842  // Clears the matrix.
843  Clear();
844 
845 #ifdef SELDON_CHECK_IO
846  // Checks if the stream is ready.
847  if (!FileStream.good())
848  throw IOError("Matrix_Pointers::ReadText(istream& FileStream)",
849  "The stream is not ready.");
850 #endif
851 
852  // Reads the first line.
853  string line;
854  getline(FileStream, line);
855  if (FileStream.fail())
856  // Is the file empty?
857  return;
858 
859  // Converts the first line into a vector.
860  istringstream line_stream(line);
861  Vector<T> first_row;
862  first_row.ReadText(line_stream);
863 
864  // Now reads all other rows, and puts them in a single vector.
865  Vector<T> other_row;
866  other_row.ReadText(FileStream);
867 
868  // Number of rows and columns.
869  int n = first_row.GetM();
870  int m = 1 + other_row.GetM() / n;
871 
872 #ifdef SELDON_CHECK_IO
873  // Checks that enough elements were read.
874  if (other_row.GetM() != (m - 1) * n)
875  throw IOError("Matrix_Pointers::ReadText(istream& FileStream)",
876  "Not all rows have the same number of columns.");
877 #endif
878 
879  this->Reallocate(m, n);
880  // Fills the matrix.
881  for (int j = 0; j < n; j++)
882  this->Val(0, j) = first_row(j);
883 
884  int k = 0;
885  for (int i = 1; i < m; i++)
886  for (int j = 0; j < n; j++)
887  this->Val(i, j) = other_row(k++);
888  }
889 
890 
892  // MATRIX<COLMAJOR> //
894 
895 
896  /*****************
897  * OTHER METHODS *
898  *****************/
899 
900 
902 
908  template <class T, class Prop, class Allocator>
910  ::WriteColumn(string FileName, int col) const
911  {
912  ofstream FileStream;
913  FileStream.open(FileName.c_str());
914 
915 #ifdef SELDON_CHECK_IO
916  // Checks if the file was opened.
917  if (!FileStream.is_open())
918  throw IOError("Matrix::WriteColumn(string FileName)",
919  string("Unable to open file \"") + FileName + "\".");
920 #endif
921 
922  this->WriteColumn(FileStream, col);
923 
924  FileStream.close();
925  }
926 
927 
929 
935  template <class T, class Prop, class Allocator>
937  ::WriteColumn(ostream& FileStream, int col) const
938  {
939 #ifdef SELDON_CHECK_BOUNDS
940  if (col < 0 || col >= this->n_)
941  throw WrongCol("Matrix::WriteColumn(ostream& FileStream, int col)",
942  string("Index should be in [0, ")
943  + to_str(this->n_-1) + "], but is equal to "
944  + to_str(col) + ".");
945 #endif
946 
947 #ifdef SELDON_CHECK_IO
948  // Checks if the stream is ready.
949  if (!FileStream.good())
950  throw IOError("Matrix::WriteColumn(ostream& FileStream, int col)",
951  "The stream is not ready.");
952 #endif
953 
954  FileStream.write(reinterpret_cast<char*>(this->me_[col]),
955  this->m_ * sizeof(value_type));
956 
957 #ifdef SELDON_CHECK_IO
958  // Checks if data was written.
959  if (!FileStream.good())
960  throw IOError("Matrix::WriteColumn(ostream& FileStream, int col)",
961  "Output operation failed.");
962 #endif
963 
964  }
965 
966 
968  // MATRIX<ROWMAJOR> //
970 
971 
972  /*****************
973  * OTHER METHODS *
974  *****************/
975 
976 
978 
984  template <class T, class Prop, class Allocator>
986  ::WriteRow(string FileName, int row) const
987  {
988  ofstream FileStream;
989  FileStream.open(FileName.c_str());
990 
991 #ifdef SELDON_CHECK_IO
992  // Checks if the file was opened.
993  if (!FileStream.is_open())
994  throw IOError("Matrix::WriteRow(string FileName, int row)",
995  string("Unable to open file \"") + FileName + "\".");
996 #endif
997 
998  this->WriteRow(FileStream, row);
999 
1000  FileStream.close();
1001  }
1002 
1003 
1005 
1011  template <class T, class Prop, class Allocator>
1013  ::WriteRow(ostream& FileStream, int row) const
1014  {
1015 #ifdef SELDON_CHECK_BOUNDS
1016  if (row < 0 || row >= this->m_)
1017  throw WrongRow("Matrix::WriteRow(ostream& FileStream, int row)",
1018  string("Index should be in [0, ")
1019  + to_str(this->m_-1) + "], but is equal to "
1020  + to_str(row) + ".");
1021 #endif
1022 
1023 #ifdef SELDON_CHECK_IO
1024  // Checks if the stream is ready.
1025  if (!FileStream.good())
1026  throw IOError("Matrix::WriteRow(ostream& FileStream, int rowm)",
1027  "The stream is not ready.");
1028 #endif
1029 
1030  FileStream.write(reinterpret_cast<char*>(this->me_[row]),
1031  this->n_ * sizeof(value_type));
1032 
1033 #ifdef SELDON_CHECK_IO
1034  // Checks if data was written.
1035  if (!FileStream.good())
1036  throw IOError("Matrix::WriteRow(ostream& FileStream, int row)",
1037  "Output operation failed.");
1038 #endif
1039 
1040  }
1041 
1042 
1043 } // namespace Seldon.
1044 
1045 #define SELDON_FILE_MATRIX_POINTERS_CXX
1046 #endif
Seldon::Matrix_Base
Base class for all matrices.
Definition: Matrix_Base.hxx:143
Seldon::Matrix_Pointers::Nullify
void Nullify()
Clears the matrix without releasing memory.
Definition: Matrix_Pointers.cxx:329
Seldon::Matrix_Pointers::Append
void Append(string FileName) const
Appends the matrix in a file.
Definition: Matrix_Pointers.cxx:574
Seldon::to_str
std::string to_str(const T &input)
Converts most types to string.
Definition: CommonInline.cxx:137
Seldon::WrongCol
Definition: Errors.hxx:138
Seldon::Matrix_Pointers
Full matrix class.
Definition: Matrix_Pointers.hxx:37
Seldon::Vector
Definition: SeldonHeader.hxx:207
Seldon::Matrix_Pointers::Reallocate
void Reallocate(int i, int j)
Reallocates memory to resize the matrix.
Definition: Matrix_Pointers.cxx:183
Seldon::Matrix_Pointers::WriteText
void WriteText(string FileName) const
Writes the matrix in a file.
Definition: Matrix_Pointers.cxx:675
Seldon::Matrix
Definition: SeldonHeader.hxx:226
Seldon::Matrix_Pointers::FillRand
void FillRand()
Fills the matrix randomly.
Definition: Matrix_Pointers.cxx:474
Seldon::WrongRow
Definition: Errors.hxx:126
Seldon::Matrix_Pointers::Clear
void Clear()
Clears the matrix.
Definition: Matrix_Pointers.cxx:122
Seldon::Matrix_Pointers::Zero
void Zero()
Sets all elements to zero.
Definition: Matrix_Pointers.cxx:406
Seldon::Matrix_Pointers::Read
void Read(string FileName, bool with_size=true)
Reads the matrix from a file.
Definition: Matrix_Pointers.cxx:746
Seldon::Matrix_Pointers::operator=
Matrix_Pointers< T, Prop, Storage, Allocator > & operator=(const Matrix_Pointers< T, Prop, Storage, Allocator > &A)
Duplicates a matrix (assignment operator).
Definition: Matrix_PointersInline.cxx:311
Seldon::Matrix_Pointers::Fill
void Fill()
Fills the matrix the matrix with 0, 1, 2, ...
Definition: Matrix_Pointers.cxx:434
Seldon::Matrix_Pointers::SetIdentity
void SetIdentity()
Sets the current matrix to the identity.
Definition: Matrix_Pointers.cxx:415
Seldon::Matrix_Pointers::Print
void Print() const
Displays the matrix on the standard output.
Definition: Matrix_Pointers.cxx:491
Seldon::Matrix_Pointers::ReadText
void ReadText(string FileName)
Reads the matrix from a file.
Definition: Matrix_Pointers.cxx:815
Seldon::Matrix_Pointers::SetData
void SetData(int i, int j, pointer data)
Changes the size of the matrix and sets its data array (low level method).
Definition: Matrix_Pointers.cxx:277
Seldon::Matrix_Pointers::Write
void Write(string FileName, bool with_size=true) const
Writes the matrix in a file.
Definition: Matrix_Pointers.cxx:604
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::IOError
Definition: Errors.hxx:150
Seldon::Matrix_Pointers::Resize
void Resize(int i, int j)
Reallocates memory to resize the matrix and keeps previous entries.
Definition: Matrix_Pointers.cxx:369
Seldon::NoMemory
Definition: Errors.hxx:90
Seldon::SetComplexReal
void SetComplexReal(int n, std::complex< T > &number)
Sets a complex number to (n, 0).
Definition: CommonInline.cxx:234
Seldon::Matrix_Pointers::Matrix_Pointers
Matrix_Pointers()
Default constructor.
Definition: Matrix_PointersInline.cxx:39