00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #ifndef XPETRA_MULTIVECTOR_HPP
00047 #define XPETRA_MULTIVECTOR_HPP
00048
00049
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
00063 template<class S, class LO, class GO, class N> class Vector;
00064 #endif
00065
00066 template <class Scalar, class LocalOrdinal = int, class GlobalOrdinal = LocalOrdinal, class Node = Kokkos::DefaultNode::DefaultNodeType>
00067 class MultiVector
00068 : public DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node >
00069 {
00070
00071 public:
00072
00074
00075
00077 virtual ~MultiVector() { }
00078
00080
00082
00083
00085 virtual void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)= 0;
00086
00088 virtual void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)= 0;
00089
00091 virtual void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)= 0;
00092
00094 virtual void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)= 0;
00095
00097 virtual void putScalar(const Scalar &value)= 0;
00098
00100
00102
00103
00105 virtual Teuchos::ArrayRCP< const Scalar > getData(size_t j) const = 0;
00106
00108 virtual Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)= 0;
00109
00111
00113
00114
00116 virtual void dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< Scalar > &dots) const = 0;
00117
00119 virtual void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)= 0;
00120
00122 virtual void reciprocal(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)= 0;
00123
00125 virtual void scale(const Scalar &alpha)= 0;
00126
00128 virtual void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)= 0;
00129
00131 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;
00132
00134 virtual void norm1(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const = 0;
00135
00137 virtual void norm2(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const = 0;
00138
00140 virtual void normInf(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const = 0;
00141
00143 virtual void normWeighted(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &weights, const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const = 0;
00144
00146 virtual void meanValue(const Teuchos::ArrayView< Scalar > &means) const = 0;
00147
00149 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;
00150
00152 virtual void elementWiseMultiply(Scalar scalarAB, const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, Scalar scalarThis)= 0;
00153
00155
00157
00158
00160 virtual size_t getNumVectors() const = 0;
00161
00163 virtual size_t getLocalLength() const = 0;
00164
00166 virtual global_size_t getGlobalLength() const = 0;
00167
00169
00171
00172
00174 virtual std::string description() const = 0;
00175
00177 virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const = 0;
00178
00180
00182
00183
00185 virtual void setSeed(unsigned int seed)= 0;
00186
00187
00188 virtual void randomize(bool bUseXpetraImplementation = false)= 0;
00189
00191 virtual void Xpetra_randomize()
00192 {
00193 typedef Teuchos::ScalarTraits<Scalar> SCT;
00194
00195 const size_t numVectors = getNumVectors();
00196 for (size_t i = 0; i < numVectors; i++)
00197 {
00198 Teuchos::ArrayRCP< Scalar > datai = getDataNonConst(i);
00199
00200 const size_t myLength = getLocalLength();
00201 for(size_t j=0; j<myLength; j++)
00202 {
00203 datai[j] = SCT::random();
00204 }
00205 }
00206 }
00207
00208
00210
00211 };
00212
00213 }
00214
00215 #define XPETRA_MULTIVECTOR_SHORT
00216 #endif // XPETRA_MULTIVECTOR_HPP