ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
anasazi_solver.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * ALPS MPS DMRG Project
4  *
5  * Copyright (C) 2013 Institute for Theoretical Physics, ETH Zurich
6  * 2011-2011 by Bela Bauer <bauerb@phys.ethz.ch>
7  *
8  * This software is part of the ALPS Applications, published under the ALPS
9  * Application License; you can use, redistribute it and/or modify it under
10  * the terms of the license, either version 1 or (at your option) any later
11  * version.
12  *
13  * You should have received a copy of the ALPS Application License along with
14  * the ALPS Applications; see the file LICENSE.txt. If not, the license is also
15  * available from http://alps.comp-phys.org/.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23  * DEALINGS IN THE SOFTWARE.
24  *
25  *****************************************************************************/
26 
27 #ifndef ANASAZI_MULTI_VEC_TRAITS_HPP
28 #define ANASAZI_MULTI_VEC_TRAITS_HPP
29 
30 #include "AnasaziConfigDefs.hpp"
31 #include "AnasaziTypes.hpp"
32 #include "Teuchos_RCP.hpp"
33 #include "Teuchos_SerialDenseMatrix.hpp"
34 
35 #include <boost/shared_ptr.hpp>
36 #include <boost/noncopyable.hpp>
37 
38 namespace Anasazi {
39 
40  // They want a shallow copy...what a bunch of morons
41  // To avoid confusion, I derive from noncopyable
42 
43  template<class Vector>
44  class IETLMultMv : public boost::noncopyable
45  {
46  public:
47  typedef typename std::vector<boost::shared_ptr<Vector> > data_type;
49 
50  IETLMultMv(std::size_t k = 0) : data(k) { }
51  }
52 
53  template< class ScalarType, class MV >
54  struct UndefinedMultiVecTraits
55  {
56  static inline ScalarType notDefined() { return MV::this_type_is_missing_a_specialization(); };
57  };
58 
59  template<class ScalarType, class Vector>
60  class MultiVecTraits<double, IETLMultMv<Vector> >
61  {
62  typedef IETLMultMv<Vector> MV;
63 
64  public:
65  static Teuchos::RCP<MV> Clone( const MV& mv, const int numvecs )
66  {
67  MV * ret = new MV(numvecs);
68  for (int k = 0; i < numvecs; ++k)
69  // any ideas how to get the vectorspacee?
70  MV->data[i].reset( new Vector(mv.data[0]) );
71  return Teuchos::RCP<MV>(ret);
72  }
73 
74  static Teuchos::RCP<MV> CloneCopy( const MV& mv )
75  {
76  MV * ret = new MV(mv.data.size());
77  for (int k = 0; i < numvecs; ++k)
78  ret->data[i].reset( new Vector(mv.data[k]) );
79  return Teuchos::RCP<MV>(ret);
80  }
81 
82  static Teuchos::RCP<MV> CloneCopy( const MV& mv, const std::vector<int>& index )
83  {
84  MV * ret = new MV(index.size());
85  for (int k = 0; k < index.size(); ++k)
86  ret->data[k].reset( new Vector(mv->data[index[k]]) );
87  return Teuchos::RCP<MV>(ret);
88  }
89 
90  static Teuchos::RCP<MV> CloneViewNonConst( MV& mv, const std::vector<int>& index )
91  {
92  MV * ret = new MV(index.size());
93  for (int k = 0; k < index.size(); ++k)
94  ret->data[k] = mv->data[k];
95  return Teuchos::RCP<MV>(ret);
96  }
97 
98  static Teuchos::RCP<const MV> CloneView( const MV& mv, const std::vector<int>& index )
99  {
100  MV * ret = new MV(index.size());
101  for (int k = 0; k < index.size(); ++k)
102  ret->data[k] = mv->data[k];
103  return Teuchos::RCP<MV>(ret);
104  }
105 
106  static int GetVecLength( const MV& mv )
107  {
108  return 0;
109  }
110 
111  static int GetNumberVecs( const MV& mv )
112  {
113  return mv.data.size();
114  }
115 
116 
117  static void MvTimesMatAddMv(const ScalarType alpha, const MV& A,
118  const Teuchos::SerialDenseMatrix<int,ScalarType>& B,
119  const ScalarType beta, MV& mv )
121 
122  static void MvAddMv( const ScalarType alpha, const MV& A, const ScalarType beta, const MV& B, MV& mv )
124 
125  static void MvScale ( MV& mv, const ScalarType alpha )
127 
128  static void MvScale ( MV& mv, const std::vector<ScalarType>& alpha )
130 
131  static void MvTransMv( const ScalarType alpha, const MV& A, const MV& mv, Teuchos::SerialDenseMatrix<int,ScalarType>& B)
133 
134  static void MvDot ( const MV& mv, const MV& A, std::vector<ScalarType> &b)
136 
137 
138 
139 
140  static void MvNorm( const MV& mv, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> &normvec )
142 
143 
144 
145 
146  static void SetBlock( const MV& A, const std::vector<int>& index, MV& mv )
148 
149  static void MvRandom( MV& mv )
151 
152  static void MvInit( MV& mv, const ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero() )
154 
155 
156 
157 
158  static void MvPrint( const MV& mv, std::ostream& os )
160 
161  };
162 
163 } // namespace Anasazi
164 
165 #endif // ANASAZI_MULTI_VEC_TRAITS_HPP
std::vector< boost::shared_ptr< Vector > > data_type
static Teuchos::RCP< MV > CloneCopy(const MV &mv, const std::vector< int > &index)
Anasazi::IETLMultMv boost::noncopyable notDefined()
class Anasazi::MultiVecTraits< double, IETLMultMv< Vector > > notDefined
static void MvTransMv(const ScalarType alpha, const MV &A, const MV &mv, Teuchos::SerialDenseMatrix< int, ScalarType > &B)
static Teuchos::RCP< const MV > CloneView(const MV &mv, const std::vector< int > &index)
static void MvNorm(const MV &mv, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec)
static Teuchos::RCP< MV > CloneCopy(const MV &mv)
static void SetBlock(const MV &A, const std::vector< int > &index, MV &mv)
static void MvDot(const MV &mv, const MV &A, std::vector< ScalarType > &b)
static void MvTimesMatAddMv(const ScalarType alpha, const MV &A, const Teuchos::SerialDenseMatrix< int, ScalarType > &B, const ScalarType beta, MV &mv)
static void MvPrint(const MV &mv, std::ostream &os)
static void MvScale(MV &mv, const ScalarType alpha)
static void MvAddMv(const ScalarType alpha, const MV &A, const ScalarType beta, const MV &B, MV &mv)
Anasazi::IETLMultMv ScalarType
static Teuchos::RCP< MV > Clone(const MV &mv, const int numvecs)
static void MvScale(MV &mv, const std::vector< ScalarType > &alpha)
IETLMultMv(std::size_t k=0)
static Teuchos::RCP< MV > CloneViewNonConst(MV &mv, const std::vector< int > &index)
static void MvInit(MV &mv, const ScalarType alpha=Teuchos::ScalarTraits< ScalarType >::zero())