DistributedMatrix.hxx
1 // Copyright (C) 2013-2015 INRIA
2 // Author(s): 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 #ifndef SELDON_FILE_DISTRIBUTED_MATRIX_HXX
21 
22 namespace Seldon
23 {
24 
27  {
28  public:
29 #ifdef SELDON_WITH_MPI
30 
35  IVect OverlapRowNumbers;
36 
38 
42  IVect OverlapProcNumbers;
43 
45  IVect GlobalRowNumbers;
46 
48  IVect ProcSharingRows;
49 
51 
56  Vector<IVect> SharingRowNumbers;
57 
59  int nodl_scalar, nb_unknowns_scal;
60 
62  int nglob;
63 
65  int nloc;
66 
68  MPI_Comm comm;
69 
70  void Clear();
71  void SetData(int nl, int ng, int nodl, int nb_u, const MPI_Comm& comm_,
72  const IVect& overlap_row, const IVect& overlap_proc,
73  const IVect& global_rows, const IVect& proc_rows, const Vector<IVect>& sharing_rows);
74 
75  void Nullify();
76 
77  static int ConstructArrays(IVect& row_num, IVect& overlap_num, IVect& proc_num,
78  IVect& MatchingProc,
79  Vector<IVect>& MatchingDofNumber, const MPI_Comm& comm);
80 
81  static int ConstructArrays(Vector<IVect>& all_rows,
82  IVect& row_num, IVect& overlap_num, IVect& proc_num,
83  IVect& MatchingProc, Vector<IVect>& MatchingDofNumber,
84  const MPI_Comm& comm, bool distribute_row = true);
85 #endif
86 
87  };
88 
89 
91 
102  template<class T>
104  {
105  template<class T0>
106  friend class DistributedMatrix_Base;
107 
108  protected :
110 
115 
117 
122 
125 
128 
130 
136 
138  int nodl_scalar_, nb_unknowns_scal_;
139 
141  int nglob_;
142 
144  MPI_Comm comm_;
145 
149 
153 
156 
158  IVect global_row_to_recv, global_col_to_recv;
159  IVect ptr_global_row_to_recv, ptr_global_col_to_recv;
160 
162  Vector<IVect> local_row_to_send, local_col_to_send;
163 
165  IVect proc_col_to_recv, proc_col_to_send,
166  proc_row_to_recv, proc_row_to_send;
167 
171 
173  long size_max_distant_row, size_max_distant_col;
174 
175  // internal functions
176  void EraseArrayForMltAdd();
177  void SwitchToGlobalNumbers();
178 
179  template<class TypeDist>
180  void SortAndAssembleDistantInteractions(TypeDist& dist_val,
181  Vector<IVect>& dist_proc,
182  IVect& glob_num,
183  IVect& ptr_glob_num,
184  IVect& proc_glob,
185  Vector<IVect>& local_num,
186  IVect& proc_local);
187 
188  template<class T2>
189  void ScatterValues(const Vector<T2>& X, const IVect& num_recv,
190  const IVect&, const IVect& proc_recv,
191  const Vector<IVect>& num_send,
192  const IVect& proc_send, Vector<T2>& Xcol) const;
193 
194  template<class T2>
195  void AssembleValues(const Vector<T2>& Xcol, const IVect& num_recv,
196  const IVect&, const IVect& proc_recv,
197  const Vector<IVect>& num_send,
198  const IVect& proc_send, Vector<T2>& X) const;
199 
200  void AssembleValuesMin(const IVect& Xcol, const IVect& Xcol_proc,
201  const IVect& num_recv, const IVect& ptr_num_recv,
202  const IVect& proc_recv,
203  const Vector<IVect>& num_send,
204  const IVect& proc_send,
205  IVect& Y, IVect& Yproc) const;
206 
207  void AssembleVecMin(Vector<int>& X, Vector<int>& Xproc) const;
208 
209  template<class T0, class TypeDist>
210  void RemoveSmallEntryDistant(const T0&, TypeDist&, Vector<IVect>&);
211 
212  template<class T0> void GetRowSumDistantCol(Vector<T0>& vec_sum) const;
213  template<class T0> void GetRowSumDistantRow(Vector<T0>& vec_sum) const;
214 
215  template<class T0> void GetColSumDistantCol(Vector<T0>& vec_sum) const;
216  template<class T0> void GetColSumDistantRow(Vector<T0>& vec_sum) const;
217 
218  // internal functions for matrix-vector product
219  void PrepareMltAdd();
220 
221  template<class T2>
222  void ScatterRowValues(const Vector<T2>& X, Vector<T2>& Xcol) const;
223 
224  template<class T2>
225  void ScatterColValues(const Vector<T2>& X, Vector<T2>& Xcol) const;
226 
227  template<class T2>
228  void AssembleRowValues(const Vector<T2>& Xrow, Vector<T2>& X) const;
229 
230  template<class T2>
231  void AssembleColValues(const Vector<T2>& Xrow, Vector<T2>& X) const;
232 
233  public:
234  template<class T2>
235  void AssembleVec(Vector<T2>&) const;
236 
237  protected:
238  template<class T2, class Storage2, class Allocator2,
239  class T4, class Storage4, class Allocator4>
240  void MltAddCol(const SeldonTranspose& Trans,
243 
244  template<class T2, class Storage2, class Allocator2,
245  class T4, class Storage4, class Allocator4>
246  void MltAddRow(const SeldonTranspose& Trans,
249 
250  // internal static functions
251  static void AddDistantValue(Vector<T, VectSparse>& dist_col_,
252  IVect& proc_col_,
253  int jglob, int proc2, const T& val);
254 
255  static void SendAndReceiveDistributed(const MPI_Comm& comm, IVect& nsend_int, Vector<IVect>& EntierToSend,
256  Vector<Vector<T> >& FloatToSend, IVect& nrecv_int,
257  Vector<IVect>& EntierToRecv, Vector<Vector<T> >& FloatToRecv);
258 
259 
260  static void AddReceivedInteractions(const MPI_Comm& comm, Matrix<T, General, ArrayRowSparse>& B,
261  Vector<IVect>& EntierToRecv, Vector<Vector<T> >& FloatToRecv,
262  IVect& nrecv_int, Vector<IVect>& EntierToSend,
263  Vector<Vector<T> >& FloatToSend, IVect& nsend_int,
264  IVect& Glob_to_local, const IVect& OverlappedCol,
265  const IVect& OverlapProcNumber,
266  Vector<IVect>& procB, bool reorder);
267 
268  static void AddReceivedInteractions(const MPI_Comm& comm, Matrix<T, General, ArrayColSparse>& B,
269  Vector<IVect>& EntierToRecv, Vector<Vector<T> >& FloatToRecv,
270  IVect& nrecv_int, Vector<IVect>& EntierToSend,
271  Vector<Vector<T> >& FloatToSend, IVect& nsend_int,
272  IVect& Glob_to_local, const IVect& OverlappedCol,
273  const IVect& OverlapProcNumber,
274  Vector<IVect>& procB, bool reorder);
275 
276  template<class TypeDist>
277  static void EraseDistantEntries(MPI_Comm& comm, const Vector<bool>& IsRowDropped,
278  const Vector<bool>& IsRowDroppedDistant,
279  TypeDist& dist_row_, Vector<IVect>& proc_row_,
280  TypeDist& dist_col_, Vector<IVect>& proc_col_);
281 
282  public :
283  // constructors
285  explicit DistributedMatrix_Base(int m, int n);
286 
287  // Inline methods
288  MPI_Comm& GetCommunicator();
289  const MPI_Comm& GetCommunicator() const;
290 
291  int GetLocalM() const;
292  int GetLocalN() const;
293  int GetGlobalM() const;
294  int GetNodlScalar() const;
295  int GetNbScalarUnknowns() const;
296 
297  void AddDistantInteraction(int i, int jglob, int proc,
298  const T& val);
299 
300  void AddRowDistantInteraction(int iglob, int j, int proc,
301  const T& val);
302 
303  long GetMaxDataSizeDistantCol() const;
304  long GetMaxDataSizeDistantRow() const;
305  bool IsReadyForMltAdd() const;
306  void SetReadyForMltAdd(bool all_zero = true);
307 
308  int GetDistantColSize(int i) const;
309  int IndexGlobalCol(int i, int j) const;
310  int ProcessorDistantCol(int i, int j) const;
311  const T& ValueDistantCol(int i, int j) const;
312 
313  int GetDistantRowSize(int i) const;
314  int IndexGlobalRow(int i, int j) const;
315  int ProcessorDistantRow(int i, int j) const;
316  const T& ValueDistantRow(int i, int j) const;
317 
318  // initialisation of pointers
319  void Init(int n, IVect*, IVect*, IVect*,
320  int, int, IVect*, Vector<IVect>*, const MPI_Comm&);
321 
323  void Init(IVect&, const MPI_Comm& comm, DistributedMatrixIntegerArray&);
324 
325  template<class T0>
326  void Init(const DistributedMatrix_Base<T0>&);
327 
328  void Init(Vector<IVect>&, IVect&, IVect&, IVect&,
329  IVect&, Vector<IVect>&, const MPI_Comm&,
330  bool distribute_row = true);
331 
332  void Init(IVect&, IVect&, IVect&,
333  IVect&, Vector<IVect>&, const MPI_Comm&);
334 
335  // memory management
336  void ReallocateDist(int m, int n);
337  void Resize(int m, int n);
338  void Clear();
339 
340  // basic functions
343 
344  template<class T2>
345  void Copy(const DistributedMatrix_Base<T2>& X);
346 
347  template<class T0>
349 
351  const IVect& GetGlobalRowNumber() const;
353  const IVect& GetOverlapRowNumber() const;
355  const IVect& GetOverlapProcNumber() const;
357  const IVect& GetProcessorSharingRows() const;
359  const Vector<IVect>& GetSharingRowNumbers() const;
360 
361  size_t GetMemorySize() const;
362 
363  // convenient functions overloaded
364  long GetNonZeros() const;
365  long GetDataSize() const;
366 
367  template<class T0>
368  void RemoveSmallEntry(const T0& epsilon);
369 
370  void SetIdentity();
371  void Zero();
372  void Fill();
373 
374  template<class T0>
375  void Fill(const T0& x);
376 
377  void FillRand();
378 
379  void WriteText(ostream& FileStream, Vector<int>& Indow, Vector<int>& IndCol,
380  Vector<T>& Value, bool cplx) const;
381 
382  // functions called by matrix-vector products
383  template<class T2, class T3, class T4, class Storage4, class Allocator4>
384  void InitMltAdd(bool& proceed_distant_row, bool& proceed_distant_col,
385  const Vector<T2>& X, Vector<T2>& Xcol,
386  const T3& beta, Vector<T4, Storage4, Allocator4>& Y,
388 
389  template<class T2, class T3, class T4, class Storage4, class Allocator4>
390  void FinalizeMltAdd(bool proceed_distant_row, bool proceed_distant_col,
391  const Vector<T2>& X, Vector<T2>& Xcol, const T3& alpha,
392  const T3& beta, Vector<T4, Storage4, Allocator4>& Y,
393  Vector<T4, Storage4, Allocator4>& Yres, bool assemble) const;
394 
395  template<class T2, class T3, class T4, class Storage4, class Allocator4>
396  void InitMltAdd(bool& proceed_distant_row, bool& proceed_distant_col,
397  const SeldonTranspose& trans, const Vector<T2>& X, Vector<T2>& Xrow,
398  const T3& beta, Vector<T4, Storage4, Allocator4>& Y,
400 
401  template<class T2, class T3, class T4, class Storage4, class Allocator4>
402  void FinalizeMltAdd(bool proceed_distant_row, bool proceed_distant_col,
403  const SeldonTranspose& trans, const Vector<T2>& X, Vector<T2>& Xrow,
404  const T3& alpha, const T3& beta, Vector<T4, Storage4, Allocator4>& Y,
405  Vector<T4, Storage4, Allocator4>& Yres, bool assemble) const;
406 
407  void InitMltMin(Vector<int>& Y, Vector<int>& Yproc,
408  Vector<int>& Xcol, Vector<int>& Xcol_proc) const;
409 
410  void FinalizeMltMin(Vector<int>& Y, Vector<int>& Yproc,
411  Vector<int>& Xcol, Vector<int>& Xcol_proc) const;
412 
413  // methods called for various functions on matrices
414  template<class T0, class T1>
415  void AddDistributedMatrix(const T0& alpha,
416  const DistributedMatrix_Base<T1>& A);
417 
418  void GetMaxAbsDistant(typename ClassComplexType<T>::Treal& res) const;
419 
420  template<class T0>
421  void AddRowSumDistant(Vector<T0>& vec_sum) const;
422 
423  template<class T0>
424  void AddColSumDistant(Vector<T0>& vec_sum) const;
425 
426  template<class T0>
427  void AddRowColSumDistant(Vector<T0>& sum_row, Vector<T0>& sum_col) const;
428 
429  void ExchangeParallelData(int& smax_row, int& smax_col, bool& local_number,
431  NewAlloc<Vector<T, VectSparse> > >& dist_row_,
433  NewAlloc<Vector<T, VectSparse> > >& dist_col_,
434  Vector<IVect>& proc_row_, Vector<IVect>& proc_col_,
435  IVect& global_row_to_recv_, IVect& global_col_to_recv_,
436  IVect& ptr_global_row_to_recv_, IVect& ptr_global_col_to_recv_,
437  Vector<IVect>& local_row_to_send_, Vector<IVect>& local_col_to_send_,
438  IVect& proc_row_to_recv_, IVect& proc_col_to_recv_,
439  IVect& proc_row_to_send_, IVect& proc_col_to_send_);
440 
441  void ConjugateDistant();
443 
444  template<class T0>
445  void ScaleLeftDistant(const Vector<T0>& Drow);
446 
447  template<class T0>
448  void ScaleRightDistant(const Vector<T0>& Dcol);
449 
450  template<class T0, class T1>
451  void ScaleDistant(const Vector<T0>& Drow, const Vector<T1>& Dcol);
452 
453  void EraseColDistant(const IVect& num, bool sym);
454  void EraseRowDistant(const IVect& num, bool sym);
455 
456  template<class T1>
458  const IVect& row, const IVect& col, bool sym);
459 
461 
462  // functions for assembling matrix
464  Symmetric& sym, IVect& row_numbers, IVect& local_row_numbers,
465  IVect& OverlappedCol, bool sym_pattern, bool reorder);
466 
467  template<class Tint0, class Tint1>
468  static void ConvertToCSR(Matrix<T, General, ArrayRowSparse>& B, IVect& OverlappedCol,
469  Vector<Tint0>& PtrA, Vector<Tint1>& IndA, Vector<T>& ValA);
470 
472  General& prop, IVect& col_numbers, IVect& local_col_numbers,
473  IVect& OverlappedCol, bool sym_pattern, bool reorder);
474 
475  template<class Tint0, class Tint1>
476  static void ConvertToCSC(Matrix<T, General, ArrayColSparse>& B, IVect& OverlappedCol,
477  Vector<Tint0>& PtrA, Vector<Tint1>& IndA, Vector<T>& ValA);
478 
479  template<class T0, class Allocator0>
481  ArrayRowSparse, Allocator0>& rows,
482  Vector<IVect>& proc, bool sym) const;
483 
484  template<class T0, class Allocator0>
486  Vector<IVect>& procB, Vector<long>& Ptr, IVect& Ind,
487  Vector<T0>& Val, bool sym_pattern) const;
488 
489  };
490 
491 
493 
504  template<class T, class Prop, class Storage, class Allocator
505  = typename SeldonDefaultAllocator<Storage, T>::allocator>
506  class DistributedMatrix : public Matrix<T, Prop, Storage, Allocator>,
507  public DistributedMatrix_Base<T>
508  {
509  template<class T0, class Prop0, class Storage0, class Allocator0>
510  friend class DistributedMatrix;
511 
512  public :
513  // constructors
515  explicit DistributedMatrix(int m, int n);
516 
517  // Inline methods
518  void AddDistantInteraction(int i, int jglob, int proc,
519  const T& val);
520 
521  void AddRowDistantInteraction(int iglob, int j, int proc,
522  const T& val);
523 
524  // memory management
525  void Reallocate(int m, int n);
526  void Resize(int m, int n);
527  void Clear();
528  void ClearLocal();
529 
530  // basic functions
531  template<class T2, class Prop2, class Storage2, class Allocator2>
534 
535  template<class T0>
537 
538  size_t GetMemorySize() const;
539 
540  // convenient functions
541  long GetNonZeros() const;
542  long GetDataSize() const;
543 
544  template<class T0>
545  void RemoveSmallEntry(const T0& epsilon);
546 
547  void SetIdentity();
548  void Zero();
549  void Fill();
550 
551  template<class T0>
552  void Fill(const T0& x);
553 
554  void FillRand();
555 
556  void Write(string FileName) const;
557  void Write(ostream& FileStream) const;
558  void WriteText(string FileName, bool cplx = false) const;
559  void WriteText(ostream& FileStream, bool cplx = false) const;
560  void Read(string FileName);
561  void Read(istream& FileStream);
562  void ReadText(string FileName, bool cplx = false);
563  void ReadText(istream& FileStream, bool cplx = false);
564 
565  // functions for assembling matrix
566  template<class T0, class Allocator0>
568  ArrayRowSparse, Allocator0>& rows,
569  Vector<IVect>& proc) const;
570 
571  template<class T0, class Allocator0>
573  ArrayColSparse, Allocator0>& rows,
574  Vector<IVect>&, bool sym_pattern) const;
575 
576 #ifdef SELDON_WITH_VIRTUAL
577  // virtual inline methods
578  typedef typename ClassComplexType<T>::Treal Treal;
579  typedef typename ClassComplexType<T>::Tcplx Tcplx;
580 
581  virtual void ApplySor(const SeldonTranspose&, Vector<Treal>& x, const Vector<Treal>& r,
582  const typename ClassComplexType<T>::Treal& omega,
583  int nb_iter, int stage_ssor) const;
584 
585  virtual void ApplySor(const SeldonTranspose&, Vector<Tcplx>& x, const Vector<Tcplx>& r,
586  const typename ClassComplexType<T>::Treal& omega,
587  int nb_iter, int stage_ssor) const;
588 
589  virtual void MltAddVector(const Treal& alpha, const Vector<Treal>& x,
590  const Treal& beta, Vector<Treal>& y) const;
591 
592  virtual void MltAddVector(const Tcplx& alpha, const Vector<Tcplx>& x,
593  const Tcplx& beta, Vector<Tcplx>& y) const;
594 
595  virtual void MltAddVector(const Treal& alpha, const SeldonTranspose&,
596  const Vector<Treal>& x,
597  const Treal& beta, Vector<Treal>& y) const;
598 
599  virtual void MltAddVector(const Tcplx& alpha, const SeldonTranspose&,
600  const Vector<Tcplx>& x,
601  const Tcplx& beta, Vector<Tcplx>& y) const;
602 
603  virtual void MltVector(const Vector<Treal>& x, Vector<Treal>& y) const;
604  virtual void MltVector(const Vector<Tcplx>& x, Vector<Tcplx>& y) const;
605 
606  virtual void MltVector(const SeldonTranspose&,
607  const Vector<Treal>& x, Vector<Treal>& y) const;
608 
609  virtual void MltVector(const SeldonTranspose&,
610  const Vector<Tcplx>& x, Vector<Tcplx>& y) const;
611 #endif
612 
613  };
614 
615 
616  // matrix vector products
617  template<class T0, class T1, class Prop1, class Storage1, class Allocator1,
618  class T2, class Storage2, class Allocator2, class T3,
619  class T4, class Storage4, class Allocator4>
620  void MltAddVector(const T0& alpha,
623  const T3& beta,
624  Vector<T4, Storage4, Allocator4>& Yres, bool assemble = true);
625 
626  template<class T0, class T1, class Prop1, class Storage1, class Allocator1,
627  class T2, class Storage2, class Allocator2, class T3,
628  class T4, class Storage4, class Allocator4>
629  void MltAddVector(const T0& alpha,
630  const SeldonTranspose& Trans,
633  const T3& beta,
634  Vector<T4, Storage4, Allocator4>& Y, bool assemble = true);
635 
636  template <class T0, class Prop0, class Storage0, class Allocator0,
637  class T1, class Storage1, class Allocator1,
638  class T2, class Storage2, class Allocator2>
641  Vector<T2, Storage2, Allocator2>& Y, bool assemble = true);
642 
643  template <class T1, class Prop1, class Storage1, class Allocator1,
644  class T2, class Storage2, class Allocator2,
645  class T3, class Storage3, class Allocator3>
646  void MltVector(const T3& alpha,
649  Vector<T3, Storage3, Allocator3>& Y, bool assemble = true);
650 
651  template <class T1, class Prop1, class Storage1, class Allocator1,
652  class T2, class Storage2, class Allocator2,
653  class T3, class Storage3, class Allocator3>
654  void MltVector(const SeldonTranspose& Trans,
657  Vector<T3, Storage3, Allocator3>& Y, bool assemble = true);
658 
659  template<class T0, class T1, class Prop1, class Storage1, class Allocator1>
660  void MltScalar(const T0& alpha,
662 
663  template<class T1, class Prop1, class Allocator1>
665  const IVect& global, IVect& Y, IVect& Yproc);
666 
667  template<class T1, class Prop1, class Allocator1>
669  const IVect& global, IVect& Y, IVect& Yproc);
670 
671 #ifdef SELDON_FILE_MATRIX_ARRAY_COMPLEX_SPARSE_HXX
672  template<class T1, class Prop1, class Allocator1>
674  const IVect& global, IVect& Y, IVect& Yproc);
675 
676  template<class T1, class Prop1, class Allocator1>
677  void MltMin(const Matrix<T1, Prop1,
678  ArrayRowSymComplexSparse, Allocator1>& A,
679  const IVect& global, IVect& Y, IVect& Yproc);
680 #endif
681 
682  template<class T1, class Prop1, class Storage1, class Allocator1>
684  IVect& Y, IVect& Yproc);
685 
686  // matrix functions
687 
688  template<class T0, class T1, class Prop1, class Storage1, class Allocator1,
689  class T2, class Prop2, class Storage2, class Allocator2>
690  void AddMatrix(const T0& alpha,
693 
694  template<class T1, class Prop1, class Storage1, class Allocator1>
695  typename ClassComplexType<T1>::Treal
697 
698  template<class T0, class T, class Prop, class Storage, class Allocator>
699  void GetRowSum(Vector<T0>& vec_sum,
701 
702  template<class T0, class T, class Prop, class Storage, class Allocator>
703  void GetColSum(Vector<T0>& vec_sum,
705 
706  template<class T0, class T, class Prop, class Storage, class Allocator>
707  void GetRowColSum(Vector<T0>& sum_row,
708  Vector<T0>& sum_col,
710 
711  template<class T1, class Prop1, class Storage1, class Allocator1>
712  typename ClassComplexType<T1>::Treal
714 
715  template<class T1, class Prop1, class Storage1, class Allocator1>
716  typename ClassComplexType<T1>::Treal
718 
719  template<class T1, class Prop1, class Storage1, class Allocator1>
721 
722  template<class T1, class Prop1, class Storage1, class Allocator1>
724 
725  template<class T1, class Prop1, class Storage1, class Allocator1>
728 
729  template<class T, class Prop, class Storage, class Allocator>
730  void TransposeConj(const DistributedMatrix<T, Prop,
731  Storage, Allocator>& A,
733 
734  template<class T, class Prop, class Storage, class Allocator>
736 
737  // matrix-matrix products
738 
739  template<class T1, class Prop1, class Storage1, class Allocator1,
740  class T2, class Prop2, class Storage2, class Allocator2,
741  class T4, class Prop4, class Storage4, class Allocator4>
745 
746  template<class T0,
747  class T1, class Prop1, class Storage1, class Allocator1,
748  class T2, class Prop2, class Storage2, class Allocator2,
749  class T3,
750  class T4, class Prop4, class Storage4, class Allocator4>
751  void MltAddMatrix(const T0& alpha,
754  const T3& beta,
756 
757  template<class T0, class T1, class Prop1, class Storage1, class Allocator1,
758  class T2, class Prop2, class Storage2, class Allocator2, class T3,
759  class T4, class Prop4, class Storage4, class Allocator4>
760  void MltAddMatrix(const T0& alpha, const SeldonTranspose& transA,
762  const SeldonTranspose& transB,
764  const T3& beta,
766 
767  // Matrix functions
768 
769  template<class T0, class Prop0, class Storage0, class Allocator0,
770  class T1, class Allocator1>
773 
774  template<class T0, class Prop0, class Storage0, class Allocator0,
775  class T1, class Allocator1>
778 
779  template<class T0, class Prop0, class Storage0, class Allocator0,
780  class T1, class Allocator1>
781  void SetRow(const Vector<T1, VectSparse, Allocator1>& X,
783 
784  template<class T0, class Prop0, class Storage0, class Allocator0,
785  class T1, class Allocator1>
786  void SetCol(const Vector<T1, VectSparse, Allocator1>& X,
788 
789  template<class T, class Prop, class Storage, class Allocator>
790  void ApplyPermutation(DistributedMatrix<T, Prop, Storage, Allocator>& A,
791  const Vector<int>& row_perm,
792  const Vector<int>& col_perm);
793 
794  template<class T, class Prop, class Storage, class Allocator>
795  void
796  ApplyInversePermutation(DistributedMatrix<T, Prop, Storage, Allocator>& A,
797  const Vector<int>& row_perm,
798  const Vector<int>& col_perm);
799 
800  template <class T0, class Prop0, class Storage0, class Allocator0,
801  class T1, class Storage1, class Allocator1,
802  class T2, class Storage2, class Allocator2, class T3>
806  const T3& omega, int iter, int type_ssor = 2);
807 
808  template <class T0, class Prop0, class Storage0, class Allocator0,
809  class T1, class Storage1, class Allocator1,
810  class T2, class Storage2, class Allocator2, class T3>
811  void SorVector(const SeldonTranspose& transM,
815  const T3& omega, int iter, int type_ssor = 3);
816 
817  template<class T1, class Prop, class Storage, class Allocator,
818  class T2, class Allocator2, class Allocator3>
820  const IVect& col_number,
822  VectSparse, Allocator3>& V);
823 
824  template<class T, class Prop1, class Storage1, class Allocator1,
825  class Prop2, class Storage2, class Allocator2>
828 
829  template<class T, class Prop1, class Storage1, class Allocator1,
830  class Prop2, class Storage2, class Allocator2>
831  void Copy(const DistributedMatrix<complex<T>, Prop1, Storage1, Allocator1>& A,
833 
834  template<class T, class Prop1, class Storage1, class Allocator1,
835  class Prop2, class Storage2, class Allocator2>
837  DistributedMatrix<complex<T>, Prop2, Storage2, Allocator2>& B);
838 
839  template<class T1, class Prop1, class Storage1, class Allocator1,
840  class T2, class Prop2, class Storage2, class Allocator2>
841  void
844 
845  template<class T, class Prop, class Storage, class Allocator>
846  typename ClassComplexType<T>::Treal
848 
849  template<class T, class Storage, class Allocator,
850  class T1, class Allocator1>
853 
854  template<class T, class Storage, class Allocator,
855  class T1, class Allocator1>
856  void ScaleRightMatrix(DistributedMatrix<T, General, Storage, Allocator>& A,
858 
859  template<class T, class Prop, class Storage, class Allocator,
860  class T1, class Allocator1, class T2, class Allocator2>
864 
865  template<class Prop, class Storage, class Alloc, class Tint0, class Tint1, class T>
866  void AssembleDistributed(DistributedMatrix<T, Prop, Storage, Alloc>& A,
867  Symmetric& sym, const MPI_Comm& comm,
868  IVect& row_numbers, IVect& local_row_numbers,
869  Vector<Tint0>& PtrA, Vector<Tint1>& IndA,
870  Vector<T>& ValA, bool sym_pattern, bool reorder = false);
871 
872  template<class Prop, class Storage, class Alloc, class Tint0, class Tint1, class T>
873  void AssembleDistributed(DistributedMatrix<T, Prop, Storage, Alloc>& A,
874  General& prop, const MPI_Comm& comm,
875  IVect& col_numbers, IVect& local_col_numbers,
876  Vector<Tint0>& PtrA, Vector<Tint1>& IndA,
877  Vector<T>& ValA, bool sym_pattern, bool reorder = false);
878 
879  template<class TypeDist>
880  void EraseDistantEntries(MPI_Comm& comm, const Vector<bool>& IsRowDropped,
881  const Vector<bool>& IsRowDroppedDistant,
882  TypeDist& dist_row, Vector<IVect>& proc_row,
883  TypeDist& dist_col, Vector<IVect>& proc_col);
884 
885  template<class T1, class Prop1, class Storage1, class Allocator1>
886  void EraseCol(const IVect& num,
888 
889  template<class T1, class Prop1, class Storage1, class Allocator1>
890  void EraseRow(const IVect& num,
892 
893  template<class T0, class Prop0, class Storage0, class Allocator0,
894  class T1, class Prop1, class Storage1, class Allocator1>
895  void
897  const IVect& row, const IVect& col,
899 
900  /****************************************
901  * Mlt, MltAdd for distributed matrices *
902  ****************************************/
903 
904  // functions present in DistributedMatrixInline.cxx
905  template<class T, class Prop, class Storage, class Allocator>
906  void Mlt(const T& alpha,
908 
909  template<class T, class Prop, class Storage, class Allocator>
910  void Mlt(const T& alpha,
911  DistributedMatrix<complex<T>, Prop, Storage, Allocator>& A);
912 
913  template <class T,
914  class Prop1, class Storage1, class Allocator1,
915  class Prop2, class Storage2, class Allocator2>
916  void Add(const T& alpha,
919 
920  template <class T,
921  class Prop1, class Storage1, class Allocator1,
922  class Prop2, class Storage2, class Allocator2>
923  void Add(const complex<T>& alpha,
925  DistributedMatrix<complex<T>, Prop2, Storage2, Allocator2>& B);
926 
927  template <class T,
928  class Prop1, class Storage1, class Allocator1,
929  class Prop2, class Storage2, class Allocator2>
930  void Add(const T& alpha,
931  const DistributedMatrix<complex<T>, Prop1, Storage1, Allocator1>& A,
932  DistributedMatrix<complex<T>, Prop2, Storage2, Allocator2>& B);
933 
934  template <class T,
935  class Prop1, class Storage1, class Allocator1,
936  class Prop2, class Storage2, class Allocator2>
937  void Add(const T& alpha,
938  const DistributedMatrix<complex<T>, Prop1, Storage1, Allocator1>& A,
940 
941  template<class T0, class Prop0, class Storage0, class Allocator0>
943  const Vector<T0>& X, Vector<T0>& Y, bool assemble = true);
944 
945  template<class T0, class Prop0, class Storage0, class Allocator0>
947  const Vector<complex<T0> >& X, Vector<complex<T0> >& Y,
948  bool assemble = true);
949 
950  template<class T0, class Prop0, class Storage0, class Allocator0>
951  void Mlt(const DistributedMatrix<complex<T0>, Prop0, Storage0, Allocator0>&,
952  const Vector<T0>& X, Vector<T0>& Y, bool assemble = true);
953 
954  template<class T0, class Prop0, class Storage0, class Allocator0>
955  void Mlt(const SeldonTranspose& trans,
957  const Vector<T0>& X, Vector<T0>& Y, bool assemble = true);
958 
959  template<class T0, class Prop0, class Storage0, class Allocator0>
960  void Mlt(const SeldonTranspose& trans,
962  const Vector<complex<T0> >& X, Vector<complex<T0> >& Y,
963  bool assemble = true);
964 
965  template<class T0, class Prop0, class Storage0, class Allocator0>
966  void Mlt(const SeldonTranspose& trans,
967  const DistributedMatrix<complex<T0>, Prop0, Storage0, Allocator0>& A,
968  const Vector<T0>& X, Vector<T0>& Y, bool assemble = true);
969 
970  template<class T0, class Prop0, class Storage0, class Allocator0>
971  void MltAdd(const T0& alpha,
973  const Vector<T0>& X, const T0& beta, Vector<T0>& Y,
974  bool assemble = true);
975 
976  template<class T0, class Prop0, class Storage0, class Allocator0>
977  void MltAdd(const complex<T0>& alpha,
979  const Vector<complex<T0> >& X, const complex<T0>& beta,
980  Vector<complex<T0> >& Y, bool assemble = true);
981 
982  template<class T0, class Prop0, class Storage0, class Allocator0>
983  void MltAdd(const T0& alpha,
984  const DistributedMatrix<complex<T0>, Prop0, Storage0, Allocator0>& A,
985  const Vector<T0>& X, const T0& beta, Vector<T0>& Y, bool assemble = true);
986 
987  template<class T0, class Prop0, class Storage0, class Allocator0>
988  void MltAdd(const T0& alpha, const SeldonTranspose& trans,
990  const Vector<T0>& X, const T0& beta, Vector<T0>& Y, bool assemble = true);
991 
992  template<class T0, class Prop0, class Storage0, class Allocator0>
993  void MltAdd(const complex<T0>& alpha, const SeldonTranspose& trans,
995  const Vector<complex<T0> >& X, const complex<T0>& beta,
996  Vector<complex<T0> >& Y, bool assemble = true);
997 
998  template<class T0, class Prop0, class Storage0, class Allocator0>
999  void MltAdd(const T0& alpha, const SeldonTranspose& trans,
1000  const DistributedMatrix<complex<T0>, Prop0, Storage0, Allocator0>& A,
1001  const Vector<T0>& X, const T0& beta, Vector<T0>& Y, bool assemble = true);
1002 
1003  template <class T, class Prop0, class Storage0, class Allocator0,
1004  class Storage1, class Allocator1,
1005  class Storage2, class Allocator2>
1009  const T& omega, int iter, int type_ssor = 2);
1010 
1011  template <class T, class Prop0, class Storage0, class Allocator0,
1012  class Storage1, class Allocator1,
1013  class Storage2, class Allocator2>
1014  void SOR(const SeldonTranspose&,
1018  const T& omega, int iter, int type_ssor = 3);
1019 
1020  template <class T, class Prop0, class Storage0, class Allocator0,
1021  class Storage1, class Allocator1,
1022  class Storage2, class Allocator2>
1024  Vector<complex<T>, Storage2, Allocator2>& Y,
1025  const Vector<complex<T>, Storage1, Allocator1>& X,
1026  const T& omega, int iter, int type_ssor = 2);
1027 
1028  template <class T, class Prop0, class Storage0, class Allocator0,
1029  class Storage1, class Allocator1,
1030  class Storage2, class Allocator2>
1031  void SOR(const SeldonTranspose&,
1033  Vector<complex<T>, Storage2, Allocator2>& Y,
1034  const Vector<complex<T>, Storage1, Allocator1>& X,
1035  const T& omega, int iter, int type_ssor = 3);
1036 
1037  template <class T, class Prop0, class Storage0, class Allocator0,
1038  class Storage1, class Allocator1,
1039  class Storage2, class Allocator2>
1040  void SOR(const DistributedMatrix<complex<T>, Prop0, Storage0, Allocator0>& M,
1043  const T& omega, int iter, int type_ssor = 2);
1044 
1045  template <class T, class Prop0, class Storage0, class Allocator0,
1046  class Storage1, class Allocator1,
1047  class Storage2, class Allocator2>
1048  void SOR(const SeldonTranspose&,
1049  const DistributedMatrix<complex<T>, Prop0, Storage0, Allocator0>& M,
1052  const T& omega, int iter, int type_ssor = 3);
1053 
1054 }
1055 
1056 #define SELDON_FILE_DISTRIBUTED_MATRIX_HXX
1057 #endif
1058 
Seldon::DistributedMatrix_Base::global_row_to_recv
IVect global_row_to_recv
global row/col numbers (needed for MltAdd)
Definition: DistributedMatrix.hxx:158
Seldon::DistributedMatrix::operator*=
DistributedMatrix< T, Prop, Storage, Allocator > & operator*=(const T0 &x)
multiplication by a scalar
Definition: DistributedMatrix.cxx:4885
Seldon::DistributedMatrix_Base::PrepareMltAdd
void PrepareMltAdd()
prepares a matrix vector product with the distributed matrix
Definition: DistributedMatrix.cxx:956
Seldon::DistributedMatrix_Base::InitMltAdd
void InitMltAdd(bool &proceed_distant_row, bool &proceed_distant_col, const Vector< T2 > &X, Vector< T2 > &Xcol, const T3 &beta, Vector< T4, Storage4, Allocator4 > &Y, Vector< T4, Storage4, Allocator4 > &Yres) const
Initializes the matrix-vector product
Definition: DistributedMatrix.cxx:2434
Seldon::DistributedMatrix_Base::dist_col
Vector< Vector< T, VectSparse >, VectFull, NewAlloc< Vector< T, VectSparse > > > dist_col
additional values on rows with non-local columns
Definition: DistributedMatrix.hxx:148
Seldon::ArrayColSparse
Definition: Storage.hxx:128
Seldon::DistributedMatrix_Base::EraseArrayForMltAdd
void EraseArrayForMltAdd()
erases any array used for MltAdd
Definition: DistributedMatrix.cxx:406
Seldon::TransposeConj
void TransposeConj(const Matrix< T, Prop, Storage, Allocator > &A, Matrix< T, Prop, Storage, Allocator > &B)
Matrix transposition and conjugation.
Definition: Functions_Matrix.cxx:2925
Seldon::DistributedMatrix_Base::GetLocalN
int GetLocalN() const
returns the local number of columns
Definition: DistributedMatrixInline.cxx:58
Seldon::DistributedMatrix_Base::GetNbScalarUnknowns
int GetNbScalarUnknowns() const
returns the number of scalar unknowns
Definition: DistributedMatrixInline.cxx:82
Seldon::DistributedMatrix::GetDistributedColumns
void GetDistributedColumns(Matrix< T0, General, ArrayColSparse, Allocator0 > &rows, Vector< IVect > &, bool sym_pattern) const
grouping all the local columns of the matrix into CSC form
Definition: DistributedMatrix.cxx:5189
Seldon::SeldonTranspose
Definition: MatrixFlag.hxx:32
Seldon::DistributedMatrix::Clear
void Clear()
Clears the matrix.
Definition: DistributedMatrix.cxx:4851
Seldon::DistributedMatrix_Base::AssembleValuesMin
void AssembleValuesMin(const IVect &Xcol, const IVect &Xcol_proc, const IVect &num_recv, const IVect &ptr_num_recv, const IVect &proc_recv, const Vector< IVect > &num_send, const IVect &proc_send, IVect &Y, IVect &Yproc) const
assembles the results for each row, by taking the minimum of Yproc then the minimum of Y
Definition: DistributedMatrix.cxx:764
Seldon::DistributedMatrix_Base::Zero
void Zero()
sets values of non-zero entries to 0
Definition: DistributedMatrix.cxx:2297
Seldon::DistributedMatrix_Base::GetRowSumDistantCol
void GetRowSumDistantCol(Vector< T0 > &vec_sum) const
adds contribution of dist_col for GetRowSum
Definition: DistributedMatrix.cxx:887
Seldon::DistributedMatrix::Read
void Read(string FileName)
reads the matrix in binary format
Definition: DistributedMatrix.cxx:5106
Seldon::DistributedMatrix_Base::ConvertToCSR
static void ConvertToCSR(Matrix< T, General, ArrayRowSparse > &B, IVect &OverlappedCol, Vector< Tint0 > &PtrA, Vector< Tint1 > &IndA, Vector< T > &ValA)
Fills PtrA, IndA and ValA from values contained in B.
Definition: DistributedMatrix.cxx:3885
Seldon::DistributedMatrix_Base::Init
void Init(int n, IVect *, IVect *, IVect *, int, int, IVect *, Vector< IVect > *, const MPI_Comm &)
Initialisation of pointers.
Definition: DistributedMatrix.cxx:1750
Seldon::MltScalar
void MltScalar(const T0 &alpha, Array3D< T, Allocator > &A)
Multiplication of all elements of a 3D array by a scalar.
Definition: Array3D.cxx:539
Seldon::DistributedMatrix_Base::GetDistributedColumns
void GetDistributedColumns(Matrix< T0, General, ArrayColSparse, Allocator0 > &B, Vector< IVect > &procB, Vector< long > &Ptr, IVect &Ind, Vector< T0 > &Val, bool sym_pattern) const
grouping all the local columns of the matrix into CSC form
Definition: DistributedMatrix.cxx:4703
Seldon::DistributedMatrix_Base::AddDistributedMatrix
void AddDistributedMatrix(const T0 &alpha, const DistributedMatrix_Base< T1 > &A)
Adds alpha A to the current matrix (only distant values)
Definition: DistributedMatrix.cxx:2748
Seldon::DistributedMatrix_Base::FillRand
void FillRand()
sets values of non-zero entries to random values
Definition: DistributedMatrix.cxx:2350
Seldon::DistributedMatrix_Base::Clear
void Clear()
matrix is cleared
Definition: DistributedMatrix.cxx:1916
Seldon::Norm1
ClassComplexType< T >::Treal Norm1(const VectorExpression< T, E > &X)
returns 1-norm of an expression with vectors
Definition: Functions_BaseInline.cxx:140
Seldon::DistributedMatrix_Base::AddRowColSumDistant
void AddRowColSumDistant(Vector< T0 > &sum_row, Vector< T0 > &sum_col) const
Adds \sum |a_ij| to sum_row(i) and sum_col(j) for distant non-zero entries.
Definition: DistributedMatrix.cxx:2848
Seldon::DistributedMatrix::SetIdentity
void SetIdentity()
sets matrix to identity matrix
Definition: DistributedMatrix.cxx:4957
Seldon::DistributedMatrix::operator=
DistributedMatrix< T, Prop, Storage, Allocator > & operator=(const DistributedMatrix< T2, Prop2, Storage2, Allocator2 > &X)
equality *this = X
Definition: DistributedMatrix.cxx:4871
Seldon::DistributedMatrix_Base::MltAddRow
void MltAddRow(const SeldonTranspose &Trans, const Vector< T2, Storage2, Allocator2 > &X, Vector< T4, Storage4, Allocator4 > &Y) const
Y = Y + alpha A^T X with only distant rows of A.
Definition: DistributedMatrix.cxx:1107
Seldon::Vector< int, VectFull >
Seldon::DistributedMatrix_Base::AddRowSumDistant
void AddRowSumDistant(Vector< T0 > &vec_sum) const
Adds \sum |a_ij| to vec_sum(i) for distant non-zero entries.
Definition: DistributedMatrix.cxx:2800
Seldon::DistributedMatrix::AddRowDistantInteraction
void AddRowDistantInteraction(int iglob, int j, int proc, const T &val)
Adds val for global row iglob and local column j (proc owns the row)
Definition: DistributedMatrixInline.cxx:250
Seldon::DistributedMatrix_Base::ConvertToCSC
static void ConvertToCSC(Matrix< T, General, ArrayColSparse > &B, IVect &OverlappedCol, Vector< Tint0 > &PtrA, Vector< Tint1 > &IndA, Vector< T > &ValA)
Fills PtrA, IndA and ValA from values contained in B.
Definition: DistributedMatrix.cxx:4528
Seldon::DistributedMatrix_Base::ReallocateDist
void ReallocateDist(int m, int n)
changing the size of the local matrix, previous values are lost
Definition: DistributedMatrix.cxx:1884
Seldon::DistributedMatrix::Write
void Write(string FileName) const
writes the matrix in binary format
Definition: DistributedMatrix.cxx:5023
Seldon::DistributedMatrix::FillRand
void FillRand()
sets values of non-zero entries to random values
Definition: DistributedMatrix.cxx:5014
Seldon::DistributedMatrix_Base::AddColSumDistant
void AddColSumDistant(Vector< T0 > &vec_sum) const
Adds \sum |a_ij| to vec_sum(j) for distant non-zero entries.
Definition: DistributedMatrix.cxx:2824
Seldon::DistributedMatrix_Base::GetDistantRowSize
int GetDistantRowSize(int i) const
returns the number of distant non-zero entries for the local column i
Definition: DistributedMatrixInline.cxx:200
Seldon::DistributedMatrix_Base::InitMltMin
void InitMltMin(Vector< int > &Y, Vector< int > &Yproc, Vector< int > &Xcol, Vector< int > &Xcol_proc) const
Initializes the matrix-vector product MltMin
Definition: DistributedMatrix.cxx:2621
Seldon::DistributedMatrix_Base::OverlapRowNumbers
IVect * OverlapRowNumbers
row numbers shared with other processors
Definition: DistributedMatrix.hxx:114
Seldon::DistributedMatrix_Base::nodl_scalar_
int nodl_scalar_
number of "scalar" unknowns
Definition: DistributedMatrix.hxx:138
Seldon::DistributedMatrix_Base::comm_
MPI_Comm comm_
MPI communicator.
Definition: DistributedMatrix.hxx:144
Seldon::DistributedMatrix_Base::GetMemorySize
size_t GetMemorySize() const
returns the size of memory used to store the matrix
Definition: DistributedMatrix.cxx:2162
Seldon::DistributedMatrix_Base::GetColSumDistantRow
void GetColSumDistantRow(Vector< T0 > &vec_sum) const
adds contribution of dist_row for GetColSum
Definition: DistributedMatrix.cxx:936
Seldon::DistributedMatrix::RemoveSmallEntry
void RemoveSmallEntry(const T0 &epsilon)
removes small entries of the matrix
Definition: DistributedMatrix.cxx:4945
Seldon::DistributedMatrix_Base::IndexGlobalCol
int IndexGlobalCol(int i, int j) const
returns the global column number of distant non-zero entry j for the local row i
Definition: DistributedMatrixInline.cxx:173
Seldon::DistributedMatrix_Base::GetOverlapRowNumber
IVect & GetOverlapRowNumber()
returns rows already counted in another processor
Definition: DistributedMatrix.cxx:2044
Seldon::Matrix
Definition: SeldonHeader.hxx:226
Seldon::DistributedMatrix_Base::GetDistantColSize
int GetDistantColSize(int i) const
returns the number of distant non-zero entries for the local row i
Definition: DistributedMatrixInline.cxx:165
Seldon::DistributedMatrix_Base::AssembleVec
void AssembleVec(Vector< T2 > &) const
assembles the vector (adds values of shared rows)
Definition: DistributedMatrix.cxx:1050
Seldon::DistributedMatrix_Base::GetDistributedRows
void GetDistributedRows(Matrix< T0, General, ArrayRowSparse, Allocator0 > &rows, Vector< IVect > &proc, bool sym) const
grouping all the local rows of the matrix into CSR form
Definition: DistributedMatrix.cxx:4579
Seldon::DistributedMatrix_Base::AddRowDistantInteraction
void AddRowDistantInteraction(int iglob, int j, int proc, const T &val)
adding a non-zero entry, between a local row and a non-local row
Definition: DistributedMatrixInline.cxx:118
Seldon::DistributedMatrix_Base::ScatterValues
void ScatterValues(const Vector< T2 > &X, const IVect &num_recv, const IVect &, const IVect &proc_recv, const Vector< IVect > &num_send, const IVect &proc_send, Vector< T2 > &Xcol) const
internal function
Definition: DistributedMatrix.cxx:642
Seldon::DistributedMatrix_Base::GetNonZeros
long GetNonZeros() const
returns the number of non-zero entries stored in the matrix
Definition: DistributedMatrix.cxx:2207
Seldon::CopyReal
void CopyReal(const DistributedMatrix< T1, Prop1, Storage1, Allocator1 > &A, DistributedMatrix< T2, Prop2, Storage2, Allocator2 > &B)
extracts real part of a matrix
Definition: DistributedMatrix.cxx:5977
Seldon::DistributedMatrix::ReadText
void ReadText(string FileName, bool cplx=false)
reads the matrix in text format
Definition: DistributedMatrix.cxx:5136
Seldon::NewAlloc
Definition: Allocator.hxx:91
Seldon::DistributedMatrix_Base::ValueDistantCol
const T & ValueDistantCol(int i, int j) const
returns the value of distant non-zero entry j for the local row i
Definition: DistributedMatrixInline.cxx:192
Seldon::DistributedMatrix_Base::GetGlobalRowNumber
IVect & GetGlobalRowNumber()
returns local to global numbering
Definition: DistributedMatrix.cxx:2014
Seldon::DistributedMatrixIntegerArray
class storing arrays needed for a distributed matrix
Definition: DistributedMatrix.hxx:26
Seldon::DistributedMatrix_Base::GetSharingRowNumbers
Vector< IVect > & GetSharingRowNumbers()
returns row numbers for each set of shared rows
Definition: DistributedMatrix.cxx:2133
Seldon::DistributedMatrix_Base::GetGlobalM
int GetGlobalM() const
returns the global number of rows
Definition: DistributedMatrixInline.cxx:66
Seldon::VectFull
Definition: StorageInline.cxx:74
Seldon::DistributedMatrix_Base::GetDataSize
long GetDataSize() const
returns the number of elements stored
Definition: DistributedMatrix.cxx:2228
Seldon::DistributedMatrix_Base::CopySubDistant
void CopySubDistant(const DistributedMatrix_Base< T1 > &A, const IVect &row, const IVect &col, bool sym)
Copies A(row, col) to the current matrix.
Definition: DistributedMatrix.cxx:3150
Seldon::DistributedMatrix_Base::AssembleValues
void AssembleValues(const Vector< T2 > &Xcol, const IVect &num_recv, const IVect &, const IVect &proc_recv, const Vector< IVect > &num_send, const IVect &proc_send, Vector< T2 > &X) const
internal function
Definition: DistributedMatrix.cxx:701
Seldon::DistributedMatrix_Base
Base class for distributed matrix over all the processors.
Definition: DistributedMatrix.hxx:103
Seldon::DistributedMatrix::Resize
void Resize(int m, int n)
changing the size of the local matrix, previous values are kept
Definition: DistributedMatrix.cxx:4842
Seldon::DistributedMatrix_Base::ProcSharingRows
IVect * ProcSharingRows
list of processors sharing rows with the current one
Definition: DistributedMatrix.hxx:127
Seldon::DistributedMatrix_Base::SameDistributedRows
bool SameDistributedRows(const DistributedMatrix_Base< T > &A)
returns true if the distributed rows of A coincide with the distributed rows of the current matrix
Definition: DistributedMatrix.cxx:3268
Seldon::DistributedMatrix::Fill
void Fill()
sets values of non-zero entries to 0, 1, 2, etc
Definition: DistributedMatrix.cxx:4991
Seldon::DistributedMatrix_Base::SwitchToGlobalNumbers
void SwitchToGlobalNumbers()
erases informations for matrix-vector product and reverts dist_row/dist_col to global numbers
Definition: DistributedMatrix.cxx:425
Seldon::DistributedMatrix_Base::RemoveSmallEntry
void RemoveSmallEntry(const T0 &epsilon)
removes small entries of the matrix
Definition: DistributedMatrix.cxx:2268
Seldon::Conjugate
void Conjugate(Matrix< T, Prop, Storage, Allocator > &A)
A is replaced by its conjugate.
Definition: Functions_Matrix.cxx:2915
Seldon::DistributedMatrix_Base::SortAndAssembleDistantInteractions
void SortAndAssembleDistantInteractions(TypeDist &dist_val, Vector< IVect > &dist_proc, IVect &glob_num, IVect &ptr_glob_num, IVect &proc_glob, Vector< IVect > &local_num, IVect &proc_local)
changes global numbers in proc_row to local numbers
Definition: DistributedMatrix.cxx:470
Seldon::DistributedMatrix_Base::ScatterColValues
void ScatterColValues(const Vector< T2 > &X, Vector< T2 > &Xcol) const
Sends/receives values of X on distant columns.
Definition: DistributedMatrix.cxx:1012
Seldon::DistributedMatrix::GetDistributedRows
void GetDistributedRows(Matrix< T0, General, ArrayRowSparse, Allocator0 > &rows, Vector< IVect > &proc) const
grouping all the local rows of the matrix into CSR form
Definition: DistributedMatrix.cxx:5172
Seldon::DistributedMatrix_Base::Fill
void Fill()
sets values of non-zero entries to 0, 1, 2, etc
Definition: DistributedMatrix.cxx:2313
Seldon::DistributedMatrix::Reallocate
void Reallocate(int m, int n)
changing the size of the local matrix, previous values are lost
Definition: DistributedMatrix.cxx:4832
Seldon::DistributedMatrix_Base::local_number_distant_values
bool local_number_distant_values
if true local numbers are present in dist_row/dist_col instead of global numbers
Definition: DistributedMatrix.hxx:170
Seldon::DistributedMatrix_Base::Copy
void Copy(const DistributedMatrix_Base< T2 > &X)
Copies content of X in the current object.
Definition: DistributedMatrix.cxx:1952
Seldon::DistributedMatrix_Base::GetProcessorSharingRows
IVect & GetProcessorSharingRows()
returns processor numbers for each set of shared rows
Definition: DistributedMatrix.cxx:2103
Seldon::DistributedMatrix_Base::AssembleColValues
void AssembleColValues(const Vector< T2 > &Xrow, Vector< T2 > &X) const
Sends/receives values of Xcol on distant columns and adds them to X.
Definition: DistributedMatrix.cxx:1039
Seldon::DistributedMatrix_Base::FinalizeMltMin
void FinalizeMltMin(Vector< int > &Y, Vector< int > &Yproc, Vector< int > &Xcol, Vector< int > &Xcol_proc) const
Finalizes the matrix-vector product MltMin.
Definition: DistributedMatrix.cxx:2646
Seldon::DistributedMatrix_Base::RemoveSmallEntryDistant
void RemoveSmallEntryDistant(const T0 &, TypeDist &, Vector< IVect > &)
removes non-zero entries contained in dist_vec below epsilon dist_proc is modified in the same way
Definition: DistributedMatrix.cxx:848
Seldon::DistributedMatrix_Base::AssembleRowValues
void AssembleRowValues(const Vector< T2 > &Xrow, Vector< T2 > &X) const
Sends/receives values of Xrow on distant rows and adds them to X.
Definition: DistributedMatrix.cxx:1028
Seldon::DistributedMatrix_Base::FinalizeMltAdd
void FinalizeMltAdd(bool proceed_distant_row, bool proceed_distant_col, const Vector< T2 > &X, Vector< T2 > &Xcol, const T3 &alpha, const T3 &beta, Vector< T4, Storage4, Allocator4 > &Y, Vector< T4, Storage4, Allocator4 > &Yres, bool assemble) const
Finalizes the matrix-vector product.
Definition: DistributedMatrix.cxx:2486
Seldon::DistributedMatrix_Base::GlobalRowNumbers
IVect * GlobalRowNumbers
global row numbers
Definition: DistributedMatrix.hxx:124
Seldon::DistributedMatrix_Base::WriteText
void WriteText(ostream &FileStream, Vector< int > &Indow, Vector< int > &IndCol, Vector< T > &Value, bool cplx) const
writes the matrix in text format
Definition: DistributedMatrix.cxx:2363
Seldon::MltMatrix
void MltMatrix(const Matrix< T0, Prop0, RowSparse, Allocator0 > &A, const Matrix< T1, Prop1, RowSparse, Allocator1 > &B, Matrix< T2, Prop2, RowSparse, Allocator2 > &C)
Multiplies two row-major sparse matrices in Harwell-Boeing format.
Definition: Functions_Matrix.cxx:207
Seldon::DistributedMatrix_Base::GetColSumDistantCol
void GetColSumDistantCol(Vector< T0 > &vec_sum) const
adds contribution of dist_col for GetColSum
Definition: DistributedMatrix.cxx:917
Seldon::DistributedMatrix_Base::GetMaxDataSizeDistantRow
long GetMaxDataSizeDistantRow() const
returns the maximum number of values in dist_row to exchange
Definition: DistributedMatrixInline.cxx:140
Seldon::DistributedMatrix_Base::EraseRowDistant
void EraseRowDistant(const IVect &num, bool sym)
erases rows num(i)
Definition: DistributedMatrix.cxx:3116
Seldon::General
Definition: Properties.hxx:26
Seldon::DistributedMatrix_Base::local_row_to_send
Vector< IVect > local_row_to_send
local row/col numbers (needed for MltAdd)
Definition: DistributedMatrix.hxx:162
Seldon::DistributedMatrix_Base::ScaleLeftDistant
void ScaleLeftDistant(const Vector< T0 > &Drow)
Multiplies a_ij by Drow(i) for distant non-zero entries.
Definition: DistributedMatrix.cxx:2977
Seldon::DistributedMatrix_Base::proc_col
Vector< IVect > proc_col
distant processor for additional values
Definition: DistributedMatrix.hxx:155
Seldon::DistributedMatrix_Base::size_max_distant_row
long size_max_distant_row
number of distant non-zero entries
Definition: DistributedMatrix.hxx:173
Seldon::DistributedMatrix_Base::GetNodlScalar
int GetNodlScalar() const
returns the number of scalar unknowns
Definition: DistributedMatrixInline.cxx:74
Seldon::DistributedMatrix_Base::EraseColDistant
void EraseColDistant(const IVect &num, bool sym)
erases columns num(i)
Definition: DistributedMatrix.cxx:3083
Seldon::DistributedMatrix_Base::GetRowSumDistantRow
void GetRowSumDistantRow(Vector< T0 > &vec_sum) const
adds contribution of dist_row for GetRowSum
Definition: DistributedMatrix.cxx:898
Seldon::DistributedMatrix::WriteText
void WriteText(string FileName, bool cplx=false) const
writes the matrix in text format
Definition: DistributedMatrix.cxx:5053
Seldon::DistributedMatrix::GetMemorySize
size_t GetMemorySize() const
returns the size of memory used to store the matrix
Definition: DistributedMatrix.cxx:4897
Seldon::DistributedMatrix_Base::AssembleParallel
void AssembleParallel(Matrix< T, General, ArrayRowSparse > &B, Vector< IVect > &procB, Symmetric &sym, IVect &row_numbers, IVect &local_row_numbers, IVect &OverlappedCol, bool sym_pattern, bool reorder)
Method called by AssembleDistributed.
Definition: DistributedMatrix.cxx:3318
Seldon::DistributedMatrix_Base::SetIdentity
void SetIdentity()
sets matrix to identity matrix
Definition: DistributedMatrix.cxx:2277
Seldon::DistributedMatrix_Base::TransposeDistant
void TransposeDistant(const DistributedMatrix_Base< T > &A)
Computes *this = A^T for non-zero entries.
Definition: DistributedMatrix.cxx:2945
Seldon::DistributedMatrix::ClearLocal
void ClearLocal()
Clears the local matrix.
Definition: DistributedMatrix.cxx:4860
Seldon::ArrayRowSymComplexSparse
Definition: Storage.hxx:450
Seldon::DistributedMatrix_Base::Resize
void Resize(int m, int n)
changing the size of the local matrix, previous values are kept
Definition: DistributedMatrix.cxx:1898
Seldon::DistributedMatrix_Base::ScaleRightDistant
void ScaleRightDistant(const Vector< T0 > &Dcol)
Multiplies a_ij by Dcol(j) for distant non-zero entries.
Definition: DistributedMatrix.cxx:3008
Seldon::DistributedMatrix_Base::operator=
DistributedMatrix_Base< T > & operator=(const DistributedMatrix_Base< T > &X)
equality *this = X
Definition: DistributedMatrix.cxx:1942
Seldon::NormInf
ClassComplexType< T >::Treal NormInf(const Matrix< T, Prop, Storage, Allocator > &A)
Returns the infinity-norm of a matrix.
Definition: Functions_Matrix.cxx:2435
Seldon::DistributedMatrix_Base::ScatterRowValues
void ScatterRowValues(const Vector< T2 > &X, Vector< T2 > &Xcol) const
Sends/receives values of X on distant rows (similar to ScatterColValues)
Definition: DistributedMatrix.cxx:997
Seldon::Transpose
void Transpose(Matrix< T, Prop, Storage, Allocator > &A)
Matrix transposition.
Definition: Functions_Matrix.cxx:2699
Seldon::DistributedMatrix::GetNonZeros
long GetNonZeros() const
returns the number of non-zero entries stored in the matrix
Definition: DistributedMatrix.cxx:4912
Seldon::DistributedMatrix_Base::SendAndReceiveDistributed
static void SendAndReceiveDistributed(const MPI_Comm &comm, IVect &nsend_int, Vector< IVect > &EntierToSend, Vector< Vector< T > > &FloatToSend, IVect &nrecv_int, Vector< IVect > &EntierToRecv, Vector< Vector< T > > &FloatToRecv)
Sends EntierToSend and FloatToSend to the required processors.
Definition: DistributedMatrix.cxx:1219
Seldon::DistributedMatrix_Base::ConjugateDistant
void ConjugateDistant()
Conjugates distant non-zero entries.
Definition: DistributedMatrix.cxx:2926
Seldon::DistributedMatrix
matrix distributed over all the processors
Definition: DistributedMatrix.hxx:506
Seldon::DistributedMatrix::GetDataSize
long GetDataSize() const
returns the number of elements stored
Definition: DistributedMatrix.cxx:4928
Seldon::DistributedMatrix_Base::OverlapProcNumbers
IVect * OverlapProcNumbers
processor where each shared row should be assembled
Definition: DistributedMatrix.hxx:121
Seldon::DistributedMatrix_Base::ProcessorDistantRow
int ProcessorDistantRow(int i, int j) const
returns the processor associated with distant non-zero entry j for the local column i
Definition: DistributedMatrixInline.cxx:219
Seldon::DistributedMatrix_Base::GetLocalM
int GetLocalM() const
returns the local number of rows
Definition: DistributedMatrixInline.cxx:50
Seldon::DistributedMatrix_Base::nglob_
int nglob_
total number of rows (on all processors)
Definition: DistributedMatrix.hxx:141
Seldon::VectSparse
Definition: StorageInline.cxx:79
Seldon::DistributedMatrix_Base::SharingRowNumbers
Vector< IVect > * SharingRowNumbers
for each processor sharing rows, list of "local numbers" shared
Definition: DistributedMatrix.hxx:135
Seldon::DistributedMatrix::Zero
void Zero()
sets values of non-zero entries to 0
Definition: DistributedMatrix.cxx:4978
Seldon::DistributedMatrix_Base::EraseDistantEntries
static void EraseDistantEntries(MPI_Comm &comm, const Vector< bool > &IsRowDropped, const Vector< bool > &IsRowDroppedDistant, TypeDist &dist_row_, Vector< IVect > &proc_row_, TypeDist &dist_col_, Vector< IVect > &proc_col_)
clears distant numbers in a sparse matrix
Definition: DistributedMatrix.cxx:1639
Seldon::DistributedMatrix_Base::GetOverlapProcNumber
IVect & GetOverlapProcNumber()
returns processor numbers of the original rows
Definition: DistributedMatrix.cxx:2073
Seldon::DistributedMatrix_Base::ExchangeParallelData
void ExchangeParallelData(int &smax_row, int &smax_col, bool &local_number, Vector< Vector< T, VectSparse >, VectFull, NewAlloc< Vector< T, VectSparse > > > &dist_row_, Vector< Vector< T, VectSparse >, VectFull, NewAlloc< Vector< T, VectSparse > > > &dist_col_, Vector< IVect > &proc_row_, Vector< IVect > &proc_col_, IVect &global_row_to_recv_, IVect &global_col_to_recv_, IVect &ptr_global_row_to_recv_, IVect &ptr_global_col_to_recv_, Vector< IVect > &local_row_to_send_, Vector< IVect > &local_col_to_send_, IVect &proc_row_to_recv_, IVect &proc_col_to_recv_, IVect &proc_row_to_send_, IVect &proc_col_to_send_)
Swaps arrays contained in the current structure with arrays given as parameters.
Definition: DistributedMatrix.cxx:2878
Seldon::Symmetric
Definition: Properties.hxx:30
Seldon::MaxAbs
ClassComplexType< T >::Treal MaxAbs(const Matrix< T, Prop, Storage, Allocator > &A)
Returns the maximum (in absolute value) of a matrix.
Definition: Functions_Matrix.cxx:2386
Seldon::SorVector
void SorVector(const Matrix< T0, Prop0, Storage0, Allocator0 > &M, Vector< T2, Storage2, Allocator2 > &Y, const Vector< T1, Storage1, Allocator1 > &X, const T3 &omega, int iter, int type_ssor)
Solve M Y = X with S.O.R. method.
Definition: Functions_MatVect.cxx:1638
Seldon::DistributedMatrix_Base::proc_col_to_recv
IVect proc_col_to_recv
processor numbers (needed for MltAdd)
Definition: DistributedMatrix.hxx:165
Seldon::DistributedMatrix_Base::ScaleDistant
void ScaleDistant(const Vector< T0 > &Drow, const Vector< T1 > &Dcol)
Multiplies a_ij by Drow(i) Dcol(i) for distant non-zero entries.
Definition: DistributedMatrix.cxx:3040
Seldon::ArrayRowSparse
Definition: Storage.hxx:124
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::MltAddMatrix
void MltAddMatrix(const T0 &alpha, const Matrix< T1, Prop1, Storage1, Allocator1 > &A, const Matrix< T2, Prop2, Storage2, Allocator2 > &B, const T3 &beta, Matrix< T4, Prop4, Storage4, Allocator4 > &C)
Multiplies two matrices, and adds the result to a third matrix.
Definition: Functions_Matrix.cxx:617
Seldon::DistributedMatrix_Base::dist_row
Vector< Vector< T, VectSparse >, VectFull, NewAlloc< Vector< T, VectSparse > > > dist_row
additional values on columns with non-local rows
Definition: DistributedMatrix.hxx:152
Seldon::DistributedMatrix::AddDistantInteraction
void AddDistantInteraction(int i, int jglob, int proc, const T &val)
Adds val for local row i and global column jglob (proc owns this column)
Definition: DistributedMatrixInline.cxx:241
Seldon::DistributedMatrix_Base::ProcessorDistantCol
int ProcessorDistantCol(int i, int j) const
returns the processor associated with distant non-zero entry j for the local row i
Definition: DistributedMatrixInline.cxx:184
Seldon::DistributedMatrix_Base::GetMaxAbsDistant
void GetMaxAbsDistant(typename ClassComplexType< T >::Treal &res) const
Computes res = max(res, maximum absolute value of non-zero entries)
Definition: DistributedMatrix.cxx:2774
Seldon::AddMatrix
void AddMatrix(const T0 &alpha, const Matrix< T1, Prop1, Storage1, Allocator1 > &A, Matrix< T2, Prop2, Storage2, Allocator2 > &B)
Adds two matrices.
Definition: Functions_Matrix.cxx:1619
Seldon::DistributedMatrix_Base::AssembleVecMin
void AssembleVecMin(Vector< int > &X, Vector< int > &Xproc) const
assembles the vector (by taking the minimum instead of summing for AssembleVec
Definition: DistributedMatrix.cxx:837
Seldon::DistributedMatrix_Base::GetCommunicator
MPI_Comm & GetCommunicator()
returns MPI communicator (processors that will share the matrix)
Definition: DistributedMatrixInline.cxx:34
Seldon::DistributedMatrix_Base::ValueDistantRow
const T & ValueDistantRow(int i, int j) const
returns the value of distant non-zero entry j for the local column i
Definition: DistributedMatrixInline.cxx:227
Seldon::DistributedMatrix_Base::SetReadyForMltAdd
void SetReadyForMltAdd(bool all_zero=true)
tells that there are no distant rows (mltadd ready)
Definition: DistributedMatrixInline.cxx:157
Seldon::DistributedMatrix_Base::operator*=
DistributedMatrix_Base< T > & operator*=(const T0 &x)
multiplication by a scalar
Definition: DistributedMatrix.cxx:1999
Seldon::DistributedMatrix_Base::IsReadyForMltAdd
bool IsReadyForMltAdd() const
returns true if the matrix is ready to perform a matrix-vector product
Definition: DistributedMatrixInline.cxx:149
Seldon::DistributedMatrix_Base::AddReceivedInteractions
static void AddReceivedInteractions(const MPI_Comm &comm, Matrix< T, General, ArrayRowSparse > &B, Vector< IVect > &EntierToRecv, Vector< Vector< T > > &FloatToRecv, IVect &nrecv_int, Vector< IVect > &EntierToSend, Vector< Vector< T > > &FloatToSend, IVect &nsend_int, IVect &Glob_to_local, const IVect &OverlappedCol, const IVect &OverlapProcNumber, Vector< IVect > &procB, bool reorder)
Adds received non-zero entries to the matrix B.
Definition: DistributedMatrix.cxx:1313
Seldon::DistributedMatrix_Base::IndexGlobalRow
int IndexGlobalRow(int i, int j) const
returns the global row number of distant non-zero entry j for the local column i
Definition: DistributedMatrixInline.cxx:208
Seldon::DistributedMatrix_Base::AddDistantValue
static void AddDistantValue(Vector< T, VectSparse > &dist_col_, IVect &proc_col_, int jglob, int proc2, const T &val)
adding a non-zero entry, between a local row/column and a non-local row/column
Definition: DistributedMatrix.cxx:1164
Seldon::DistributedMatrix_Base::MltAddCol
void MltAddCol(const SeldonTranspose &Trans, const Vector< T2, Storage2, Allocator2 > &X, Vector< T4, Storage4, Allocator4 > &Y) const
Y = Y + alpha A X with only distant columns of A.
Definition: DistributedMatrix.cxx:1062
Seldon::DistributedMatrix_Base::AddDistantInteraction
void AddDistantInteraction(int i, int jglob, int proc, const T &val)
adding a non-zero entry, between a local column and a non-local column
Definition: DistributedMatrixInline.cxx:99
Seldon::DistributedMatrix_Base::GetMaxDataSizeDistantCol
long GetMaxDataSizeDistantCol() const
returns the maximum number of values in dist_col to exchange
Definition: DistributedMatrixInline.cxx:131