DistributedVectorInline.cxx
1 // Copyright (C) 2014 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_VECTOR_INLINE_CXX
21 
22 #include "DistributedVector.hxx"
23 
24 namespace Seldon
25 {
26 
28  template<class T, class Allocator>
30  { OverlapRowNumbers = NULL; comm_ = MPI_COMM_SELF; }
31 
32 
34 
45  template<class T, class Allocator>
47  ::DistributedVector(const IVect& rows, const MPI_Comm& comm)
48  : OverlapRowNumbers(const_cast<IVect*>(&rows)), comm_(comm)
49  {
50  }
51 
52 
54  template<class T, class Allocator>
57  : Vector<T, VectFull, Allocator>(V),
58  OverlapRowNumbers(V.OverlapRowNumbers), comm_(V.comm_)
59  {
60  }
61 
62 
64  template<class T, class Allocator>
66  ::SetOverlapRow(const IVect& rows, const MPI_Comm& comm)
67  {
68  OverlapRowNumbers = const_cast<IVect*>(&rows);
69  comm_ = comm;
70  }
71 
72 
74  template<class T, class Allocator>
76  {
77  if (OverlapRowNumbers == NULL)
78  return 0;
79 
80  return OverlapRowNumbers->GetM();
81  }
82 
83 
85  template<class T, class Allocator>
87  {
88 #ifdef SELDON_DEBUG_LEVEL_3
89  CheckPointer((void*)OverlapRowNumbers, "DistributedVector::GetOverlapRow");
90 #endif
91 
92  return (*OverlapRowNumbers)(i);
93  }
94 
95 
97  template<class T, class Allocator>
98  inline const MPI_Comm& DistributedVector<T, Allocator>
100  {
101  return comm_;
102  }
103 
104 
106  template<class T, class Allocator>
108  {
109  comm_ = comm;
110  }
111 
112 
113  template<class T>
114  inline T DotProd(const DistributedVector<T>& X,
115  const DistributedVector<T>& Y)
116  {
117  return DotProdVector(X, Y);
118  }
119 
120  template<class T>
121  inline complex<T> DotProd(const DistributedVector<complex<T> >& X,
122  const DistributedVector<T>& Y)
123  {
124  abort();
125  return complex<T>(0, 0);
126  }
127 
128  template<class T>
129  inline complex<T> DotProd(const DistributedVector<T>& X,
130  const DistributedVector<complex<T> >& Y)
131  {
132  abort();
133  return complex<T>(0, 0);
134  }
135 
136  template<class T>
137  inline T DotProdConj(const DistributedVector<T>& X,
138  const DistributedVector<T>& Y)
139  {
140  return DotProdVector(X, Y);
141  }
142 
143  template<class T>
144  inline complex<T> DotProdConj(const DistributedVector<complex<T> >& X,
145  const DistributedVector<complex<T> >& Y)
146  {
147  return DotProdConjVector(X, Y);
148  }
149 
150  template<class T>
151  inline complex<T> DotProdConj(const DistributedVector<complex<T> >& X,
152  const DistributedVector<T>& Y)
153  {
154  abort();
155  return complex<T>(0, 0);
156  }
157 
158  template<class T>
159  inline complex<T> DotProdConj(const DistributedVector<T>& X,
160  const DistributedVector<complex<T> >& Y)
161  {
162  abort();
163  return complex<T>(0, 0);
164  }
165 
166 }
167 
168 #define SELDON_FILE_DISTRIBUTED_VECTOR_INLINE_CXX
169 #endif
170 
Seldon::DistributedVector::DistributedVector
DistributedVector()
default constructor
Definition: DistributedVectorInline.cxx:29
Seldon::DistributedVector::GetOverlapRow
int GetOverlapRow(int i) const
returns an overlapped row number
Definition: DistributedVectorInline.cxx:86
Seldon::DistributedVector::GetNbOverlap
int GetNbOverlap() const
returns the number of rows already counted
Definition: DistributedVectorInline.cxx:75
Seldon::Vector< int, VectFull >
Seldon::DotProdVector
T1 DotProdVector(const Vector< T1, Storage1, Allocator1 > &X, const Vector< T2, Storage2, Allocator2 > &Y)
Scalar product between two vectors.
Definition: Functions_Vector.cxx:399
Seldon::VectFull
Definition: StorageInline.cxx:74
Seldon::DistributedVector::GetCommunicator
const MPI_Comm & GetCommunicator() const
returns communicator
Definition: DistributedVectorInline.cxx:99
Seldon::DistributedVector::SetOverlapRow
void SetOverlapRow(const IVect &rows, const MPI_Comm &comm)
sets overlapped rows and MPI communicator
Definition: DistributedVectorInline.cxx:66
Seldon::DistributedVector::SetCommunicator
void SetCommunicator(const MPI_Comm &comm)
sets communicator
Definition: DistributedVectorInline.cxx:107
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::DotProdConjVector
T1 DotProdConjVector(const Vector< T1, Storage1, Allocator1 > &X, const Vector< T2, Storage2, Allocator2 > &Y)
Scalar product between two vectors conj(X).Y .
Definition: Functions_Vector.cxx:461
Seldon::DistributedVector
class storing a vector distributed over all the processors
Definition: DistributedVector.hxx:33