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 //                    Jeremie Gaidamour (jngaida@sandia.gov)
00040 //                    Jonathan Hu       (jhu@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   class EpetraIntVector
00063     : public Vector<int,int,int>
00064   {
00065 
00066     typedef int Scalar;
00067     typedef int LocalOrdinal;
00068     typedef int GlobalOrdinal;
00069     typedef Kokkos::DefaultNode::DefaultNodeType Node;
00070     
00071   public:
00072 
00074 
00075 
00077     explicit EpetraIntVector(const Teuchos::RCP<const Map<int,int> > &map, bool zeroOut=true) 
00078     {
00079       XPETRA_RCP_DYNAMIC_CAST(const EpetraMap, map, eMap, "Xpetra::EpetraCrsMatrix constructors only accept Xpetra::EpetraMap as input arguments.");
00080       vec_ = rcp(new Epetra_IntVector(eMap->getEpetra_BlockMap(), zeroOut));
00081     }
00082     
00084     ~EpetraIntVector() {  };
00085 
00087 
00089 
00090 
00092     int dot(const Vector<int,int,int> &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<int,int,int> &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 
00146     Teuchos::ArrayRCP<const int> getData(size_t j) const;
00147 
00150     Teuchos::ArrayRCP<int> getDataNonConst(size_t j);
00151 
00153 
00155 
00156 
00157     void dot(const MultiVector<int,int,int,Kokkos::DefaultNode::DefaultNodeType> &A, const Teuchos::ArrayView<int> &dots) const;
00158 
00160     void abs(const MultiVector<int,int,int,Kokkos::DefaultNode::DefaultNodeType> &A);
00161 
00163     void reciprocal(const MultiVector<int,int,int,Kokkos::DefaultNode::DefaultNodeType> &A);
00164 
00166     void scale(const int &alpha);
00167 
00169     void update(const int &alpha, const MultiVector<int,int,int,Kokkos::DefaultNode::DefaultNodeType> &A, const int &beta);
00170 
00172     void update(const int &alpha, const MultiVector<int,int,int,Kokkos::DefaultNode::DefaultNodeType> &A, const int &beta, const MultiVector<int,int,int,Kokkos::DefaultNode::DefaultNodeType> &B, const int &gamma);
00173 
00175     void norm1(const Teuchos::ArrayView<Teuchos::ScalarTraits<int>::magnitudeType> &norms) const;
00176 
00178     void norm2(const Teuchos::ArrayView<Teuchos::ScalarTraits<int>::magnitudeType> &norms) const;
00179 
00181     void normInf(const Teuchos::ArrayView<Teuchos::ScalarTraits<int>::magnitudeType> &norms) const;
00182 
00184     void normWeighted(const MultiVector<int,int,int,Kokkos::DefaultNode::DefaultNodeType> &weights, const Teuchos::ArrayView<Teuchos::ScalarTraits<int>::magnitudeType> &norms) const;
00185 
00187     void meanValue(const Teuchos::ArrayView<int> &means) const;
00188 
00190     void maxValue(const Teuchos::ArrayView<int> &maxs) const;
00191 
00193     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);
00194 
00196     void elementWiseMultiply(int scalarAB, const Vector<int,int,int,Kokkos::DefaultNode::DefaultNodeType> &A, const MultiVector<int,int,int,Kokkos::DefaultNode::DefaultNodeType> &B, int scalarThis);
00198 
00200 
00201 
00203     void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value);
00204 
00206     void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value);
00207 
00209     void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value);
00210 
00212     void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value);
00213 
00215 
00217 
00218 
00220     size_t getNumVectors() const;
00221 
00223     size_t getLocalLength() const {  return vec_->MyLength(); }
00224 
00226     global_size_t getGlobalLength() const {  return vec_->GlobalLength(); }
00227 
00229 
00231 
00232 
00234     std::string description() const;
00235 
00237     void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
00238 
00240 
00241     RCP< Epetra_IntVector > getEpetra_IntVector() const {  return vec_; }
00242 
00243     const RCP<const Comm<int> > getComm() const {
00244       TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO getComm Epetra MultiVector not implemented");
00245     }
00246 
00247     // Implementing DistObject
00248     const Teuchos::RCP<const Map<int,int> > getMap() const { 
00249       RCP<const Epetra_BlockMap> map = rcp(new Epetra_BlockMap(vec_->Map()));
00250       return rcp ( new Xpetra::EpetraMap(map) );
00251     }
00252 
00253     void doImport(const DistObject<int, int, int> &source, const Import<int, int> &importer, CombineMode CM);
00254 
00255     void doExport(const DistObject<int, int, int> &dest, const Import<int, int>& importer, CombineMode CM);
00256 
00257     void doImport(const DistObject<int, int, int> &source, const Export<int, int>& exporter, CombineMode CM);
00258 
00259     void doExport(const DistObject<int, int, int> &dest, const Export<int, int>& exporter, CombineMode CM);
00260 
00261   private:
00262     RCP< Epetra_IntVector > vec_;
00263     
00264   }; // class EpetraIntVector
00265 
00266 } // namespace Xpetra
00267 
00268 #endif // XPETRA_EPETRAINTVECTOR_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines