All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
Xpetra_EpetraIntVector.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 //
00003 // ***********************************************************************
00004 //
00005 //             Xpetra: A linear algebra interface package
00006 //                  Copyright 2012 Sandia Corporation
00007 //
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact
00039 //                    Jonathan Hu       (jhu@sandia.gov)
00040 //                    Andrey Prokopenko (aprokop@sandia.gov)
00041 //                    Ray Tuminaro      (rstumin@sandia.gov)
00042 //
00043 // ***********************************************************************
00044 //
00045 // @HEADER
00046 #ifndef XPETRA_EPETRAINTVECTOR_HPP
00047 #define XPETRA_EPETRAINTVECTOR_HPP
00048 
00049 #include "Xpetra_EpetraConfigDefs.hpp"
00050 
00051 #include "Xpetra_ConfigDefs.hpp"
00052 #include "Xpetra_MultiVector.hpp"
00053 #include "Xpetra_Vector.hpp"
00054 #include "Xpetra_Exceptions.hpp"
00055 
00056 #include "Xpetra_EpetraMap.hpp"
00057 #include "Xpetra_EpetraMultiVector.hpp"
00058 #include "Epetra_IntVector.h"
00059 
00060 namespace Xpetra {
00061 
00062   template<class EpetraGlobalOrdinal>
00063   class EpetraIntVectorT
00064     : public Vector<int,int,EpetraGlobalOrdinal>
00065   {
00066     typedef int Scalar;
00067     typedef int LocalOrdinal;
00068     typedef EpetraGlobalOrdinal GlobalOrdinal;
00069     typedef KokkosClassic::DefaultNode::DefaultNodeType Node;
00070 
00071   public:
00072 
00074 
00075 
00077     explicit EpetraIntVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, bool zeroOut=true)
00078     {
00079       XPETRA_RCP_DYNAMIC_CAST(const EpetraMapT<GlobalOrdinal>, map, eMap, "Xpetra::EpetraCrsMatrixT constructors only accept Xpetra::EpetraMapT as input arguments.");
00080       vec_ = rcp(new Epetra_IntVector(eMap->getEpetra_BlockMap(), zeroOut));
00081     }
00082 
00084     ~EpetraIntVectorT() {  };
00085 
00087 
00089 
00090 
00092     int dot (const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &a) const;
00093 
00095     Teuchos::ScalarTraits<int>::magnitudeType norm1() const;
00096 
00098     Teuchos::ScalarTraits<int>::magnitudeType norm2() const;
00099 
00101     Teuchos::ScalarTraits<int>::magnitudeType normInf() const;
00102 
00104     Teuchos::ScalarTraits<int>::magnitudeType normWeighted(const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &weights) const;
00105 
00107     int meanValue() const;
00108 
00110     int maxValue() const;
00111 
00113 
00115 
00116 
00118     void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value);
00119 
00121     void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value);
00122 
00124     void replaceLocalValue(LocalOrdinal myRow, const Scalar &value);
00125 
00127     void sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value);
00128 
00130     void putScalar(const int &value) {  vec_->PutValue(value); }
00131 
00133     void randomize(bool bUseXpetraImplementation = true);
00134 
00136 
00137     void setSeed(unsigned int seed);
00138 
00140 
00142 
00143 
00145     Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(size_t j) const;
00146 
00148     Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(size_t j);
00149 
00152     Teuchos::ArrayRCP<const int> getData(size_t j) const;
00153 
00156     Teuchos::ArrayRCP<int> getDataNonConst(size_t j);
00157 
00159 
00161 
00162 
00163     void dot(const MultiVector<int,int,GlobalOrdinal,Node> &A, const Teuchos::ArrayView<int> &dots) const;
00164 
00166     void abs(const MultiVector<int,int,GlobalOrdinal,Node> &A);
00167 
00169     void reciprocal(const MultiVector<int,int,GlobalOrdinal,Node> &A);
00170 
00172     void scale(const int &alpha);
00173 
00175     void scale (Teuchos::ArrayView< const int > alpha);
00176 
00178     void update(const int &alpha, const MultiVector<int,int,GlobalOrdinal,Node> &A, const int &beta);
00179 
00181     void update(const int &alpha, const MultiVector<int,int,GlobalOrdinal,Node> &A, const int &beta, const MultiVector<int,int,GlobalOrdinal,Node> &B, const int &gamma);
00182 
00184     void norm1(const Teuchos::ArrayView<Teuchos::ScalarTraits<int>::magnitudeType> &norms) const;
00185 
00187     void norm2(const Teuchos::ArrayView<Teuchos::ScalarTraits<int>::magnitudeType> &norms) const;
00188 
00190     void normInf(const Teuchos::ArrayView<Teuchos::ScalarTraits<int>::magnitudeType> &norms) const;
00191 
00193     void normWeighted(const MultiVector<int,int,GlobalOrdinal,Node> &weights, const Teuchos::ArrayView<Teuchos::ScalarTraits<int>::magnitudeType> &norms) const;
00194 
00196     void meanValue(const Teuchos::ArrayView<int> &means) const;
00197 
00199     void maxValue(const Teuchos::ArrayView<int> &maxs) const;
00200 
00202     void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const int &alpha, const MultiVector<int,int,GlobalOrdinal,Node> &A, const MultiVector<int,int,GlobalOrdinal,Node> &B, const int &beta);
00203 
00205     void elementWiseMultiply(int scalarAB, const Vector<int,int,GlobalOrdinal,Node> &A, const MultiVector<int,int,GlobalOrdinal,Node> &B, int scalarThis);
00206 
00208 
00210 
00211 
00213     void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value);
00214 
00216     void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value);
00217 
00219     void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value);
00220 
00222     void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value);
00223 
00225 
00227 
00228 
00230     size_t getNumVectors() const;
00231 
00233     size_t getLocalLength() const {  return vec_->MyLength(); }
00234 
00236     global_size_t getGlobalLength() const {  return vec_->GlobalLength64(); }
00237 
00239 
00241 
00242 
00244     std::string description() const;
00245 
00247     void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
00248 
00250 
00251     RCP< Epetra_IntVector > getEpetra_IntVector() const {  return vec_; }
00252 
00253     const RCP<const Comm<int> > getComm() const {
00254       TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO getComm Epetra MultiVector not implemented");
00255     }
00256 
00257     // Implementing DistObject
00258     Teuchos::RCP<const Map<int, GlobalOrdinal> > getMap () const {
00259       RCP<const Epetra_BlockMap> map = rcp(new Epetra_BlockMap(vec_->Map()));
00260       return rcp (new Xpetra::EpetraMapT<GlobalOrdinal>(map));
00261     }
00262 
00263     void
00264     doImport (const DistObject<int, int, GlobalOrdinal> &source,
00265               const Import<int, GlobalOrdinal> &importer, CombineMode CM);
00266 
00267     void
00268     doExport (const DistObject<int, int, GlobalOrdinal> &dest,
00269               const Import<int, GlobalOrdinal>& importer, CombineMode CM);
00270 
00271     void
00272     doImport (const DistObject<int, int, GlobalOrdinal> &source,
00273               const Export<int, GlobalOrdinal>& exporter, CombineMode CM);
00274 
00275     void
00276     doExport (const DistObject<int, int, GlobalOrdinal> &dest,
00277               const Export<int, GlobalOrdinal>& exporter, CombineMode CM);
00278 
00279     void replaceMap(const RCP<const Map<int, GlobalOrdinal> >& map) {
00280       // do nothing
00281     }
00282 
00283   protected:
00286     virtual void
00287     assign (const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal>& rhs);
00288 
00289   private:
00291     RCP< Epetra_IntVector > vec_;
00292 
00293   }; // class EpetraIntVectorT
00294 
00295 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
00296   typedef EpetraIntVectorT<int> EpetraIntVector;
00297 #endif
00298 
00299 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
00300   typedef EpetraIntVectorT<long long> EpetraIntVector64;
00301 #endif
00302 
00303 } // namespace Xpetra
00304 
00305 #endif // XPETRA_EPETRAINTVECTOR_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines