Xpetra_EpetraVector.hpp
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
46 #ifndef XPETRA_EPETRAVECTOR_HPP
47 #define XPETRA_EPETRAVECTOR_HPP
48 
49 /* this file is automatically generated - do not edit (see script/epetra.py) */
50 
52 
53 #include "Xpetra_Vector.hpp"
55 #include "Xpetra_EpetraMap.hpp" //TMP
56 #include "Xpetra_Utils.hpp"
57 #include "Xpetra_EpetraImport.hpp"
58 #include "Xpetra_EpetraExport.hpp"
59 #include "Xpetra_Exceptions.hpp"
60 
61 #include <Epetra_Vector.h>
62 
63 namespace Xpetra {
64 
65  // TODO: move that elsewhere
66  Epetra_Vector & toEpetra(Vector<double, int, int> &);
67 
68  const Epetra_Vector & toEpetra(const Vector<double, int, int> &);
69  //
70 
72  : public virtual Vector<double,int,int>, public EpetraMultiVector
73  {
74 
75  typedef double Scalar;
76  typedef int LocalOrdinal;
77  typedef int GlobalOrdinal;
79 
80  public:
81 
82  using EpetraMultiVector::dot; // overloading, not hiding
83  using EpetraMultiVector::norm1; // overloading, not hiding
84  using EpetraMultiVector::norm2; // overloading, not hiding
85  using EpetraMultiVector::normInf; // overloading, not hiding
86  using EpetraMultiVector::normWeighted; // overloading, not hiding
87  using EpetraMultiVector::meanValue; // overloading, not hiding
88  using EpetraMultiVector::replaceGlobalValue; // overloading, not hiding
89  using EpetraMultiVector::sumIntoGlobalValue; // overloading, not hiding
90  using EpetraMultiVector::replaceLocalValue; // overloading, not hiding
91  using EpetraMultiVector::sumIntoLocalValue; // overloading, not hiding
92 
94 
95 
97  explicit EpetraVector(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, bool zeroOut=true);
98 
101 
103  virtual ~EpetraVector() { }
104 
106 
108 
109 
111  void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value);
112 
114  void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value);
115 
117  void replaceLocalValue(LocalOrdinal myRow, const Scalar &value);
118 
120  void sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value);
121 
123 
125 
126 
129 
131  Teuchos::ScalarTraits< Scalar >::magnitudeType norm1() const;
132 
134  Teuchos::ScalarTraits< Scalar >::magnitudeType norm2() const;
135 
137  Teuchos::ScalarTraits< Scalar >::magnitudeType normInf() const;
138 
140  Teuchos::ScalarTraits< Scalar >::magnitudeType normWeighted(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &weights) const;
141 
143  Scalar meanValue() const;
144 
146 
148 
149 
151  std::string description() const;
152 
154  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
155 
157 
159 
160 
162  EpetraVector(const Teuchos::RCP<Epetra_Vector> &vec) : EpetraMultiVector(vec) { } // TODO: removed const of Epetra::Vector
163 
165  Epetra_Vector * getEpetra_Vector() const { return (*this->EpetraMultiVector::getEpetra_MultiVector())(0); }
166  //RCP<Epetra_Vector> getEpetra_Vector() const { return this->EpetraMultiVector::getEpetra_MultiVector()->getVectorNonConst(0); }
167 
171  EpetraVector(const RCP<Epetra_MultiVector> &mv, size_t j);
172 
174 
175  private:
176 
177  // This private member is only used by the constructor EpetraVector(const RCP<EpetraMultiVector> &mv, size_t j). The actual private member holding the Epetra vector (vec_) is in the base class (Xpetra:EpetraMultiVector)
178  const RCP<const Epetra_MultiVector> internalRefToBaseMV_;
179 
180  }; // EpetraVector class
181 
182 } // Xpetra namespace
183 
184 #endif // XPETRA_EPETRAVECTOR_HPP
void normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute Inf-norm of each vector in multi-vector.
void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
EpetraVector(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, bool zeroOut=true)
Sets all vector entries to zero.
Teuchos::ScalarTraits< Scalar >::magnitudeType normInf() const
Compute Inf-norm of this Vector.
EpetraVector(const Teuchos::RCP< Epetra_Vector > &vec)
EpetraMultiVector constructor to wrap a Epetra_Vector object.
virtual ~EpetraVector()
Destructor.
Xpetra namespace
RCP< Epetra_MultiVector > getEpetra_MultiVector() const
Get the underlying Epetra multivector.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, int > > &graph)
void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Adds specified value to existing value at the specified location.
void meanValue(const Teuchos::ArrayView< Scalar > &means) const
Compute mean (average) value of each vector in multi-vector. The outcome of this routine is undefined...
void norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute 1-norm of each vector in multi-vector.
void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm1() const
Return 1-norm of this Vector.
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 norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
std::string description() const
Return a simple one-line description of this object.
void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm2() const
Compute 2-norm of this Vector.
Scalar meanValue() const
Compute mean (average) value of this Vector.
Kokkos::DefaultNode::DefaultNodeType Node
Epetra_Vector * getEpetra_Vector() const
Get the underlying Epetra vector.
void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.
void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Replace current value at the specified location with specified value.
void sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value)
Adds specified value to existing value at the specified location.
void replaceLocalValue(LocalOrdinal myRow, const Scalar &value)
Replace current value at the specified location with specified values.
void normWeighted(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &weights, const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Teuchos::ScalarTraits< Scalar >::magnitudeType normWeighted(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &weights) const
Compute Weighted 2-norm (RMS Norm) of this Vector.
Scalar dot(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &a) const
Computes dot product of this Vector against input Vector x.
const RCP< const Epetra_MultiVector > internalRefToBaseMV_
void dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< Scalar > &dots) const
Compute dot product of each corresponding pair of vectors, dots[i] = this[i].dot(A[i]).