All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
Xpetra_MultiVector.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_MULTIVECTOR_HPP
00047 #define XPETRA_MULTIVECTOR_HPP
00048 
00049 /* this file is automatically generated - do not edit (see script/interfaces.py) */
00050 
00051 #include <Teuchos_LabeledObject.hpp>
00052 #include <Teuchos_DataAccess.hpp>
00053 #include <Teuchos_BLAS_types.hpp>
00054 #include <Teuchos_Range1D.hpp>
00055 #include "Xpetra_ConfigDefs.hpp"
00056 #include "Xpetra_DistObject.hpp"
00057 #include "Xpetra_Map.hpp"
00058 
00059 namespace Xpetra {
00060 
00061 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00062   // forward declaration of Vector, needed to prevent circular inclusions
00063   template<class S, class LO, class GO, class N> class Vector;
00064 #endif
00065 
00066   template <class Scalar = double,
00067             class LocalOrdinal = Map<>::local_ordinal_type,
00068             class GlobalOrdinal = typename Map<LocalOrdinal>::global_ordinal_type,
00069             class Node = typename Map<LocalOrdinal, GlobalOrdinal>::node_type>
00070   class MultiVector
00071     : public DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node >
00072   {
00073   public:
00074     typedef Scalar scalar_type;
00075     typedef LocalOrdinal local_ordinal_type;
00076     typedef GlobalOrdinal global_ordinal_type;
00077     typedef Node node_type;
00078 
00080 
00081 
00083     virtual ~MultiVector() { }
00084 
00095     MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>&
00096     operator= (const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& rhs) {
00097       assign (rhs); // dispatch to protected virtual method
00098       return *this;
00099     }
00100 
00102 
00103 
00104 
00106     virtual void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)= 0;
00107 
00109     virtual void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)= 0;
00110 
00112     virtual void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)= 0;
00113 
00115     virtual void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)= 0;
00116 
00118     virtual void putScalar(const Scalar &value)= 0;
00119 
00121 
00123 
00124 
00126     virtual Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(size_t j) const = 0;
00127 
00129     virtual Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(size_t j)= 0;
00130 
00132     virtual Teuchos::ArrayRCP< const Scalar > getData(size_t j) const = 0;
00133 
00135     virtual Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)= 0;
00136 
00138 
00140 
00141 
00143     virtual void dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< Scalar > &dots) const = 0;
00144 
00146     virtual void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)= 0;
00147 
00149     virtual void reciprocal(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)= 0;
00150 
00152     virtual void scale(const Scalar &alpha)= 0;
00153 
00155     virtual void scale (Teuchos::ArrayView< const Scalar > alpha) = 0;
00156 
00158     virtual void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)= 0;
00159 
00161     virtual void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const Scalar &gamma)= 0;
00162 
00164     virtual void norm1(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const = 0;
00165 
00167     virtual void norm2(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const = 0;
00168 
00170     virtual void normInf(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const = 0;
00171 
00173     virtual void normWeighted(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &weights, const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const = 0;
00174 
00176     virtual void meanValue(const Teuchos::ArrayView< Scalar > &means) const = 0;
00177 
00179     virtual void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const Scalar &beta)= 0;
00180 
00182     virtual void elementWiseMultiply(Scalar scalarAB, const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, Scalar scalarThis)= 0;
00183 
00185 
00187 
00188 
00190     virtual size_t getNumVectors() const = 0;
00191 
00193     virtual size_t getLocalLength() const = 0;
00194 
00196     virtual global_size_t getGlobalLength() const = 0;
00197 
00199 
00201 
00202 
00204     virtual std::string description() const = 0;
00205 
00207     virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const = 0;
00208 
00209     virtual void replaceMap(const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map) = 0;
00210 
00212 
00214 
00215 
00217     virtual void setSeed(unsigned int seed)= 0;
00218 
00219 
00220     virtual void randomize(bool bUseXpetraImplementation = false)= 0;
00221 
00223     virtual void Xpetra_randomize()
00224     {
00225         typedef Teuchos::ScalarTraits<Scalar> SCT;
00226 
00227         const size_t numVectors = getNumVectors();
00228         for (size_t i = 0; i < numVectors; i++)
00229         {
00230             Teuchos::ArrayRCP< Scalar > datai = getDataNonConst(i);
00231 
00232             const size_t myLength = getLocalLength();
00233             for(size_t j=0; j<myLength; j++)
00234             {
00235                 datai[j] = SCT::random();
00236             }
00237         }
00238     }
00239 
00240 
00242 
00243   protected:
00249     virtual void assign (const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& rhs) = 0;
00250 
00251   }; // MultiVector class
00252 
00253 } // Xpetra namespace
00254 
00255 #define XPETRA_MULTIVECTOR_SHORT
00256 #endif // XPETRA_MULTIVECTOR_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines