All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Xpetra_EpetraIntVector.cpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jeremie Gaidamour (jngaida@sandia.gov)
40 // Jonathan Hu (jhu@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
47 #include "Xpetra_EpetraImport.hpp"
48 #include "Xpetra_EpetraExport.hpp"
49 
50 namespace Xpetra {
51 
52  void EpetraIntVector::replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value) { XPETRA_MONITOR("EpetraIntVector::replaceGlobalValue"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO"); }
53 
54  void EpetraIntVector::sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value) { XPETRA_MONITOR("EpetraIntVector::sumIntoGlobalValue"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO"); }
55 
56  void EpetraIntVector::replaceLocalValue(LocalOrdinal myRow, const Scalar &value) { XPETRA_MONITOR("EpetraIntVector::replaceLocalValue"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO"); }
57 
58  void EpetraIntVector::sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value) { XPETRA_MONITOR("EpetraIntVector::sumIntoLocalValue"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO"); }
59 
60  int EpetraIntVector::dot(const Vector<int,int,int> &a) const { XPETRA_MONITOR("EpetraIntVector::dot"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO"); return -1; }
61 
63 
65 
67 
69 
70  int EpetraIntVector::meanValue() const { XPETRA_MONITOR("EpetraIntVector::meanValue"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO"); return -1; }
71 
72  int EpetraIntVector::maxValue() const { XPETRA_MONITOR("EpetraIntVector::maxValue"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO"); return -1; }
73 
74  void EpetraIntVector::randomize(bool bUseXpetraImplementation) { XPETRA_MONITOR("EpetraIntVector::randomize"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraIntVector::randomize(): Functionnality not available in Epetra"); }
75 
76  void EpetraIntVector::setSeed(unsigned int seed) { XPETRA_MONITOR("EpetraIntVector::setSeed"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraIntVector::setSeed(): Functionnality not available in Epetra"); }
77 
80  }
81 
84  }
85 
87  XPETRA_MONITOR("EpetraIntVector::getData");
88 
89  int * data = vec_->Values();
90  int localLength = vec_->MyLength();
91 
92  return ArrayRCP<int>(data, 0, localLength, false); // not ownership
93  }
94 
96  XPETRA_MONITOR("EpetraIntVector::getDataNonConst");
97 
98  int * data = vec_->Values();
99  int localLength = vec_->MyLength();
100 
101  return ArrayRCP<int>(data, 0, localLength, false); // not ownership
102  }
103 
104  void EpetraIntVector::dot(const MultiVector<int,int,int> &A, const Teuchos::ArrayView<int> &dots) const {
105  XPETRA_MONITOR("EpetraIntVector::dot");
106 
107  //XPETRA_DYNAMIC_CAST(const EpetraMultiVector, A, eA, "This Xpetra::EpetraMultiVector method only accept Xpetra::EpetraMultiVector as input arguments.");
109  }
110 
112  XPETRA_MONITOR("EpetraIntVector::abs");
113 
114  //XPETRA_DYNAMIC_CAST(const EpetraMultiVector, A, eA, "This Xpetra::EpetraMultiVector method only accept Xpetra::EpetraMultiVector as input arguments.");
116  }
117 
119  XPETRA_MONITOR("EpetraIntVector::reciprocal");
120 
121  //XPETRA_DYNAMIC_CAST(const EpetraMultiVector, A, eA, "This Xpetra::EpetraMultiVector method only accept Xpetra::EpetraMultiVector as input arguments.");
123  }
124 
125  void EpetraIntVector::scale(const int &alpha) { XPETRA_MONITOR("EpetraIntVector::scale"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO"); }
126 
127  void EpetraIntVector::update(const int &alpha, const MultiVector<int,int,int> &A, const int &beta) {
128  XPETRA_MONITOR("EpetraIntVector::update");
129 
130  // XPETRA_DYNAMIC_CAST(const EpetraMultiVector, A, eA, "This Xpetra::EpetraMultiVector method only accept Xpetra::EpetraMultiVector as input arguments.");
132  }
133 
134  void EpetraIntVector::update(const int &alpha, const MultiVector<int,int,int> &A, const int &beta, const MultiVector<int,int,int> &B, const int &gamma) {
135  XPETRA_MONITOR("EpetraIntVector::update");
136 
137  //XPETRA_DYNAMIC_CAST(const EpetraMultiVector, A, eA, "This Xpetra::EpetraMultiVector method only accept Xpetra::EpetraMultiVector as input arguments.");
138  //XPETRA_DYNAMIC_CAST(const EpetraMultiVector, B, eB, "This Xpetra::EpetraMultiVector method only accept Xpetra::EpetraMultiVector as input arguments.");
140  }
141 
143 
145 
147 
149 
151 
153 
154  void EpetraIntVector::multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const int &alpha, const MultiVector<int,int,int> &A, const MultiVector<int,int,int> &B, const int &beta) { XPETRA_MONITOR("EpetraIntVector::multiply"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "Not available in Epetra"); }
155 
156  void EpetraIntVector::elementWiseMultiply(int scalarAB, const Vector<int,int,int> &A, const MultiVector<int,int,int> &B, int scalarThis) {
157  XPETRA_MONITOR("EpetraIntVector::elementWiseMultiply");
158 
159  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "Xpetra_EpetraIntVector: elementWiseMultiply not implemented because Epetra_IntVector does not support this operation");
160  }
161 
162  void EpetraIntVector::replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraIntVector::replaceGlobalValue"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO"); }
163 
164  void EpetraIntVector::sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraIntVector::sumIntoGlobalValue"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO"); }
165 
166  void EpetraIntVector::replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraIntVector::replaceLocalValue"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO"); }
167 
168  void EpetraIntVector::sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraIntVector::sumIntoLocalValue"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO"); }
169 
170  size_t EpetraIntVector::getNumVectors() const { XPETRA_MONITOR("EpetraIntVector::getNumVectors"); return 1; }
171 
172  std::string EpetraIntVector::description() const {
173  XPETRA_MONITOR("EpetraIntVector::description");
174 
175  // This implementation come from Epetra_Vector_def.hpp (without modification)
176  std::ostringstream oss;
178  oss << "{length="<<this->getGlobalLength()
179  << "}";
180  return oss.str();
181  }
182 
184  XPETRA_MONITOR("EpetraIntVector::describe");
185 
186  // typedef Kokkos::MultiVector<double> KMV;
187  // typedef Kokkos::DefaultArithmetic<KMV> MVT;
188 
189  // This implementation come from Tpetra_Vector_def.hpp (without modification) // JG: true?
190  using std::endl;
191  using std::setw;
192  using Teuchos::VERB_DEFAULT;
193  using Teuchos::VERB_NONE;
194  using Teuchos::VERB_LOW;
195  using Teuchos::VERB_MEDIUM;
196  using Teuchos::VERB_HIGH;
197  using Teuchos::VERB_EXTREME;
198 
199  if (verbLevel > Teuchos::VERB_NONE)
200  vec_->Print(out);
201  }
202 
204  const Import<int, int> &importer, CombineMode CM) {
205  XPETRA_MONITOR("EpetraIntVector::doImport");
206 
207  XPETRA_DYNAMIC_CAST(const EpetraIntVector, source, tSource, "Xpetra::EpetraIntVector::doImport only accept Xpetra::EpetraIntVector as input arguments.");
208  XPETRA_DYNAMIC_CAST(const EpetraImport, importer, tImporter, "Xpetra::EpetraIntVector::doImport only accept Xpetra::EpetraImport as input arguments.");
209 
210  const Epetra_IntVector & v = *tSource.getEpetra_IntVector();
211  int err = vec_->Import(v, *tImporter.getEpetra_Import(), toEpetra(CM));
212  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
213  }
214 
216  const Import<int, int>& importer, CombineMode CM) {
217  XPETRA_MONITOR("EpetraIntVector::doExport");
218 
219  XPETRA_DYNAMIC_CAST(const EpetraIntVector, dest, tDest, "Xpetra::EpetraIntVector::doImport only accept Xpetra::EpetraIntVector as input arguments.");
220  XPETRA_DYNAMIC_CAST(const EpetraImport, importer, tImporter, "Xpetra::EpetraIntVector::doImport only accept Xpetra::EpetraImport as input arguments.");
221 
222  const Epetra_IntVector & v = *tDest.getEpetra_IntVector();
223  int err = vec_->Import(v, *tImporter.getEpetra_Import(), toEpetra(CM));
224  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
225  }
226 
228  const Export<int, int>& exporter, CombineMode CM) {
229  XPETRA_MONITOR("EpetraIntVector::doImport");
230 
231  XPETRA_DYNAMIC_CAST(const EpetraIntVector, source, tSource, "Xpetra::EpetraIntVector::doImport only accept Xpetra::EpetraIntVector as input arguments.");
232  XPETRA_DYNAMIC_CAST(const EpetraExport, exporter, tExporter, "Xpetra::EpetraIntVector::doImport only accept Xpetra::EpetraImport as input arguments.");
233 
234  const Epetra_IntVector & v = *tSource.getEpetra_IntVector();
235  int err = vec_->Import(v, *tExporter.getEpetra_Export(), toEpetra(CM));
236  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
237  }
238 
240  const Export<int, int>& exporter, CombineMode CM) {
241  XPETRA_MONITOR("EpetraIntVector::doExport");
242 
243  XPETRA_DYNAMIC_CAST(const EpetraIntVector, dest, tDest, "Xpetra::EpetraIntVector::doImport only accept Xpetra::EpetraIntVector as input arguments.");
244  XPETRA_DYNAMIC_CAST(const EpetraExport, exporter, tExporter, "Xpetra::EpetraIntVector::doImport only accept Xpetra::EpetraImport as input arguments.");
245 
246  const Epetra_IntVector & v = *tDest.getEpetra_IntVector();
247  int err = vec_->Export(v, *tExporter.getEpetra_Export(), toEpetra(CM));
248  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
249  }
250 
251 } // namespace Xpetra
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(size_t j)
Return a Vector which is a nonconst view of column j.
void reciprocal(const MultiVector< int, int, int, Kokkos::DefaultNode::DefaultNodeType > &A)
Puts element-wise reciprocal values of input Multi-vector in target, this(i,j) = 1/A(i,j).
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
void elementWiseMultiply(int scalarAB, const Vector< int, int, int, Kokkos::DefaultNode::DefaultNodeType > &A, const MultiVector< int, int, int, Kokkos::DefaultNode::DefaultNodeType > &B, int scalarThis)
Element-wise multiply of a Vector A with a EpetraMultiVector B.
Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(size_t j) const
Return a Vector which is a const view of column j.
Teuchos::ScalarTraits< int >::magnitudeType normInf() const
Compute Inf-norm of this Vector.
void update(const int &alpha, const MultiVector< int, int, int, Kokkos::DefaultNode::DefaultNodeType > &A, const int &beta)
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
std::string description() const
Return a simple one-line description of this object.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::ArrayRCP< const int > getData(size_t j) const
void replaceLocalValue(LocalOrdinal myRow, const Scalar &value)
Replace current value at the specified location with specified values.
global_size_t getGlobalLength() const
Returns the global vector length of vectors in the multi-vector.
void doExport(const DistObject< int, int, int > &dest, const Import< int, int > &importer, CombineMode CM)
void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const int &alpha, const MultiVector< int, int, int, Kokkos::DefaultNode::DefaultNodeType > &A, const MultiVector< int, int, int, Kokkos::DefaultNode::DefaultNodeType > &B, const int &beta)
Matrix-Matrix multiplication, this = beta*this + alpha*op(A)*op(B).
void randomize(bool bUseXpetraImplementation=true)
Set multi-vector values to random numbers.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, int > > &graph)
Teuchos::ScalarTraits< int >::magnitudeType norm2() const
Compute 2-norm of this Vector.
int dot(const Vector< int, int, int > &a) const
TODO missing comment.
void setSeed(unsigned int seed)
Set seed for Random function.
Teuchos::ScalarTraits< int >::magnitudeType norm1() const
Return 1-norm of this Vector.
virtual std::string description() const
void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Adds specified value to existing value at the specified location.
Exception throws when you call an unimplemented method of Xpetra.
#define XPETRA_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Replace current value at the specified location with specified value.
void doImport(const DistObject< int, int, int > &source, const Import< int, int > &importer, CombineMode CM)
void sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value)
Adds specified value to existing value at the specified location.
int maxValue() const
Compute max value of this Vector.
void abs(const MultiVector< int, int, int, Kokkos::DefaultNode::DefaultNodeType > &A)
Puts element-wise absolute values of input Multi-vector in target: A = abs(this)
int meanValue() const
Compute mean (average) value of this Vector.
Teuchos::ArrayRCP< int > getDataNonConst(size_t j)
CombineMode
Xpetra::Combine Mode enumerable type.
Teuchos::ScalarTraits< int >::magnitudeType normWeighted(const Vector< int, int, int > &weights) const
Compute Weighted 2-norm (RMS Norm) of this Vector.
size_t getNumVectors() const
Returns the number of vectors in the multi-vector.
#define XPETRA_MONITOR(funcName)
void scale(const int &alpha)
Scale the current values of a multi-vector, this = alpha*this.
RCP< Epetra_IntVector > vec_