Tpetra_VectorDecl.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 #ifndef TPETRA_VECTOR_DECL_HPP
00030 #define TPETRA_VECTOR_DECL_HPP
00031 
00032 #include <Teuchos_Object.hpp>
00033 #include <Teuchos_ArrayView.hpp>
00034 #include "Tpetra_ConfigDefs.hpp"
00035 #include "Tpetra_DistObject.hpp"
00036 #include "Tpetra_Map.hpp"
00037 
00038 namespace Tpetra {
00039 
00040 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00041   // forward declaration of VectorData, needed to prevent circular inclusions
00042   template<typename Ordinal, typename Scalar> class VectorData;
00043 #endif
00044 
00046 
00068   template<typename Ordinal, typename Scalar>
00069   class Vector : public DistObject<Ordinal,Scalar> {
00070 
00071   public:
00072   
00074 
00075 
00077     Vector(const Map<Ordinal> &map);
00078   
00080     Vector(const Teuchos::ArrayView<const Scalar> &values, const Map<Ordinal> & map);
00081 
00083     Vector(const Vector<Ordinal,Scalar> &source);
00084 
00086     ~Vector();
00087 
00089 
00091 
00092 
00094     void submitEntries(const Teuchos::ArrayView<const Ordinal> &indices,
00095                        const Teuchos::ArrayView<const Scalar>  &values);
00096 
00098     void setAllToScalar(const Scalar &value);
00099 
00101     void setAllToRandom();
00102 
00104 
00105 
00107 
00108 
00110     // void extractCopy(Scalar* userArray) const;
00111 
00113     // void extractView(Scalar** userPointerArray) const;
00114 
00116 
00117 
00119 
00120 
00122     Scalar dotProduct(const Vector<Ordinal, Scalar> &x) const;
00123 
00125     void absoluteValue(const Vector<Ordinal,Scalar> &x);
00126 
00128     void reciprocal(const Vector<Ordinal,Scalar> &x);
00129 
00131     void scale(const Scalar &scalarThis);
00132 
00134     void scale(const Scalar &scalarX, const Vector<Ordinal,Scalar> &x);
00135 
00137     void update(const Scalar &scalarX, const Vector<Ordinal,Scalar> &x, const Scalar &scalarThis);
00138 
00140     void update(const Scalar &scalarX, const Vector<Ordinal,Scalar> &x, 
00141                 const Scalar &scalarY, const Vector<Ordinal,Scalar> &y, 
00142                 const Scalar &scalarThis);
00143 
00145     Scalar norm1() const;
00146 
00148     Scalar norm2() const;
00149 
00151     Scalar normInf() const;
00152 
00154     Scalar normWeighted(const Vector<Ordinal,Scalar> &weights) const;
00155 
00157     Scalar minValue() const;
00158 
00160     Scalar maxValue() const;
00161 
00163     Scalar meanValue() const;
00164 
00166 
00167     void elementwiseMultiply(const Scalar &scalarXY, const Vector<Ordinal,Scalar> &x, const Vector<Ordinal,Scalar> &y, 
00168                              const Scalar &scalarThis);
00169 
00171 
00172     void elementwiseReciprocalMultiply(Scalar scalarXY, const Vector<Ordinal, Scalar> &x, const Vector<Ordinal, Scalar> &y, 
00173                                        const Scalar &scalarThis);
00174 
00176 
00177 
00179 
00180 
00182     const Scalar & getSeed() const;
00183 
00185     void setSeed(const Scalar &seed);
00186 
00188 
00189 
00191 
00192 
00194     Scalar& operator[](Ordinal index);
00195 
00197     const Scalar & operator[](Ordinal index) const;
00198 
00200 
00201 
00203 
00204 
00206     Ordinal getNumMyEntries() const;
00207 
00209     Ordinal getNumGlobalEntries() const;
00210 
00212 
00214 
00215 
00217     void print(std::ostream &os) const;
00218 
00219     void printValues(std::ostream &os) const;
00220 
00222 
00224 
00225 
00227     const Map<Ordinal> & getMap() const;
00228 
00230     Vector<Ordinal,Scalar> & operator=(const Vector<Ordinal,Scalar> &source);
00231 
00233 
00235 
00236 
00237     // Returns pointer to Scalar array inside of scalarArray
00238     Teuchos::ArrayView<Scalar> scalarPointer();
00239 
00240     Teuchos::ArrayView<const Scalar> scalarPointer() const;
00241 
00243 
00244   private:
00245 
00246     Teuchos::RCP<VectorData<Ordinal,Scalar> > VectorData_;
00247 
00248     // four functions needed for DistObject derivation
00249     bool checkSizes(const DistObject<Ordinal,Scalar> & sourceObj);
00250 
00251     void copyAndPermute(const DistObject<Ordinal,Scalar> & sourceObj,
00252                Ordinal numSameIDs,
00253                Ordinal numPermuteIDs,
00254                const Teuchos::ArrayView<const Ordinal> & permuteToLIDs,
00255                const Teuchos::ArrayView<const Ordinal> & permuteFromLIDs);
00256 
00257     void packAndPrepare(const DistObject<Ordinal,Scalar> & sourceObj,
00258                Ordinal numExportIDs,
00259                const Teuchos::ArrayView<const Ordinal> & exportLIDs,
00260                const Teuchos::ArrayView<Scalar> & exports,
00261                Ordinal &packetSize,
00262                Distributor<Ordinal> &distor);
00263   
00264     void unpackAndCombine(Ordinal numImportIDs,
00265                const Teuchos::ArrayView<const Ordinal> & importLIDs,
00266                const Teuchos::ArrayView<const Scalar> & imports,
00267                Distributor<Ordinal> &distor,
00268                CombineMode CM);
00269 
00270   }; // class Vector
00271 
00272 } // namespace Tpetra
00273 
00274 #endif // TPETRA_VECTOR_DECL_HPP

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