20 #ifndef SELDON_FILE_DISTRIBUTED_MATRIX_HXX
29 #ifdef SELDON_WITH_MPI
35 IVect OverlapRowNumbers;
42 IVect OverlapProcNumbers;
45 IVect GlobalRowNumbers;
48 IVect ProcSharingRows;
59 int nodl_scalar, nb_unknowns_scal;
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,
77 static int ConstructArrays(
IVect& row_num,
IVect& overlap_num,
IVect& proc_num,
84 const MPI_Comm& comm,
bool distribute_row =
true);
159 IVect ptr_global_row_to_recv, ptr_global_col_to_recv;
166 proc_row_to_recv, proc_row_to_send;
179 template<
class TypeDist>
201 const IVect& num_recv,
const IVect& ptr_num_recv,
202 const IVect& proc_recv,
204 const IVect& proc_send,
209 template<
class T0,
class TypeDist>
238 template<
class T2,
class Storage2,
class Allocator2,
239 class T4,
class Storage4,
class Allocator4>
244 template<
class T2,
class Storage2,
class Allocator2,
245 class T4,
class Storage4,
class Allocator4>
253 int jglob,
int proc2,
const T& val);
264 IVect& Glob_to_local,
const IVect& OverlappedCol,
265 const IVect& OverlapProcNumber,
272 IVect& Glob_to_local,
const IVect& OverlappedCol,
273 const IVect& OverlapProcNumber,
276 template<
class TypeDist>
330 bool distribute_row =
true);
337 void Resize(
int m,
int n);
375 void Fill(
const T0& x);
383 template<
class T2,
class T3,
class T4,
class Storage4,
class Allocator4>
384 void InitMltAdd(
bool& proceed_distant_row,
bool& proceed_distant_col,
389 template<
class T2,
class T3,
class T4,
class Storage4,
class Allocator4>
390 void FinalizeMltAdd(
bool proceed_distant_row,
bool proceed_distant_col,
395 template<
class T2,
class T3,
class T4,
class Storage4,
class Allocator4>
396 void InitMltAdd(
bool& proceed_distant_row,
bool& proceed_distant_col,
401 template<
class T2,
class T3,
class T4,
class Storage4,
class Allocator4>
402 void FinalizeMltAdd(
bool proceed_distant_row,
bool proceed_distant_col,
414 template<
class T0,
class T1>
435 IVect& global_row_to_recv_,
IVect& global_col_to_recv_,
436 IVect& ptr_global_row_to_recv_,
IVect& ptr_global_col_to_recv_,
438 IVect& proc_row_to_recv_,
IVect& proc_col_to_recv_,
439 IVect& proc_row_to_send_,
IVect& proc_col_to_send_);
450 template<
class T0,
class T1>
458 const IVect& row,
const IVect& col,
bool sym);
465 IVect& OverlappedCol,
bool sym_pattern,
bool reorder);
467 template<
class T
int0,
class T
int1>
473 IVect& OverlappedCol,
bool sym_pattern,
bool reorder);
475 template<
class T
int0,
class T
int1>
479 template<
class T0,
class Allocator0>
484 template<
class T0,
class Allocator0>
504 template<
class T,
class Prop,
class Storage,
class Allocator
505 =
typename SeldonDefaultAllocator<Storage, T>::allocator>
509 template<
class T0,
class Prop0,
class Storage0,
class Allocator0>
526 void Resize(
int m,
int n);
531 template<
class T2,
class Prop2,
class Storage2,
class Allocator2>
552 void Fill(
const T0& x);
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);
566 template<
class T0,
class Allocator0>
571 template<
class T0,
class Allocator0>
576 #ifdef SELDON_WITH_VIRTUAL
578 typedef typename ClassComplexType<T>::Treal Treal;
579 typedef typename ClassComplexType<T>::Tcplx Tcplx;
582 const typename ClassComplexType<T>::Treal& omega,
583 int nb_iter,
int stage_ssor)
const;
586 const typename ClassComplexType<T>::Treal& omega,
587 int nb_iter,
int stage_ssor)
const;
589 virtual void MltAddVector(
const Treal& alpha,
const Vector<Treal>& x,
592 virtual void MltAddVector(
const Tcplx& alpha,
const Vector<Tcplx>& x,
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,
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,
636 template <
class T0,
class Prop0,
class Storage0,
class Allocator0,
637 class T1,
class Storage1,
class Allocator1,
638 class T2,
class Storage2,
class Allocator2>
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,
651 template <
class T1,
class Prop1,
class Storage1,
class Allocator1,
652 class T2,
class Storage2,
class Allocator2,
653 class T3,
class Storage3,
class Allocator3>
659 template<
class T0,
class T1,
class Prop1,
class Storage1,
class Allocator1>
663 template<
class T1,
class Prop1,
class Allocator1>
667 template<
class T1,
class Prop1,
class Allocator1>
671 #ifdef SELDON_FILE_MATRIX_ARRAY_COMPLEX_SPARSE_HXX
672 template<
class T1,
class Prop1,
class Allocator1>
676 template<
class T1,
class Prop1,
class Allocator1>
677 void MltMin(
const Matrix<T1, Prop1,
682 template<
class T1,
class Prop1,
class Storage1,
class Allocator1>
688 template<
class T0,
class T1,
class Prop1,
class Storage1,
class Allocator1,
689 class T2,
class Prop2,
class Storage2,
class Allocator2>
694 template<
class T1,
class Prop1,
class Storage1,
class Allocator1>
695 typename ClassComplexType<T1>::Treal
698 template<
class T0,
class T,
class Prop,
class Storage,
class Allocator>
702 template<
class T0,
class T,
class Prop,
class Storage,
class Allocator>
706 template<
class T0,
class T,
class Prop,
class Storage,
class Allocator>
711 template<
class T1,
class Prop1,
class Storage1,
class Allocator1>
712 typename ClassComplexType<T1>::Treal
715 template<
class T1,
class Prop1,
class Storage1,
class Allocator1>
716 typename ClassComplexType<T1>::Treal
719 template<
class T1,
class Prop1,
class Storage1,
class Allocator1>
722 template<
class T1,
class Prop1,
class Storage1,
class Allocator1>
725 template<
class T1,
class Prop1,
class Storage1,
class Allocator1>
729 template<
class T,
class Prop,
class Storage,
class Allocator>
731 Storage, Allocator>& A,
734 template<
class T,
class Prop,
class Storage,
class Allocator>
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>
747 class T1,
class Prop1,
class Storage1,
class Allocator1,
748 class T2,
class Prop2,
class Storage2,
class Allocator2,
750 class T4,
class Prop4,
class Storage4,
class Allocator4>
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>
769 template<
class T0,
class Prop0,
class Storage0,
class Allocator0,
770 class T1,
class Allocator1>
774 template<
class T0,
class Prop0,
class Storage0,
class Allocator0,
775 class T1,
class Allocator1>
779 template<
class T0,
class Prop0,
class Storage0,
class Allocator0,
780 class T1,
class Allocator1>
784 template<
class T0,
class Prop0,
class Storage0,
class Allocator0,
785 class T1,
class Allocator1>
789 template<
class T,
class Prop,
class Storage,
class Allocator>
794 template<
class T,
class Prop,
class Storage,
class Allocator>
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);
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>
815 const T3& omega,
int iter,
int type_ssor = 3);
817 template<
class T1,
class Prop,
class Storage,
class Allocator,
818 class T2,
class Allocator2,
class Allocator3>
820 const IVect& col_number,
824 template<
class T,
class Prop1,
class Storage1,
class Allocator1,
825 class Prop2,
class Storage2,
class Allocator2>
829 template<
class T,
class Prop1,
class Storage1,
class Allocator1,
830 class Prop2,
class Storage2,
class Allocator2>
834 template<
class T,
class Prop1,
class Storage1,
class Allocator1,
835 class Prop2,
class Storage2,
class Allocator2>
839 template<
class T1,
class Prop1,
class Storage1,
class Allocator1,
840 class T2,
class Prop2,
class Storage2,
class Allocator2>
845 template<
class T,
class Prop,
class Storage,
class Allocator>
846 typename ClassComplexType<T>::Treal
849 template<
class T,
class Storage,
class Allocator,
850 class T1,
class Allocator1>
854 template<
class T,
class Storage,
class Allocator,
855 class T1,
class Allocator1>
859 template<
class T,
class Prop,
class Storage,
class Allocator,
860 class T1,
class Allocator1,
class T2,
class Allocator2>
865 template<
class Prop,
class Storage,
class Alloc,
class T
int0,
class T
int1,
class T>
870 Vector<T>& ValA,
bool sym_pattern,
bool reorder =
false);
872 template<
class Prop,
class Storage,
class Alloc,
class T
int0,
class T
int1,
class T>
874 General& prop,
const MPI_Comm& comm,
877 Vector<T>& ValA,
bool sym_pattern,
bool reorder =
false);
879 template<
class TypeDist>
880 void EraseDistantEntries(MPI_Comm& comm,
const Vector<bool>& IsRowDropped,
885 template<
class T1,
class Prop1,
class Storage1,
class Allocator1>
886 void EraseCol(
const IVect& num,
889 template<
class T1,
class Prop1,
class Storage1,
class Allocator1>
890 void EraseRow(
const IVect& num,
893 template<
class T0,
class Prop0,
class Storage0,
class Allocator0,
894 class T1,
class Prop1,
class Storage1,
class Allocator1>
905 template<
class T,
class Prop,
class Storage,
class Allocator>
906 void Mlt(
const T& alpha,
909 template<
class T,
class Prop,
class Storage,
class Allocator>
910 void Mlt(
const T& alpha,
914 class Prop1,
class Storage1,
class Allocator1,
915 class Prop2,
class Storage2,
class Allocator2>
916 void Add(
const T& alpha,
921 class Prop1,
class Storage1,
class Allocator1,
922 class Prop2,
class Storage2,
class Allocator2>
923 void Add(
const complex<T>& alpha,
928 class Prop1,
class Storage1,
class Allocator1,
929 class Prop2,
class Storage2,
class Allocator2>
930 void Add(
const T& alpha,
935 class Prop1,
class Storage1,
class Allocator1,
936 class Prop2,
class Storage2,
class Allocator2>
937 void Add(
const T& alpha,
941 template<
class T0,
class Prop0,
class Storage0,
class Allocator0>
945 template<
class T0,
class Prop0,
class Storage0,
class Allocator0>
948 bool assemble =
true);
950 template<
class T0,
class Prop0,
class Storage0,
class Allocator0>
954 template<
class T0,
class Prop0,
class Storage0,
class Allocator0>
959 template<
class T0,
class Prop0,
class Storage0,
class Allocator0>
963 bool assemble =
true);
965 template<
class T0,
class Prop0,
class Storage0,
class Allocator0>
970 template<
class T0,
class Prop0,
class Storage0,
class Allocator0>
971 void MltAdd(
const T0& alpha,
974 bool assemble =
true);
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);
982 template<
class T0,
class Prop0,
class Storage0,
class Allocator0>
983 void MltAdd(
const T0& alpha,
987 template<
class T0,
class Prop0,
class Storage0,
class Allocator0>
992 template<
class T0,
class Prop0,
class Storage0,
class Allocator0>
995 const Vector<complex<T0> >& X,
const complex<T0>& beta,
996 Vector<complex<T0> >& Y,
bool assemble =
true);
998 template<
class T0,
class Prop0,
class Storage0,
class Allocator0>
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);
1011 template <
class T,
class Prop0,
class Storage0,
class Allocator0,
1012 class Storage1,
class Allocator1,
1013 class Storage2,
class Allocator2>
1018 const T& omega,
int iter,
int type_ssor = 3);
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);
1028 template <
class T,
class Prop0,
class Storage0,
class Allocator0,
1029 class Storage1,
class Allocator1,
1030 class Storage2,
class Allocator2>
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);
1037 template <
class T,
class Prop0,
class Storage0,
class Allocator0,
1038 class Storage1,
class Allocator1,
1039 class Storage2,
class Allocator2>
1043 const T& omega,
int iter,
int type_ssor = 2);
1045 template <
class T,
class Prop0,
class Storage0,
class Allocator0,
1046 class Storage1,
class Allocator1,
1047 class Storage2,
class Allocator2>
1052 const T& omega,
int iter,
int type_ssor = 3);
1056 #define SELDON_FILE_DISTRIBUTED_MATRIX_HXX
IVect global_row_to_recv
global row/col numbers (needed for MltAdd)
DistributedMatrix< T, Prop, Storage, Allocator > & operator*=(const T0 &x)
multiplication by a scalar
void PrepareMltAdd()
prepares a matrix vector product with the distributed matrix
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
Vector< Vector< T, VectSparse >, VectFull, NewAlloc< Vector< T, VectSparse > > > dist_col
additional values on rows with non-local columns
void EraseArrayForMltAdd()
erases any array used for MltAdd
void TransposeConj(const Matrix< T, Prop, Storage, Allocator > &A, Matrix< T, Prop, Storage, Allocator > &B)
Matrix transposition and conjugation.
int GetLocalN() const
returns the local number of columns
int GetNbScalarUnknowns() const
returns the number of scalar unknowns
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
void Clear()
Clears the matrix.
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
void Zero()
sets values of non-zero entries to 0
void GetRowSumDistantCol(Vector< T0 > &vec_sum) const
adds contribution of dist_col for GetRowSum
void Read(string FileName)
reads the matrix in binary format
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.
void Init(int n, IVect *, IVect *, IVect *, int, int, IVect *, Vector< IVect > *, const MPI_Comm &)
Initialisation of pointers.
void MltScalar(const T0 &alpha, Array3D< T, Allocator > &A)
Multiplication of all elements of a 3D array by a scalar.
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
void AddDistributedMatrix(const T0 &alpha, const DistributedMatrix_Base< T1 > &A)
Adds alpha A to the current matrix (only distant values)
void FillRand()
sets values of non-zero entries to random values
void Clear()
matrix is cleared
ClassComplexType< T >::Treal Norm1(const VectorExpression< T, E > &X)
returns 1-norm of an expression with vectors
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.
void SetIdentity()
sets matrix to identity matrix
DistributedMatrix< T, Prop, Storage, Allocator > & operator=(const DistributedMatrix< T2, Prop2, Storage2, Allocator2 > &X)
equality *this = X
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.
void AddRowSumDistant(Vector< T0 > &vec_sum) const
Adds \sum |a_ij| to vec_sum(i) for distant non-zero entries.
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)
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.
void ReallocateDist(int m, int n)
changing the size of the local matrix, previous values are lost
void Write(string FileName) const
writes the matrix in binary format
void FillRand()
sets values of non-zero entries to random values
void AddColSumDistant(Vector< T0 > &vec_sum) const
Adds \sum |a_ij| to vec_sum(j) for distant non-zero entries.
int GetDistantRowSize(int i) const
returns the number of distant non-zero entries for the local column i
void InitMltMin(Vector< int > &Y, Vector< int > &Yproc, Vector< int > &Xcol, Vector< int > &Xcol_proc) const
Initializes the matrix-vector product MltMin
IVect * OverlapRowNumbers
row numbers shared with other processors
int nodl_scalar_
number of "scalar" unknowns
MPI_Comm comm_
MPI communicator.
size_t GetMemorySize() const
returns the size of memory used to store the matrix
void GetColSumDistantRow(Vector< T0 > &vec_sum) const
adds contribution of dist_row for GetColSum
void RemoveSmallEntry(const T0 &epsilon)
removes small entries of the matrix
int IndexGlobalCol(int i, int j) const
returns the global column number of distant non-zero entry j for the local row i
IVect & GetOverlapRowNumber()
returns rows already counted in another processor
int GetDistantColSize(int i) const
returns the number of distant non-zero entries for the local row i
void AssembleVec(Vector< T2 > &) const
assembles the vector (adds values of shared rows)
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
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
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
long GetNonZeros() const
returns the number of non-zero entries stored in the matrix
void CopyReal(const DistributedMatrix< T1, Prop1, Storage1, Allocator1 > &A, DistributedMatrix< T2, Prop2, Storage2, Allocator2 > &B)
extracts real part of a matrix
void ReadText(string FileName, bool cplx=false)
reads the matrix in text format
const T & ValueDistantCol(int i, int j) const
returns the value of distant non-zero entry j for the local row i
IVect & GetGlobalRowNumber()
returns local to global numbering
class storing arrays needed for a distributed matrix
Vector< IVect > & GetSharingRowNumbers()
returns row numbers for each set of shared rows
int GetGlobalM() const
returns the global number of rows
long GetDataSize() const
returns the number of elements stored
void CopySubDistant(const DistributedMatrix_Base< T1 > &A, const IVect &row, const IVect &col, bool sym)
Copies A(row, col) to the current matrix.
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
Base class for distributed matrix over all the processors.
void Resize(int m, int n)
changing the size of the local matrix, previous values are kept
IVect * ProcSharingRows
list of processors sharing rows with the current one
bool SameDistributedRows(const DistributedMatrix_Base< T > &A)
returns true if the distributed rows of A coincide with the distributed rows of the current matrix
void Fill()
sets values of non-zero entries to 0, 1, 2, etc
void SwitchToGlobalNumbers()
erases informations for matrix-vector product and reverts dist_row/dist_col to global numbers
void RemoveSmallEntry(const T0 &epsilon)
removes small entries of the matrix
void Conjugate(Matrix< T, Prop, Storage, Allocator > &A)
A is replaced by its conjugate.
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
void ScatterColValues(const Vector< T2 > &X, Vector< T2 > &Xcol) const
Sends/receives values of X on distant columns.
void GetDistributedRows(Matrix< T0, General, ArrayRowSparse, Allocator0 > &rows, Vector< IVect > &proc) const
grouping all the local rows of the matrix into CSR form
void Fill()
sets values of non-zero entries to 0, 1, 2, etc
void Reallocate(int m, int n)
changing the size of the local matrix, previous values are lost
bool local_number_distant_values
if true local numbers are present in dist_row/dist_col instead of global numbers
void Copy(const DistributedMatrix_Base< T2 > &X)
Copies content of X in the current object.
IVect & GetProcessorSharingRows()
returns processor numbers for each set of shared rows
void AssembleColValues(const Vector< T2 > &Xrow, Vector< T2 > &X) const
Sends/receives values of Xcol on distant columns and adds them to X.
void FinalizeMltMin(Vector< int > &Y, Vector< int > &Yproc, Vector< int > &Xcol, Vector< int > &Xcol_proc) const
Finalizes the matrix-vector product MltMin.
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
void AssembleRowValues(const Vector< T2 > &Xrow, Vector< T2 > &X) const
Sends/receives values of Xrow on distant rows and adds them to X.
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.
IVect * GlobalRowNumbers
global row numbers
void WriteText(ostream &FileStream, Vector< int > &Indow, Vector< int > &IndCol, Vector< T > &Value, bool cplx) const
writes the matrix in text format
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.
void GetColSumDistantCol(Vector< T0 > &vec_sum) const
adds contribution of dist_col for GetColSum
long GetMaxDataSizeDistantRow() const
returns the maximum number of values in dist_row to exchange
void EraseRowDistant(const IVect &num, bool sym)
erases rows num(i)
Vector< IVect > local_row_to_send
local row/col numbers (needed for MltAdd)
void ScaleLeftDistant(const Vector< T0 > &Drow)
Multiplies a_ij by Drow(i) for distant non-zero entries.
Vector< IVect > proc_col
distant processor for additional values
long size_max_distant_row
number of distant non-zero entries
int GetNodlScalar() const
returns the number of scalar unknowns
void EraseColDistant(const IVect &num, bool sym)
erases columns num(i)
void GetRowSumDistantRow(Vector< T0 > &vec_sum) const
adds contribution of dist_row for GetRowSum
void WriteText(string FileName, bool cplx=false) const
writes the matrix in text format
size_t GetMemorySize() const
returns the size of memory used to store the matrix
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.
void SetIdentity()
sets matrix to identity matrix
void TransposeDistant(const DistributedMatrix_Base< T > &A)
Computes *this = A^T for non-zero entries.
void ClearLocal()
Clears the local matrix.
void Resize(int m, int n)
changing the size of the local matrix, previous values are kept
void ScaleRightDistant(const Vector< T0 > &Dcol)
Multiplies a_ij by Dcol(j) for distant non-zero entries.
DistributedMatrix_Base< T > & operator=(const DistributedMatrix_Base< T > &X)
equality *this = X
ClassComplexType< T >::Treal NormInf(const Matrix< T, Prop, Storage, Allocator > &A)
Returns the infinity-norm of a matrix.
void ScatterRowValues(const Vector< T2 > &X, Vector< T2 > &Xcol) const
Sends/receives values of X on distant rows (similar to ScatterColValues)
void Transpose(Matrix< T, Prop, Storage, Allocator > &A)
Matrix transposition.
long GetNonZeros() const
returns the number of non-zero entries stored in the matrix
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.
void ConjugateDistant()
Conjugates distant non-zero entries.
matrix distributed over all the processors
long GetDataSize() const
returns the number of elements stored
IVect * OverlapProcNumbers
processor where each shared row should be assembled
int ProcessorDistantRow(int i, int j) const
returns the processor associated with distant non-zero entry j for the local column i
int GetLocalM() const
returns the local number of rows
int nglob_
total number of rows (on all processors)
Vector< IVect > * SharingRowNumbers
for each processor sharing rows, list of "local numbers" shared
void Zero()
sets values of non-zero entries to 0
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
IVect & GetOverlapProcNumber()
returns processor numbers of the original rows
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.
ClassComplexType< T >::Treal MaxAbs(const Matrix< T, Prop, Storage, Allocator > &A)
Returns the maximum (in absolute value) of a matrix.
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.
IVect proc_col_to_recv
processor numbers (needed for MltAdd)
void ScaleDistant(const Vector< T0 > &Drow, const Vector< T1 > &Dcol)
Multiplies a_ij by Drow(i) Dcol(i) for distant non-zero entries.
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.
Vector< Vector< T, VectSparse >, VectFull, NewAlloc< Vector< T, VectSparse > > > dist_row
additional values on columns with non-local rows
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)
int ProcessorDistantCol(int i, int j) const
returns the processor associated with distant non-zero entry j for the local row i
void GetMaxAbsDistant(typename ClassComplexType< T >::Treal &res) const
Computes res = max(res, maximum absolute value of non-zero entries)
void AddMatrix(const T0 &alpha, const Matrix< T1, Prop1, Storage1, Allocator1 > &A, Matrix< T2, Prop2, Storage2, Allocator2 > &B)
Adds two matrices.
void AssembleVecMin(Vector< int > &X, Vector< int > &Xproc) const
assembles the vector (by taking the minimum instead of summing for AssembleVec
MPI_Comm & GetCommunicator()
returns MPI communicator (processors that will share the matrix)
const T & ValueDistantRow(int i, int j) const
returns the value of distant non-zero entry j for the local column i
void SetReadyForMltAdd(bool all_zero=true)
tells that there are no distant rows (mltadd ready)
DistributedMatrix_Base< T > & operator*=(const T0 &x)
multiplication by a scalar
bool IsReadyForMltAdd() const
returns true if the matrix is ready to perform a matrix-vector product
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.
int IndexGlobalRow(int i, int j) const
returns the global row number of distant non-zero entry j for the local column i
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
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.
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
long GetMaxDataSizeDistantCol() const
returns the maximum number of values in dist_col to exchange