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 = 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);
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 };
00252
00253 }
00254
00255 #define XPETRA_MULTIVECTOR_SHORT
00256 #endif // XPETRA_MULTIVECTOR_HPP