Tpetra_MultiVectorDecl.hpp

00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //          Tpetra: Templated Linear Algebra Services Package
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 // FINISH: some of these arrayview objects should be something else, like Ptr
00030 
00031 #ifndef TPETRA_MULTIVECTOR_DECL_HPP
00032 #define TPETRA_MULTIVECTOR_DECL_HPP
00033 
00034 #include <Teuchos_Object.hpp>
00035 #include <Teuchos_ArrayView.hpp>
00036 #include <Teuchos_ArrayRCP.hpp>
00037 #include <Teuchos_DataAccess.hpp>
00038 #include <Teuchos_BLAS_types.hpp>
00039 #include <Teuchos_Range1D.hpp>
00040 #include "Tpetra_DistObject.hpp"
00041 #include "Tpetra_Map.hpp"
00042 #include "Tpetra_CombineMode.hpp"
00043 
00044 namespace Tpetra {
00045 
00046 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00047   // forward declaration of MultiVectorData, needed to prevent circular inclusions
00048   template<typename Ordinal, typename Scalar> class MultiVectorData;
00049 #endif
00050 
00052   template<class Ordinal, class Scalar>
00053   class MultiVector : public DistObject<Ordinal,Scalar> {
00054 
00055     public:
00056 
00058 
00059 
00061     MultiVector(const Map<Ordinal> &map, Ordinal numVectors, bool zeroOut=true);
00062 
00064     MultiVector(const MultiVector<Ordinal,Scalar> &source);
00065 
00067     MultiVector(const Map<Ordinal> &map, const Teuchos::ArrayView<const Scalar> &A, Ordinal LDA, Ordinal numVectors);
00068 
00070     MultiVector(const Map<Ordinal> &map, const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar> > &arrayOfArrays);
00071 
00073     virtual ~MultiVector();
00074 
00076 
00078 
00079 
00081     void replaceGlobalValue(Ordinal globalRow, Ordinal vectorIndex, const Scalar &value);
00082 
00084     void sumIntoGlobalValue(Ordinal globalRow, Ordinal vectorIndex, const Scalar &value);
00085 
00087     void replaceMyValue(Ordinal MyRow, Ordinal VectorIndex, const Scalar &ScalarValue);
00088 
00090     void sumIntoMyValue(Ordinal MyRow, Ordinal VectorIndex, const Scalar &ScalarValue);
00091 
00093     void putScalar(const Scalar &ScalarConstant);
00094 
00096     void random();
00097 
00099     void replaceMap(const Map<Ordinal> &map);
00100 
00102     void reduce();
00103 
00104 
00106 
00108 
00109 
00110     /*
00112     Teuchos::RCP<MultiVector<Ordinal,Scalar> > subCopy(const Teuchos::Range1D &colRng) const;
00113     */
00114 
00116     Teuchos::RCP<MultiVector<Ordinal,Scalar> > subCopy(const Teuchos::ArrayView<const Teuchos_Index> &cols) const;
00117 
00118     /*
00120     Teuchos::RCP<MultiVector<Ordinal,Scalar> > subView(const Teuchos::Range1D &colRng);
00121     */
00122 
00124     Teuchos::RCP<MultiVector<Ordinal,Scalar> > subView(const Teuchos::ArrayView<const Teuchos_Index> &cols);
00125 
00126     /*
00128     Teuchos::RCP<const MultiVector<Ordinal,Scalar> > subViewConst(const Teuchos::Range1D &colRng) const;
00129     */
00130 
00132     Teuchos::RCP<const MultiVector<Ordinal,Scalar> > subViewConst(const Teuchos::ArrayView<const Teuchos_Index> &cols) const;
00133 
00134 
00136     void extractCopy(Teuchos::ArrayView<Scalar> A, Ordinal &MyLDA) const;
00137 
00139     void extractCopy(Teuchos::ArrayView<const Teuchos::ArrayView<Scalar> > arrayOfArrays) const;
00140 
00142     void extractView(Teuchos::ArrayView<Scalar> &A, Ordinal &MyLDA);
00143 
00145     Teuchos::ArrayView<const Teuchos::ArrayView<Scalar> > extractView();
00146 
00148     void extractConstView(Teuchos::ArrayView<const Scalar> &A, Ordinal &MyLDA) const;
00149 
00151     Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar> > extractConstView() const;
00152 
00154 
00156 
00157 
00158     // FINISH: expand documentation of these functions
00159 
00161     void dot(const MultiVector<Ordinal,Scalar> &A, const Teuchos::ArrayView<Scalar> &dots) const;
00162 
00164     void abs(const MultiVector<Ordinal,Scalar> &A);
00165 
00167     void reciprocal(const MultiVector<Ordinal,Scalar> &A);
00168 
00170     void scale(const Scalar &alpha);
00171 
00173     void scale(Teuchos::ArrayView<const Scalar> alpha);
00174 
00176     void scale(const Scalar &alpha, const MultiVector<Ordinal,Scalar> &A);
00177 
00179     void update(const Scalar &alpha, const MultiVector<Ordinal,Scalar> &A, const Scalar &beta);
00180 
00182     void update(const Scalar &alpha, const MultiVector<Ordinal,Scalar> &A, const Scalar &beta, const MultiVector<Ordinal,Scalar> &B, const Scalar &gamma);
00183 
00185     void norm1(const Teuchos::ArrayView<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const;
00186 
00188     void norm2(const Teuchos::ArrayView<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const;
00189 
00191     void normInf(const Teuchos::ArrayView<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const;
00192 
00194     void normWeighted(const MultiVector<Ordinal,Scalar> &weights, const Teuchos::ArrayView<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const;
00195 
00197     void minValue(const Teuchos::ArrayView<Scalar> &mins) const;
00198 
00200     void maxValue(const Teuchos::ArrayView<Scalar> &maxs) const;
00201 
00203     void meanValue(const Teuchos::ArrayView<Scalar> &means) const;
00204 
00206     void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const Scalar &alpha, const MultiVector<Ordinal,Scalar> &A, const MultiVector<Ordinal,Scalar> &B, const Scalar &beta);
00207 
00209     void multiply(const Scalar &alpha, const MultiVector<Ordinal,Scalar> &A, const MultiVector<Ordinal,Scalar> &B, const Scalar &beta);
00210 
00212     void reciprocalMultiply(const Scalar &alpha, const MultiVector<Ordinal,Scalar> &A, const MultiVector<Ordinal,Scalar> &B, const Scalar &beta);
00213 
00215 
00217 
00218 
00220 
00223     MultiVector<Ordinal,Scalar>& operator=(const MultiVector<Ordinal,Scalar> &source);
00224 
00226 
00228     Teuchos::ArrayView<Scalar> operator[](Ordinal i);
00229 
00231 
00233     Teuchos::ArrayView<const Scalar> operator[](Ordinal i) const;
00234 
00235     /*
00237     Vector<Ordinal,Scalar> & operator()(Ordinal i);
00238     */
00239 
00240     /*
00242     const Vector<Ordinal,Scalar> & operator() (Ordinal i) const;
00243     */
00244 
00246 
00248 
00249 
00251     Ordinal numVectors() const;
00252 
00254     Ordinal myLength() const;
00255 
00257     Ordinal globalLength() const;
00258 
00260     Ordinal stride() const;
00261 
00263     bool constantStride() const;
00264 
00266 
00268 
00269 
00271     void print(std::ostream &os) const;
00272     void printValues(std::ostream &os) const;
00273 
00275 
00277 
00278 
00279 /*
00281     void resetView(const Teuchos::ArrayRCP<const Teuchos::ArrayRCP<Scalar> > &arrayOfArrays);
00282 
00284     const Teuchos::ArrayRCP<Scalar> & values();
00285 
00287     const Teuchos::ArrayRCP<const Scalar> & valuesConst() const;
00288 
00290     const Teuchos::ArrayRCP<const Teuchos::ArrayRCP<Scalar> > & pointers();
00291 
00293     const Teuchos::ArrayRCP<const Teuchos::ArrayRCP<const Scalar> > & pointersConst() const;
00294 */
00295 
00297 
00298     protected:
00299 
00300     Teuchos::RCP<MultiVectorData<Ordinal,Scalar> > MVData_;
00301 
00302     // Advanced MultiVector constuctor for creating views.
00303     MultiVector(const Map<Ordinal> &map, const Teuchos::RCP<MultiVectorData<Ordinal,Scalar> > &mvdata);
00304 
00305     // four functions needed for DistObject derivation
00306     bool checkSizes(const DistObject<Ordinal,Scalar> &sourceObj, Ordinal &packetSize);
00307 
00308     void copyAndPermute(const DistObject<Ordinal,Scalar> &sourceObj,
00309                               Ordinal numSameIDs,
00310                         const Teuchos::ArrayView<const Ordinal> &permuteToLIDs,
00311                         const Teuchos::ArrayView<const Ordinal> &permuteFromLIDs);
00312 
00313     void packAndPrepare(const DistObject<Ordinal,Scalar> &sourceObj,
00314                         const Teuchos::ArrayView<const Ordinal> &exportLIDs,
00315                         const Teuchos::ArrayView<Scalar> &exports,
00316                         Distributor<Ordinal> &distor);
00317 
00318     void unpackAndCombine(const Teuchos::ArrayView<const Ordinal> &importLIDs,
00319                           const Teuchos::ArrayView<const Scalar> &imports,
00320                           Distributor<Ordinal> &distor,
00321                           CombineMode CM);
00322 
00323 
00324   }; // class MultiVector
00325 
00326 } // namespace Tpetra
00327 
00328 
00329 #endif // TPETRA_MULTIVECTOR_DECL_HPP

Generated on Wed May 12 21:59:41 2010 for Tpetra Matrix/Vector Services by  doxygen 1.4.7