Tpetra Matrix/Vector Services Version of the Day
Tpetra_MultiVector_decl.hpp
00001 // @HEADER
00002 // ***********************************************************************
00003 //
00004 //          Tpetra: Templated Linear Algebra Services Package
00005 //                 Copyright (2008) Sandia Corporation
00006 //
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00038 //
00039 // ************************************************************************
00040 // @HEADER
00041 
00042 #ifndef TPETRA_MULTIVECTOR_DECL_HPP
00043 #define TPETRA_MULTIVECTOR_DECL_HPP
00044 
00045 #include <Teuchos_DataAccess.hpp>
00046 #include <Teuchos_Range1D.hpp>
00047 #include "Tpetra_ConfigDefs.hpp"
00048 #if TPETRA_USE_KOKKOS_DISTOBJECT
00049 #include "Tpetra_DistObjectKA.hpp"
00050 #else
00051 #include "Tpetra_DistObject.hpp"
00052 #endif
00053 #include "Tpetra_ViewAccepter.hpp"
00054 #include <Kokkos_MultiVector.hpp>
00055 #include <Teuchos_BLAS_types.hpp>
00056 
00057 namespace KokkosClassic {
00058 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00059   // forward declaration of DefaultArithmetic
00060   template<class KokkosMultiVectorType>
00061   class DefaultArithmetic;
00062 #endif // DOXYGEN_SHOULD_SKIP_THIS
00063 } // namespace KokkosClassic
00064 
00065 namespace Tpetra {
00066 
00067 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00068   // forward declaration of Vector, needed to prevent circular inclusions
00069   template<class S, class LO, class GO, class N> class Vector;
00070 
00071   // forward declaration of Map
00072   template<class LO, class GO, class N> class Map;
00073 #endif // DOXYGEN_SHOULD_SKIP_THIS
00074 
00075 
00076   namespace Details {
00085     template<class MultiVectorType>
00086     struct CreateMultiVectorFromView {
00087       typedef typename MultiVectorType::scalar_type scalar_type;
00088       typedef typename MultiVectorType::local_ordinal_type local_ordinal_type;
00089       typedef typename MultiVectorType::global_ordinal_type global_ordinal_type;
00090       typedef typename MultiVectorType::node_type node_type;
00091       typedef ::Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
00092 
00093       static Teuchos::RCP<MultiVectorType>
00094       create (const Teuchos::RCP<const map_type>& map,
00095               const Teuchos::ArrayRCP<scalar_type>& view,
00096               const size_t LDA,
00097               const size_t numVectors);
00098     };
00099   } // namespace Details
00100 
00101 
00350   template<class Scalar,
00351            class LocalOrdinal=int,
00352            class GlobalOrdinal=LocalOrdinal,
00353            class Node=KokkosClassic::DefaultNode::DefaultNodeType>
00354   class MultiVector :
00355 #if TPETRA_USE_KOKKOS_DISTOBJECT
00356     public DistObjectKA<Scalar, LocalOrdinal, GlobalOrdinal, Node>
00357 #else
00358     public DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node>
00359 #endif
00360   {
00361   public:
00363 
00364 
00366     typedef Scalar scalar_type;
00368     typedef LocalOrdinal local_ordinal_type;
00370     typedef GlobalOrdinal global_ordinal_type;
00372     typedef Node node_type;
00374 
00378     typedef Scalar dot_type;
00379 
00380 #if TPETRA_USE_KOKKOS_DISTOBJECT
00381     typedef DistObjectKA<Scalar, LocalOrdinal, GlobalOrdinal, Node> DO;
00382     typedef typename DO::device_type device_type;
00383 #else
00384     typedef DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node> DO;
00385 #endif
00386 
00388 
00389 
00390 
00397     MultiVector (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map,
00398                  size_t NumVectors,
00399                  bool zeroOut=true);
00400 
00402     MultiVector (const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &source);
00403 
00419     MultiVector (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map,
00420                  const Teuchos::ArrayView<const Scalar>& A,
00421                  size_t LDA,
00422                  size_t NumVectors);
00423 
00437     MultiVector (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map,
00438                  const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar> >&ArrayOfPtrs,
00439                  size_t NumVectors);
00440 
00451     MultiVector (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map,
00452                  const Teuchos::ArrayRCP<Scalar>& data,
00453                  const size_t LDA,
00454                  const size_t numVectors);
00455 
00457     template <class Node2>
00458     Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >
00459     clone(const Teuchos::RCP<Node2> &node2) const;
00460 
00462     virtual ~MultiVector();
00463 
00465 
00466 
00467 
00476     void
00477     replaceGlobalValue (GlobalOrdinal globalRow,
00478                         size_t vectorIndex,
00479                         const Scalar &value);
00480 
00489     void
00490     sumIntoGlobalValue (GlobalOrdinal globalRow,
00491                         size_t vectorIndex,
00492                         const Scalar &value);
00493 
00502     void
00503     replaceLocalValue (LocalOrdinal myRow,
00504                        size_t vectorIndex,
00505                        const Scalar &value);
00506 
00515     void
00516     sumIntoLocalValue (LocalOrdinal myRow,
00517                        size_t vectorIndex,
00518                        const Scalar &value);
00519 
00521     void putScalar (const Scalar &value);
00522 
00538     void randomize();
00539 
00605     void replaceMap (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map);
00606 
00613     void reduce();
00614 
00629     MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>&
00630     operator= (const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& source);
00631 
00633 
00648 
00649 
00654     Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
00655     subCopy (const Teuchos::Range1D &colRng) const;
00656 
00658     Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
00659     subCopy (const Teuchos::ArrayView<const size_t> &cols) const;
00660 
00665     Teuchos::RCP<const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
00666     subView (const Teuchos::Range1D &colRng) const;
00667 
00669     Teuchos::RCP<const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
00670     subView (const Teuchos::ArrayView<const size_t> &cols) const;
00671 
00676     Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
00677     subViewNonConst (const Teuchos::Range1D &colRng);
00678 
00680     Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
00681     subViewNonConst (const Teuchos::ArrayView<const size_t> &cols);
00682 
00745     Teuchos::RCP<const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
00746     offsetView (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& subMap,
00747                 size_t offset) const;
00748 
00766     Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
00767     offsetViewNonConst (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > &subMap,
00768                         size_t offset);
00769 
00771     Teuchos::RCP<const Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
00772     getVector (size_t j) const;
00773 
00775     Teuchos::RCP<Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
00776     getVectorNonConst (size_t j);
00777 
00779     Teuchos::ArrayRCP<const Scalar> getData(size_t j) const;
00780 
00782     Teuchos::ArrayRCP<Scalar> getDataNonConst(size_t j);
00783 
00790     void get1dCopy (Teuchos::ArrayView<Scalar> A, size_t LDA) const;
00791 
00797     void get2dCopy (Teuchos::ArrayView<const Teuchos::ArrayView<Scalar> > ArrayOfPtrs) const;
00798 
00804     Teuchos::ArrayRCP<const Scalar> get1dView() const;
00805 
00807     Teuchos::ArrayRCP<Teuchos::ArrayRCP<const Scalar> > get2dView() const;
00808 
00814     Teuchos::ArrayRCP<Scalar> get1dViewNonConst();
00815 
00817     Teuchos::ArrayRCP<Teuchos::ArrayRCP<Scalar> > get2dViewNonConst();
00818 
00820     const KokkosClassic::MultiVector<Scalar,Node> & getLocalMV() const;
00821 
00823     KokkosClassic::MultiVector<Scalar,Node> & getLocalMVNonConst();
00824 
00826 
00827 
00828 
00842     void
00843     dot (const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& A,
00844          const Teuchos::ArrayView<Scalar>& dots) const;
00845 
00847     void abs(const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &A);
00848 
00850     void reciprocal(const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &A);
00851 
00859     void scale (const Scalar &alpha);
00860 
00869     void scale (Teuchos::ArrayView<const Scalar> alpha);
00870 
00879     void
00880     scale (const Scalar& alpha,
00881            const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& A);
00882 
00889     void
00890     update (const Scalar& alpha,
00891             const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& A,
00892             const Scalar& beta);
00893 
00900     void
00901     update (const Scalar& alpha,
00902             const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& A,
00903             const Scalar& beta,
00904             const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& B,
00905             const Scalar& gamma);
00906 
00908     void norm1(const Teuchos::ArrayView<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const;
00909 
00912     void norm2(const Teuchos::ArrayView<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const;
00913 
00915     void normInf(const Teuchos::ArrayView<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const;
00916 
00919     void normWeighted(const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &weights, const Teuchos::ArrayView<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const;
00920 
00923     void meanValue(const Teuchos::ArrayView<Scalar> &means) const;
00924 
00930     void
00931     multiply (Teuchos::ETransp transA,
00932               Teuchos::ETransp transB,
00933               const Scalar& alpha,
00934               const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& A,
00935               const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& B,
00936               const Scalar& beta);
00937 
00958     void
00959     elementWiseMultiply (Scalar scalarAB,
00960                          const Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& A,
00961                          const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& B,
00962                          Scalar scalarThis);
00964 
00965 
00966 
00968     size_t getNumVectors() const;
00969 
00971     size_t getLocalLength() const;
00972 
00974     global_size_t getGlobalLength() const;
00975 
00981     size_t getStride() const;
00982 
00986     bool isConstantStride() const;
00987 
00989 
00991 
00992 
00994     virtual std::string description() const;
00995 
01024     virtual void
01025     describe (Teuchos::FancyOStream& out,
01026               const Teuchos::EVerbosityLevel verbLevel =
01027               Teuchos::Describable::verbLevel_default) const;
01029 
01043     virtual void
01044     removeEmptyProcessesInPlace (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& newMap);
01045 
01046   protected:
01047 
01048     typedef KokkosClassic::MultiVector<Scalar,Node> KMV;
01049     typedef KokkosClassic::DefaultArithmetic<KMV>   MVT;
01050 
01052     KMV lclMV_;
01053 
01066     Array<size_t> whichVectors_;
01067 
01069 
01070 
01071     // Implementation detail of the nonmember "constructor" function
01072     // createMultiVectorFromView.  Please consider this function
01073     // DEPRECATED.
01074     template <class MultiVectorType>
01075     friend struct Details::CreateMultiVectorFromView;
01076 
01088     MultiVector (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map,
01089                  const Teuchos::ArrayRCP<Scalar>& view,
01090                  size_t LDA,
01091                  size_t NumVectors,
01092                  EPrivateHostViewConstructor /* dummy */);
01093 
01094     bool vectorIndexOutOfRange (size_t VectorIndex) const;
01095 
01101     template <class T>
01102     ArrayRCP<T> getSubArrayRCP(ArrayRCP<T> arr, size_t j) const;
01103 
01107     MultiVector (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map,
01108                  Teuchos::ArrayRCP<Scalar> data,
01109                  size_t LDA,
01110                  Teuchos::ArrayView<const size_t> whichVectors,
01111                  EPrivateComputeViewConstructor /* dummy */);
01112 
01116     MultiVector (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map,
01117                  Teuchos::ArrayRCP<Scalar> data,
01118                  size_t LDA,
01119                  size_t NumVectors,
01120                  EPrivateComputeViewConstructor /* dummy */);
01121 
01129     MultiVector (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map,
01130                  const KokkosClassic::MultiVector<Scalar, Node>& localMultiVector,
01131                  EPrivateComputeViewConstructor /* dummy */);
01132 
01140     MultiVector (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map,
01141                  const KokkosClassic::MultiVector<Scalar, Node>& localMultiVector,
01142                  Teuchos::ArrayView<const size_t> whichVectors,
01143                  EPrivateComputeViewConstructor /* dummy */);
01144 
01146 
01147 
01148 
01153     virtual bool
01154     checkSizes (const SrcDistObject& sourceObj);
01155 
01157     virtual size_t constantNumberOfPackets () const;
01158 
01159 #if TPETRA_USE_KOKKOS_DISTOBJECT
01160     virtual void
01161     copyAndPermute (
01162       const SrcDistObject& sourceObj,
01163       size_t numSameIDs,
01164       const Kokkos::View<const LocalOrdinal*, device_type> &permuteToLIDs,
01165       const Kokkos::View<const LocalOrdinal*, device_type> &permuteFromLIDs);
01166 
01167     virtual void
01168     packAndPrepare (
01169       const SrcDistObject& sourceObj,
01170       const Kokkos::View<const LocalOrdinal*, device_type> &exportLIDs,
01171       Kokkos::View<Scalar*, device_type> &exports,
01172       const Kokkos::View<size_t*, device_type> &numPacketsPerLID,
01173       size_t& constantNumPackets,
01174       Distributor &distor);
01175 
01176     virtual void
01177     unpackAndCombine (
01178       const Kokkos::View<const LocalOrdinal*, device_type> &importLIDs,
01179       const Kokkos::View<const Scalar*, device_type> &imports,
01180       const Kokkos::View<size_t*, device_type> &numPacketsPerLID,
01181       size_t constantNumPackets,
01182       Distributor &distor,
01183       CombineMode CM);
01184 #else
01185     virtual void
01186     copyAndPermute (const SrcDistObject& sourceObj,
01187                     size_t numSameIDs,
01188                     const ArrayView<const LocalOrdinal>& permuteToLIDs,
01189                     const ArrayView<const LocalOrdinal>& permuteFromLIDs);
01190 
01191     virtual void
01192     packAndPrepare (const SrcDistObject& sourceObj,
01193                     const ArrayView<const LocalOrdinal>& exportLIDs,
01194                     Array<Scalar>& exports,
01195                     const ArrayView<size_t>& numExportPacketsPerLID,
01196                     size_t& constantNumPackets,
01197                     Distributor& distor);
01198 
01199     virtual void
01200     unpackAndCombine (const ArrayView<const LocalOrdinal>& importLIDs,
01201                       const ArrayView<const Scalar>& imports,
01202                       const ArrayView<size_t>& numPacketsPerLID,
01203                       size_t constantNumPackets,
01204                       Distributor& distor,
01205                       CombineMode CM);
01206 #endif
01207 
01208     void createViews () const;
01209     void createViewsNonConst (KokkosClassic::ReadWriteOption rwo);
01210     void releaseViews () const;
01211 
01213     mutable ArrayRCP<Scalar> ncview_;
01214 
01216     mutable ArrayRCP<const Scalar> cview_;
01217 
01219 
01220 #if TPETRA_USE_KOKKOS_DISTOBJECT
01221 
01222     Kokkos::View<const Scalar*, device_type, Kokkos::MemoryUnmanaged>
01223     getKokkosView() const {
01224       Teuchos::ArrayRCP<const Scalar> buff = MVT::getValues (lclMV_);
01225       Kokkos::View<const Scalar*, device_type, Kokkos::MemoryUnmanaged> v(
01226         buff.getRawPtr(), buff.size());
01227       return v;
01228     }
01229     Kokkos::View<Scalar*, device_type, Kokkos::MemoryUnmanaged>
01230     getKokkosViewNonConst() {
01231       Teuchos::ArrayRCP<Scalar> buff = MVT::getValuesNonConst (lclMV_);
01232       Kokkos::View<Scalar*, device_type, Kokkos::MemoryUnmanaged> v(
01233         buff.getRawPtr(), buff.size());
01234       return v;
01235     }
01236 
01237 #endif
01238   };
01239 
01240 
01243   template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
01244   MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>
01245   createCopy (const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& src);
01246 
01247 
01265   template <class DS, class DL, class DG, class DN,
01266             class SS, class SL, class SG, class SN>
01267   void
01268   deep_copy (MultiVector<DS,DL,DG,DN>& dst,
01269              const MultiVector<SS,SL,SG,SN>& src);
01270 
01271 
01272   template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
01273   template <class Node2>
01274   Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >
01275   MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
01276   clone (const RCP<Node2> &node2) const
01277   {
01278     using Teuchos::ArrayRCP;
01279     using Teuchos::RCP;
01280     using Teuchos::rcp;
01281     typedef Map<LocalOrdinal, GlobalOrdinal, Node2> Map2;
01282     typedef MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node2> MV2;
01283 
01284     ArrayRCP<ArrayRCP<const Scalar> > MV_view = this->get2dView ();
01285     RCP<const Map2> clonedMap = this->getMap ()->template clone<Node2> (node2);
01286     RCP<MV2> clonedMV = rcp (new MV2 (clonedMap, this->getNumVectors ()));
01287     ArrayRCP<ArrayRCP<Scalar> > clonedMV_view = clonedMV->get2dViewNonConst ();
01288     for (size_t j = 0; j < this->getNumVectors (); ++j) {
01289       clonedMV_view[j].deepCopy (MV_view[j] ());
01290     }
01291     clonedMV_view = Teuchos::null;
01292     return clonedMV;
01293   }
01294 
01295 
01296   namespace Details {
01297     template<class MultiVectorType>
01298     Teuchos::RCP<MultiVectorType>
01299     CreateMultiVectorFromView<MultiVectorType>::
01300     create (const Teuchos::RCP<const map_type>& map,
01301             const Teuchos::ArrayRCP<scalar_type>& view,
01302             const size_t LDA,
01303             const size_t numVectors)
01304     {
01305       using Teuchos::rcp;
01306       typedef Tpetra::details::ViewAccepter<node_type> VAN;
01307 
01308       // This uses a protected MultiVector constructor, but this
01309       // nonmember function was declared a friend of MultiVector.
01310       //
01311       // The ViewAccepter expression will fail to compile for
01312       // unsupported Kokkos Node types.
01313       return rcp (new MultiVectorType (map, VAN::template acceptView<scalar_type> (view),
01314                                        LDA, numVectors, HOST_VIEW_CONSTRUCTOR));
01315     }
01316   } // namespace Details
01317 
01326   template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
01327   Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
01328   createMultiVector (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map,
01329                      const size_t numVectors)
01330   {
01331     using Teuchos::rcp;
01332     typedef MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> MV;
01333 
01334     const bool initToZero = true;
01335     return rcp (new MV (map, numVectors, initToZero));
01336   }
01337 
01338 } // namespace Tpetra
01339 
01340 // Include KokkosRefactor partial specialization if enabled
01341 #if defined(TPETRA_HAVE_KOKKOS_REFACTOR)
01342 #include "Tpetra_KokkosRefactor_MultiVector_decl.hpp"
01343 #endif
01344 
01345 // Define createMultiVectorFromView after the above include, so that
01346 // the function can pick up the partial specialization of
01347 // CreateMultiVectorFromView.
01348 
01349 namespace Tpetra {
01350 
01376   template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
01377   Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
01378   createMultiVectorFromView (const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& map,
01379                              const Teuchos::ArrayRCP<Scalar>& view,
01380                              const size_t LDA,
01381                              const size_t numVectors)
01382   {
01383     typedef MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> mv_type;
01384     typedef Details::CreateMultiVectorFromView<mv_type> impl_type;
01385     return impl_type::create (map, view, LDA, numVectors);
01386   }
01387 
01388 } // namespace Tpetra
01389 
01390 #endif // TPETRA_MULTIVECTOR_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines