Matrix_ArraySparseInline.cxx
1 // Copyright (C) 2003-2011 Marc DuruflĂ©
2 //
3 // This file is part of the linear-algebra library Seldon,
4 // http://seldon.sourceforge.net/.
5 //
6 // Seldon is free software; you can redistribute it and/or modify it under the
7 // terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 2.1 of the License, or (at your option)
9 // any later version.
10 //
11 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
14 // more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with Seldon. If not, see http://www.gnu.org/licenses/.
18 
19 
20 #ifndef SELDON_FILE_MATRIX_ARRAY_SPARSE_INLINE_CXX
21 
22 #include "Matrix_ArraySparse.hxx"
23 
24 namespace Seldon
25 {
26 
28 
31  template <class T, class Prop, class Storage, class Allocator>
33  : VirtualMatrix<T>(), val_()
34  {
35  }
36 
37 
39 
44  template <class T, class Prop, class Storage, class Allocator>
46  Matrix_ArraySparse(int i, int j) :
47  VirtualMatrix<T>(i, j), val_(Storage::GetFirst(i, j))
48  {
49  }
50 
51 
53  template <class T, class Prop, class Storage, class Allocat>
55  {
56  this->m_ = 0;
57  this->n_ = 0;
58  }
59 
60 
62 
65  template <class T, class Prop, class Storage, class Allocator>
67  {
68  this->val_.Clear();
69  this->m_ = 0;
70  this->n_ = 0;
71  }
72 
73 
74  /*******************
75  * BASIC FUNCTIONS *
76  *******************/
77 
78 
80 
85  template <class T, class Prop, class Storage, class Allocator>
87  const
88  {
89  return GetNonZeros();
90  }
91 
92 
94 
99  template <class T, class Prop, class Storage, class Allocator>
101  const
102  {
103  return val_(i).GetIndex();
104  }
105 
106 
108 
112  template <class T, class Prop, class Storage, class Allocator>
113  inline T*
115  {
116  return val_(i).GetData();
117  }
118 
119 
121 
125  template <class T, class Prop, class Storage, class Allocat>
128  {
129  return val_.GetData();
130  }
131 
132 
133  /**********************************
134  * ELEMENT ACCESS AND AFFECTATION *
135  **********************************/
136 
137 
138 #ifdef SELDON_WITH_MODIFIABLE_PARENTHESIS_OPERATOR
139  template <class T, class Prop, class Storage, class Allocator>
140  inline T&
142  {
143  return Get(i, j);
144  }
145 #endif
146 
147 
149 
155  template <class T, class Prop, class Storage, class Allocator>
156  inline const T
158  const
159  {
160 
161 #ifdef SELDON_CHECK_BOUNDS
162  CheckBounds(i, j, this->m_, this->n_, "Matrix_ArraySparse");
163 #endif
164 
165  return this->val_(Storage::GetFirst(i, j))(Storage::GetSecond(i, j));
166  }
167 
168 
170 
176  template <class T, class Prop, class Storage, class Allocator>
177  inline T&
179  {
180 
181 #ifdef SELDON_CHECK_BOUNDS
182  CheckBounds(i, j, this->m_, this->n_, "Matrix_ArraySparse");
183 #endif
184 
185  return this->val_(Storage::GetFirst(i, j)).Get(Storage::GetSecond(i, j));
186  }
187 
188 
190 
196  template <class T, class Prop, class Storage, class Allocator>
197  inline const T&
199  {
200 
201 #ifdef SELDON_CHECK_BOUNDS
202  CheckBounds(i, j, this->m_, this->n_, "Matrix_ArraySparse");
203 #endif
204 
205  return this->val_(Storage::GetFirst(i, j)).Get(Storage::GetSecond(i, j));
206  }
207 
208 
210 
215  template <class T, class Prop, class Storage, class Allocator>
216  inline T&
218  {
219 
220 #ifdef SELDON_CHECK_BOUNDS
221  CheckBounds(i, j, this->m_, this->n_, "Matrix_ArraySparse");
222 #endif
223 
224  return
225  this->val_(Storage::GetFirst(i, j)).Val(Storage::GetSecond(i, j));
226  }
227 
228 
230 
236  template <class T, class Prop, class Storage, class Allocator>
237  inline const T&
239  {
240 
241 #ifdef SELDON_CHECK_BOUNDS
242  CheckBounds(i, j, this->m_, this->n_, "Matrix_ArraySparse");
243 #endif
244 
245  return
246  this->val_(Storage::GetFirst(i, j)).Val(Storage::GetSecond(i, j));
247  }
248 
249 
251 
256  template <class T, class Prop, class Storage, class Allocator>
258  ::Set(int i, int j, const T& x)
259  {
260  this->Get(i, j) = x;
261  }
262 
263 
265 
270  template <class T, class Prop, class Storage, class Allocator>
272  ::SetEntry(int i, int j, const T& x)
273  {
274  this->Get(i, j) = x;
275  }
276 
277 
279 
284  template <class T, class Prop, class Storage, class Allocator>
286  Value (int i, int j) const
287  {
288 
289 #ifdef SELDON_CHECK_BOUNDS
290  CheckBounds(i, j, Storage::GetFirst(this->m_, this->n_),
291  this->val_(i).GetM(), "Matrix_ArraySparse");
292 #endif
293 
294  return val_(i).Value(j);
295  }
296 
297 
299 
304  template <class T, class Prop, class Storage, class Allocator>
305  inline T&
307  {
308 
309 #ifdef SELDON_CHECK_BOUNDS
310  CheckBounds(i, j, Storage::GetFirst(this->m_, this->n_),
311  this->val_(i).GetM(), "Matrix_ArraySparse");
312 #endif
313 
314  return val_(i).Value(j);
315  }
316 
317 
319 
324  template <class T, class Prop, class Storage, class Allocator> inline
326  const
327  {
328 
329 #ifdef SELDON_CHECK_BOUNDS
330  CheckBounds(i, j, Storage::GetFirst(this->m_, this->n_),
331  this->val_(i).GetM(), "Matrix_ArraySparse");
332 #endif
333 
334  return val_(i).Index(j);
335  }
336 
337 
339 
344  template <class T, class Prop, class Storage, class Allocator> inline
346  {
347 
348 #ifdef SELDON_CHECK_BOUNDS
349  CheckBounds(i, j, Storage::GetFirst(this->m_, this->n_),
350  this->val_(i).GetM(), "Matrix_ArraySparse");
351 #endif
352 
353  return val_(i).Index(j);
354  }
355 
356 
358 
364  template <class T, class Prop, class Storage, class Allocator>
366  SetData(int i, int n, T* val, int* ind)
367  {
368  val_(i).SetData(n, val, ind);
369  }
370 
371 
373 
377  template <class T, class Prop, class Storage, class Allocator>
379  {
380  val_(i).Nullify();
381  }
382 
383 
385 
390  template <class T, class Prop, class Storage, class Allocator>
393  {
394  this->m_ = m;
395  this->n_ = n;
396  val_.SetData(Storage::GetFirst(m, n), val);
397  }
398 
399 
401 
405  template <class T, class Prop, class Storage, class Allocator>
407  {
408  this->m_ = 0;
409  this->n_ = 0;
410  val_.Nullify();
411  }
412 
413 
414 #ifdef SELDON_WITH_VIRTUAL
415  template <class T, class Prop, class Storage, class Allocator>
417  ::ApplySor(const SeldonTranspose& trans, Vector<Treal>& x, const Vector<Treal>& r,
418  const typename ClassComplexType<T>::Treal& omega,
419  int nb_iter, int stage_ssor) const
420  {
421  SOR(trans, static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this),
422  x, r, omega, nb_iter, stage_ssor);
423  }
424 
425  template <class T, class Prop, class Storage, class Allocator>
426  inline void Matrix_ArraySparse<T, Prop, Storage, Allocator>
427  ::ApplySor(const SeldonTranspose& trans, Vector<Tcplx>& x, const Vector<Tcplx>& r,
428  const typename ClassComplexType<T>::Treal& omega,
429  int nb_iter, int stage_ssor) const
430  {
431  SOR(trans,
432  static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this),
433  x, r, omega, nb_iter, stage_ssor);
434  }
435 
436  template <class T, class Prop, class Storage, class Allocator>
437  inline void Matrix_ArraySparse<T, Prop, Storage, Allocator>
438  ::MltAddVector(const Treal& alpha, const Vector<Treal>& x,
439  const Treal& beta, Vector<Treal>& y) const
440  {
441  MltAdd(alpha,
442  static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this),
443  x, beta, y);
444  }
445 
446  template <class T, class Prop, class Storage, class Allocator>
447  inline void Matrix_ArraySparse<T, Prop, Storage, Allocator>
448  ::MltAddVector(const Tcplx& alpha, const Vector<Tcplx>& x,
449  const Tcplx& beta, Vector<Tcplx>& y) const
450  {
451  MltAdd(alpha,
452  static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this),
453  x, beta, y);
454  }
455 
456  template <class T, class Prop, class Storage, class Allocator>
457  inline void Matrix_ArraySparse<T, Prop, Storage, Allocator>
458  ::MltAddVector(const Treal& alpha, const SeldonTranspose& trans,
459  const Vector<Treal>& x,
460  const Treal& beta, Vector<Treal>& y) const
461  {
462  MltAdd(alpha, trans,
463  static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this),
464  x, beta, y);
465  }
466 
467  template <class T, class Prop, class Storage, class Allocator>
468  inline void Matrix_ArraySparse<T, Prop, Storage, Allocator>
469  ::MltAddVector(const Tcplx& alpha, const SeldonTranspose& trans,
470  const Vector<Tcplx>& x,
471  const Tcplx& beta, Vector<Tcplx>& y) const
472  {
473  MltAdd(alpha, trans,
474  static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this),
475  x, beta, y);
476  }
477 
478  template <class T, class Prop, class Storage, class Allocator>
479  inline void Matrix_ArraySparse<T, Prop, Storage, Allocator>
480  ::MltVector(const Vector<Treal>& x, Vector<Treal>& y) const
481  {
482  Mlt(static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this), x, y);
483  }
484 
485  template <class T, class Prop, class Storage, class Allocator>
486  inline void Matrix_ArraySparse<T, Prop, Storage, Allocator>
487  ::MltVector(const Vector<Tcplx>& x, Vector<Tcplx>& y) const
488  {
489  Mlt(static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this), x, y);
490  }
491 
492  template <class T, class Prop, class Storage, class Allocator>
493  inline void Matrix_ArraySparse<T, Prop, Storage, Allocator>
494  ::MltVector(const SeldonTranspose& trans,
495  const Vector<Treal>& x, Vector<Treal>& y) const
496  {
497  Mlt(trans,
498  static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this), x, y);
499  }
500 
501  template <class T, class Prop, class Storage, class Allocator>
502  inline void Matrix_ArraySparse<T, Prop, Storage, Allocator>
503  ::MltVector(const SeldonTranspose& trans,
504  const Vector<Tcplx>& x, Vector<Tcplx>& y) const
505  {
506  Mlt(trans,
507  static_cast<const Matrix<T, Prop, Storage, Allocator>& >(*this), x, y);
508  }
509 
510  template <class T, class Prop, class Storage, class Allocator>
511  inline bool Matrix_ArraySparse<T, Prop, Storage, Allocator>
512  ::IsSymmetric() const
513  {
514  return IsSymmetricMatrix(static_cast<const Matrix<T, Prop, Storage,
515  Allocator>& >(*this));
516  }
517 #endif
518 
519 
521  // MATRIX<ARRAY_COLSPARSE> //
523 
524 
526 
529  template <class T, class Prop, class Allocator>
531  Matrix_ArraySparse<T, Prop, ArrayColSparse, Allocator>()
532  {
533  }
534 
535 
537 
542  template <class T, class Prop, class Allocator>
544  Matrix_ArraySparse<T, Prop, ArrayColSparse, Allocator>(i, j)
545  {
546  }
547 
548 
550  template <class T, class Prop, class Allocator>
552  {
553  this->val_(i).Clear();
554  }
555 
556 
558 
562  template <class T, class Prop, class Alloc> inline
564  {
565  this->val_(i).Reallocate(j);
566  }
567 
568 
570 
574  template <class T, class Prop, class Allocator> inline
576  {
577  this->val_(i).Resize(j);
578  }
579 
580 
582 
586  template <class T, class Prop, class Allocator> inline
588  {
589  Swap(this->val_(i), this->val_(j));
590  }
591 
592 
594 
598  template <class T, class Prop, class Allocator>
600  ReplaceIndexColumn(int i, IVect& new_index)
601  {
602  for (int j = 0; j < this->val_(i).GetM(); j++)
603  this->val_(i).Index(j) = new_index(j);
604  }
605 
606 
608 
612  template <class T, class Prop, class Allocator>
614  GetColumnSize(int i) const
615  {
616  return this->val_(i).GetSize();
617  }
618 
619 
621  template <class T, class Prop, class Allocator> inline
623  {
624  this->val_(i).Print();
625  }
626 
627 
629 
634  template <class T, class Prop, class Allocator> inline
636  {
637  this->val_(i).Assemble();
638  }
639 
640 
642 
647  template <class T, class Prop, class Allocator>
649  AddInteraction(int i, int j, const T& val)
650  {
651  this->val_(j).AddInteraction(i, val);
652  }
653 
654 
656  // MATRIX<ARRAY_ROWSPARSE> //
658 
659 
661 
664  template <class T, class Prop, class Allocator>
666  Matrix_ArraySparse<T, Prop, ArrayRowSparse, Allocator>()
667  {
668  }
669 
670 
672 
677  template <class T, class Prop, class Allocator>
679  Matrix_ArraySparse<T, Prop, ArrayRowSparse, Allocator>(i, j)
680  {
681  }
682 
683 
685  template <class T, class Prop, class Allocator>
687  {
688  this->val_(i).Clear();
689  }
690 
691 
693 
698  template <class T, class Prop, class Allocator>
700  ReallocateRow(int i, int j)
701  {
702  this->val_(i).Reallocate(j);
703  }
704 
705 
707 
712  template <class T, class Prop, class Allocator> inline
714  {
715  this->val_(i).Resize(j);
716  }
717 
718 
720 
724  template <class T, class Prop, class Allocator>
726  {
727  Swap(this->val_(i), this->val_(j));
728  }
729 
730 
732 
736  template <class T, class Prop, class Allocator>
738  ReplaceIndexRow(int i, IVect& new_index)
739  {
740  for (int j = 0; j < this->val_(i).GetM(); j++)
741  this->val_(i).Index(j) = new_index(j);
742  }
743 
744 
746 
750  template <class T, class Prop, class Allocator> inline
752  {
753  return this->val_(i).GetSize();
754  }
755 
756 
758  template <class T, class Prop, class Allocator> inline
760  {
761  this->val_(i).Print();
762  }
763 
764 
766 
771  template <class T, class Prop, class Allocator>
773  {
774  this->val_(i).Assemble();
775  }
776 
778 
783  template <class T, class Prop, class Allocator>
785  AddInteraction(int i, int j, const T& val)
786  {
787  this->val_(i).AddInteraction(j, val);
788  }
789 
790 
792  // MATRIX<ARRAY_COLSYMSPARSE> //
794 
795 
797 
800  template <class T, class Prop, class Allocator>
802  Matrix_ArraySparse<T, Prop, ArrayColSymSparse, Allocator>()
803  {
804  }
805 
806 
808 
813  template <class T, class Prop, class Allocator>
815  Matrix_ArraySparse<T, Prop, ArrayColSymSparse, Allocator>(i, j)
816  {
817  }
818 
819 
820  /**********************************
821  * ELEMENT ACCESS AND AFFECTATION *
822  **********************************/
823 
824 
825 #ifdef SELDON_WITH_MODIFIABLE_PARENTHESIS_OPERATOR
826  template <class T, class Prop, class Allocator>
827  inline T&
829  {
830  return Get(i, j);
831  }
832 #endif
833 
834 
836 
842  template <class T, class Prop, class Allocator>
843  inline const T
845  const
846  {
847 
848 #ifdef SELDON_CHECK_BOUNDS
849  CheckBounds(i, j, this->m_, this->n_, "Matrix");
850 #endif
851 
852  if (i < j)
853  return this->val_(j)(i);
854 
855  return this->val_(i)(j);
856  }
857 
858 
860 
866  template <class T, class Prop, class Allocator>
867  inline T&
869  {
870 
871 #ifdef SELDON_CHECK_BOUNDS
872  CheckBounds(i, j, this->m_, this->n_, "Matrix");
873 #endif
874 
875  if (i < j)
876  return this->val_(j).Get(i);
877 
878  return this->val_(i).Get(j);
879  }
880 
881 
883 
889  template <class T, class Prop, class Allocator>
890  inline const T&
892  {
893 
894 #ifdef SELDON_CHECK_BOUNDS
895  CheckBounds(i, j, this->m_, this->n_, "Matrix");
896 #endif
897 
898  if (i < j)
899  return this->val_(j).Get(i);
900 
901  return this->val_(i).Get(j);
902  }
903 
904 
906 
912  template <class T, class Prop, class Allocator>
913  inline T&
915  {
916 
917 #ifdef SELDON_CHECK_BOUNDS
918  CheckBounds(i, j, this->m_, this->n_, "Matrix");
919 #endif
920 
921  if (i > j)
922  return this->val_(i).Val(j);
923 
924  return this->val_(j).Val(i);
925  }
926 
927 
929 
935  template <class T, class Prop, class Allocator>
936  inline const T&
938  {
939 
940 #ifdef SELDON_CHECK_BOUNDS
941  CheckBounds(i, j, this->m_, this->n_, "Matrix");
942 #endif
943 
944  if (i > j)
945  return this->val_(i).Val(j);
946 
947  return this->val_(j).Val(i);
948  }
949 
950 
952 
957  template <class T, class Prop, class Allocator>
958  inline void
960  {
961  if (i < j)
962  this->val_(j).Get(i) = x;
963  else
964  this->val_(i).Get(j) = x;
965  }
966 
967 
969 
974  template <class T, class Prop, class Allocator>
975  inline void
977  {
978  if (i < j)
979  this->val_(j).Get(i) = x;
980  else
981  this->val_(i).Get(j) = x;
982  }
983 
984 
986  template <class T, class Prop, class Allocator> inline
988  {
989  this->val_(i).Clear();
990  }
991 
992 
994 
999  template <class T, class Prop, class Allocator>
1001  ReallocateColumn(int i, int j)
1002  {
1003  this->val_(i).Reallocate(j);
1004  }
1005 
1006 
1008 
1012  template <class T, class Prop, class Allocator>
1014  ResizeColumn(int i, int j)
1015  {
1016  this->val_(i).Resize(j);
1017  }
1018 
1019 
1021 
1025  template <class T, class Prop, class Allocator>
1027  SwapColumn(int i, int j)
1028  {
1029  Swap(this->val_(i), this->val_(j));
1030  }
1031 
1032 
1034 
1038  template <class T, class Prop, class Allocator>
1040  ReplaceIndexColumn(int i, IVect& new_index)
1041  {
1042  for (int j = 0; j < this->val_(i).GetM(); j++)
1043  this->val_(i).Index(j) = new_index(j);
1044  }
1045 
1046 
1048 
1052  template <class T, class Prop, class Allocator>
1054  GetColumnSize(int i) const
1055  {
1056  return this->val_(i).GetSize();
1057  }
1058 
1059 
1061  template <class T, class Prop, class Allocator>
1063  PrintColumn(int i) const
1064  {
1065  this->val_(i).Print();
1066  }
1067 
1068 
1070 
1075  template <class T, class Prop, class Allocator>
1078  {
1079  this->val_(i).Assemble();
1080  }
1081 
1082 
1084 
1089  template <class T, class Prop, class Allocator>
1091  AddInteraction(int i, int j, const T& val)
1092  {
1093  if (i <= j)
1094  this->val_(j).AddInteraction(i, val);
1095  }
1096 
1097 
1099  // MATRIX<ARRAY_ROWSYMSPARSE> //
1101 
1102 
1104 
1107  template <class T, class Prop, class Allocator>
1109  Matrix_ArraySparse<T, Prop, ArrayRowSymSparse, Allocator>()
1110  {
1111  }
1112 
1113 
1115 
1120  template <class T, class Prop, class Allocator>
1122  Matrix_ArraySparse<T, Prop, ArrayRowSymSparse, Allocator>(i, j)
1123  {
1124  }
1125 
1126 
1127  /**********************************
1128  * ELEMENT ACCESS AND AFFECTATION *
1129  **********************************/
1130 
1131 
1132 #ifdef SELDON_WITH_MODIFIABLE_PARENTHESIS_OPERATOR
1133  template <class T, class Prop, class Allocator>
1134  inline T&
1136  {
1137  return Get(i, j);
1138  }
1139 #endif
1140 
1141 
1143 
1149  template <class T, class Prop, class Allocator>
1150  inline const T
1152  const
1153  {
1154 
1155 #ifdef SELDON_CHECK_BOUNDS
1156  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1157 #endif
1158 
1159  if (i < j)
1160  return this->val_(i)(j);
1161 
1162  return this->val_(j)(i);
1163  }
1164 
1165 
1167 
1173  template <class T, class Prop, class Allocator>
1174  inline T&
1176  {
1177 
1178 #ifdef SELDON_CHECK_BOUNDS
1179  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1180 #endif
1181 
1182  if (i < j)
1183  return this->val_(i).Get(j);
1184 
1185  return this->val_(j).Get(i);
1186  }
1187 
1188 
1190 
1196  template <class T, class Prop, class Allocator>
1197  inline const T&
1199  {
1200 
1201 #ifdef SELDON_CHECK_BOUNDS
1202  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1203 #endif
1204 
1205  if (i < j)
1206  return this->val_(i).Get(j);
1207 
1208  return this->val_(j).Get(i);
1209  }
1210 
1211 
1213 
1219  template <class T, class Prop, class Allocator>
1220  inline T&
1222  {
1223 
1224 #ifdef SELDON_CHECK_BOUNDS
1225  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1226 #endif
1227 
1228  if (i > j)
1229  return this->val_(j).Val(i);
1230 
1231  return this->val_(i).Val(j);
1232  }
1233 
1234 
1236 
1242  template <class T, class Prop, class Allocator>
1243  inline const T&
1245  {
1246 
1247 #ifdef SELDON_CHECK_BOUNDS
1248  CheckBounds(i, j, this->m_, this->n_, "Matrix");
1249 #endif
1250 
1251  if (i > j)
1252  return this->val_(j).Val(i);
1253 
1254  return this->val_(i).Val(j);
1255  }
1256 
1257 
1259 
1264  template <class T, class Prop, class Allocator>
1265  inline void
1267  {
1268  if (i < j)
1269  this->val_(i).Get(j) = x;
1270  else
1271  this->val_(j).Get(i) = x;
1272  }
1273 
1274 
1276 
1281  template <class T, class Prop, class Allocator>
1282  inline void
1284  {
1285  if (i < j)
1286  this->val_(i).Get(j) = x;
1287  else
1288  this->val_(j).Get(i) = x;
1289  }
1290 
1291 
1293  template <class T, class Prop, class Allocator>
1295  {
1296  this->val_(i).Clear();
1297  }
1298 
1299 
1301 
1306  template <class T, class Prop, class Allocator>
1308  ReallocateRow(int i,int j)
1309  {
1310  this->val_(i).Reallocate(j);
1311  }
1312 
1313 
1315 
1319  template <class T, class Prop, class Allocator>
1321  ResizeRow(int i,int j)
1322  {
1323  this->val_(i).Resize(j);
1324  }
1325 
1326 
1328 
1332  template <class T, class Prop, class Allocator>
1334  SwapRow(int i,int j)
1335  {
1336  Swap(this->val_(i), this->val_(j));
1337  }
1338 
1339 
1341 
1345  template <class T, class Prop, class Allocator>
1347  ReplaceIndexRow(int i,IVect& new_index)
1348  {
1349  for (int j = 0; j < this->val_(i).GetM(); j++)
1350  this->val_(i).Index(j) = new_index(j);
1351  }
1352 
1353 
1355 
1359  template <class T, class Prop, class Allocator>
1361  const
1362  {
1363  return this->val_(i).GetSize();
1364  }
1365 
1366 
1368  template <class T, class Prop, class Allocator>
1370  const
1371  {
1372  this->val_(i).Print();
1373  }
1374 
1375 
1377 
1382  template <class T, class Prop, class Allocator>
1385  {
1386  this->val_(i).Assemble();
1387  }
1388 
1389 
1391 
1396  template <class T, class Prop, class Allocator>
1398  AddInteraction(int i, int j, const T& val)
1399  {
1400  if (i <= j)
1401  this->val_(i).AddInteraction(j, val);
1402  }
1403 
1404 
1405  template <class T, class Prop, class Allocator>
1406  inline ostream& operator <<(ostream& out,
1408  {
1409  A.WriteText(out);
1410 
1411  return out;
1412  }
1413 
1414 
1415  template <class T, class Prop, class Allocator>
1416  inline ostream& operator <<(ostream& out,
1417  const Matrix<T, Prop, ArrayColSparse, Allocator>& A)
1418  {
1419  A.WriteText(out);
1420 
1421  return out;
1422  }
1423 
1424 
1425  template <class T, class Prop, class Allocator>
1426  inline ostream& operator <<(ostream& out,
1427  const Matrix<T, Prop, ArrayRowSymSparse, Allocator>& A)
1428  {
1429  A.WriteText(out);
1430 
1431  return out;
1432  }
1433 
1434 
1435  template <class T, class Prop, class Allocator>
1436  inline ostream& operator <<(ostream& out,
1437  const Matrix<T, Prop, ArrayColSymSparse, Allocator>& A)
1438  {
1439  A.WriteText(out);
1440 
1441  return out;
1442  }
1443 
1444 } // namespace Seldon
1445 
1446 #define SELDON_FILE_MATRIX_ARRAY_SPARSE_INLINE_CXX
1447 #endif
Seldon::ArrayColSparse
Definition: Storage.hxx:128
Seldon::SeldonTranspose
Definition: MatrixFlag.hxx:32
Seldon::Matrix_ArraySparse::GetIndex
int * GetIndex(int i) const
Returns (row or column) indices of non-zero entries in row.
Definition: Matrix_ArraySparseInline.cxx:100
Seldon::Vector
Definition: SeldonHeader.hxx:207
Seldon::Matrix_ArraySparse::Clear
void Clear()
Clears the matrix.
Definition: Matrix_ArraySparseInline.cxx:66
Seldon::IsSymmetricMatrix
bool IsSymmetricMatrix(const Matrix< T, Prop, Storage, Allocator > &A)
returns true if the matrix is symmetric
Definition: Functions_BaseInline.cxx:778
Seldon::Matrix
Definition: SeldonHeader.hxx:226
Seldon::Matrix_ArraySparse::SetData
void SetData(int, int, Vector< T, VectSparse, Allocator > *)
Redefines the matrix.
Definition: Matrix_ArraySparseInline.cxx:392
Seldon::ArrayRowSymSparse
Definition: Storage.hxx:132
Seldon::ArrayColSymSparse
Definition: Storage.hxx:136
Seldon::Matrix_ArraySparse::WriteText
void WriteText(string FileName, bool cplx=false) const
Writes the matrix in a file.
Definition: Matrix_ArraySparse.cxx:314
Seldon::Matrix< T, Prop, ArrayRowSparse, Allocator >
Row-major sparse-matrix class.
Definition: Matrix_ArraySparse.hxx:214
Seldon::Matrix_ArraySparse::GetData
T * GetData(int i) const
Returns values of non-zero entries of a row/column.
Definition: Matrix_ArraySparseInline.cxx:114
Seldon::Vector< T, VectSparse, Allocator >
Sparse vector class.
Definition: SparseVector.hxx:29
Seldon::Matrix_ArraySparse
Sparse Array-matrix class.
Definition: Matrix_ArraySparse.hxx:38
Seldon::Matrix_ArraySparse::Nullify
void Nullify(int i)
Clears a row without releasing memory.
Definition: Matrix_ArraySparseInline.cxx:378
Seldon::ArrayRowSparse
Definition: Storage.hxx:124
Seldon::Matrix_ArraySparse::Matrix_ArraySparse
Matrix_ArraySparse()
Default constructor.
Definition: Matrix_ArraySparseInline.cxx:32
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::operator<<
ostream & operator<<(ostream &out, const Array< T, N, Allocator > &A)
operator<< overloaded for a 3D array.
Definition: Array.cxx:1617
Seldon::Swap
void Swap(Vector< T, Storage, Allocator > &X, Vector< T, Storage, Allocator > &Y)
Swaps X and Y without copying all elements.
Definition: Functions_Vector.cxx:348
Seldon::VirtualMatrix
Abstract base class for all matrices.
Definition: Matrix_Base.hxx:42