ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Types | List of all members
KronHandler< Matrix, SymmGroup > Class Template Reference

#include <op_handler.h>

Inheritance diagram for KronHandler< Matrix, SymmGroup >:
TagHandler< Matrix, SymmGroup >

Public Member Functions

 KronHandler (boost::shared_ptr< OPTable< Matrix, SymmGroup > > tbl_)
 
tag_type get_kron_tag (Index< SymmGroup > const &phys_i1, Index< SymmGroup > const &phys_i2, tag_type t1, tag_type t2)
 
OPTable< Matrix, SymmGroup >
::value_type
get_op (tag_type i)
 
OPTable< Matrix, SymmGroup >
::value_type const & 
get_op (tag_type i) const
 
bool is_uniform (tag_type t)
 
boost::shared_ptr< OPTable
< Matrix, SymmGroup > > 
get_kronecker_table ()
 
tag_type get_num_kron_products () const
 
tag_type register_op (const op_t &op_, tag_detail::operator_kind kind)
 
std::pair< tag_type, value_typechecked_register (op_t const &sample, tag_detail::operator_kind kind)
 
bool is_fermionic (tag_type query_tag) const
 
std::pair< tag_type, value_typeget_product_tag (const tag_type t1, const tag_type t2)
 
tag_type prod_duplicates () const
 
tag_type get_num_products () const
 
tag_type total_size () const
 
boost::shared_ptr< OPTable
< Matrix, SymmGroup > > 
get_operator_table ()
 
template<class Map >
OPTable< Matrix, SymmGroup >
::tag_type 
duplicates_ (Map const &sample)
 

Protected Types

typedef Matrix::value_type value_type
 
typedef std::map< std::pair
< tag_type, tag_type >
, std::pair< tag_type,
value_type >
, tag_detail::pair_cmp
pair_map_t
 
typedef pair_map_t::const_iterator pair_map_it_t
 

Detailed Description

template<class Matrix, class SymmGroup>
class KronHandler< Matrix, SymmGroup >

Definition at line 141 of file op_handler.h.

Member Typedef Documentation

template<class Matrix, class SymmGroup>
typedef pair_map_t::const_iterator TagHandler< Matrix, SymmGroup >::pair_map_it_t
protectedinherited

Definition at line 67 of file op_handler.h.

template<class Matrix, class SymmGroup>
typedef std::map<std::pair<tag_type, tag_type>, std::pair<tag_type, value_type>, tag_detail::pair_cmp> TagHandler< Matrix, SymmGroup >::pair_map_t
protectedinherited

Definition at line 66 of file op_handler.h.

template<class Matrix, class SymmGroup>
typedef Matrix::value_type TagHandler< Matrix, SymmGroup >::value_type
protectedinherited

Definition at line 65 of file op_handler.h.

Constructor & Destructor Documentation

template<class Matrix, class SymmGroup>
KronHandler< Matrix, SymmGroup >::KronHandler ( boost::shared_ptr< OPTable< Matrix, SymmGroup > >  tbl_)
inline

Definition at line 149 of file op_handler.h.

150  : base(tbl_)
151  , kronecker_table(new OPTable<Matrix, SymmGroup>())
152  {
153  for (typename OPTable<Matrix, SymmGroup>::iterator it = tbl_->begin();
154  it != tbl_->end(); ++it)
155  uniform.push_back(tag_detail::is_uniform(*it));
156  }
bool is_uniform(block_matrix< Matrix, SymmGroup > const &op)
Definition: tag_detail.h:77

Member Function Documentation

template<class Matrix, class SymmGroup>
std::pair<tag_type, value_type> TagHandler< Matrix, SymmGroup >::checked_register ( op_t const &  sample,
tag_detail::operator_kind  kind 
)
inlineinherited

Definition at line 80 of file op_handler.h.

80  {
81  std::pair<tag_type, value_type> ret = operator_table->checked_register(sample);
82  if (sign_table.size() < operator_table->size())
83  sign_table.push_back(kind);
84 
85  assert(sign_table.size() == operator_table->size());
86 
87  return ret;
88  }
template<class Matrix, class SymmGroup>
template<class Map >
OPTable<Matrix, SymmGroup>::tag_type TagHandler< Matrix, SymmGroup >::duplicates_ ( Map const &  sample)
inherited

Definition at line 128 of file op_handler.hpp.

128  {
129  typedef typename Map::const_iterator it_t;
130 
131  std::vector<tag_type> unique_ops;
132  for (it_t it_s = sample.begin(); it_s != sample.end(); ++it_s)
133  {
134  bool unique = true;
135  for (typename std::vector<tag_type>::iterator it_unique = unique_ops.begin(); it_unique != unique_ops.end(); ++it_unique)
136  if (equal((*operator_table)[(*it_s).second.first], (*operator_table)[*it_unique]).first)
137  {
138  unique = false;
139  break;
140  }
141 
142  if (unique)
143  unique_ops.push_back((*it_s).second.first);
144  }
145 
146  return sample.size() - unique_ops.size();
147 }
std::pair< bool, typename Matrix::value_type > equal(block_matrix< Matrix, SymmGroup > const &reference, block_matrix< Matrix, SymmGroup > const &sample)
Definition: tag_detail.h:120
template<class Matrix, class SymmGroup>
OPTable< Matrix, SymmGroup >::tag_type KronHandler< Matrix, SymmGroup >::get_kron_tag ( Index< SymmGroup > const &  phys_i1,
Index< SymmGroup > const &  phys_i2,
tag_type  t1,
tag_type  t2 
)

Definition at line 160 of file op_handler.hpp.

165 {
166  assert( t1 < base::get_operator_table()->size() && t2 < base::get_operator_table()->size() );
167 
168  // return tag of kronecker product, if already there
169  try {
170 #if defined(__xlC__) || defined(__FCC_VERSION)
171  if (kron_tags.count(std::make_pair(t1, t2)) == 0)
172  throw std::out_of_range("");
173 
174  return kron_tags[std::make_pair(t1, t2)].first;
175 #else
176  return kron_tags.at(std::make_pair(t1, t2)).first;
177 #endif
178  }
179  // compute and register the product, then return the new tag
180  catch(const std::out_of_range& e) {
181 
182  op_t product;
183  op_t& op1 = (*base::get_operator_table())[t1];
184  op_t& op2 = (*base::get_operator_table())[t2];
185 
186  op_kron(phys_i1, phys_i2, op1, op2, product);
187 
189 
190  tag_type ret = kronecker_table->register_op(product);
191  kron_tags[std::make_pair(t1, t2)] = std::make_pair(ret, 1.0);
192 
193  return ret;
194  }
195 }
boost::shared_ptr< OPTable< Matrix, SymmGroup > > get_operator_table()
Definition: op_handler.h:128
void remove_empty_blocks(block_matrix< Matrix, SymmGroup > &op)
Definition: tag_detail.h:55
void op_kron(Index< SymmGroup > const &phys_A, Index< SymmGroup > const &phys_B, block_matrix< Matrix1, SymmGroup > const &A, block_matrix< Matrix1, SymmGroup > const &B, block_matrix< Matrix2, SymmGroup > &C)
unsigned tag_type
Definition: tag_detail.h:36
template<class Matrix, class SymmGroup>
boost::shared_ptr<OPTable<Matrix, SymmGroup> > KronHandler< Matrix, SymmGroup >::get_kronecker_table ( )
inline

Definition at line 166 of file op_handler.h.

166 { return kronecker_table; }
template<class Matrix , class SymmGroup >
OPTable< Matrix, SymmGroup >::tag_type KronHandler< Matrix, SymmGroup >::get_num_kron_products ( ) const

Definition at line 198 of file op_handler.hpp.

198  {
199  return kronecker_table->size();
200 }
template<class Matrix , class SymmGroup >
OPTable< Matrix, SymmGroup >::tag_type TagHandler< Matrix, SymmGroup >::get_num_products ( ) const
inherited

Definition at line 150 of file op_handler.hpp.

150  {
151  std::set<tag_type> utags;
152  for (pair_map_it_t it = product_tags.begin(); it != product_tags.end(); ++it)
153  utags.insert(it->second.first);
154 
155  return utags.size();
156 }
pair_map_t::const_iterator pair_map_it_t
Definition: op_handler.h:67
template<class Matrix, class SymmGroup>
OPTable<Matrix, SymmGroup>::value_type& KronHandler< Matrix, SymmGroup >::get_op ( tag_type  i)
inline

Definition at line 161 of file op_handler.h.

161 { return (*kronecker_table)[i]; }
template<class Matrix, class SymmGroup>
OPTable<Matrix, SymmGroup>::value_type const& KronHandler< Matrix, SymmGroup >::get_op ( tag_type  i) const
inline

Definition at line 162 of file op_handler.h.

162 { return (*kronecker_table)[i]; }
template<class Matrix, class SymmGroup>
boost::shared_ptr<OPTable<Matrix, SymmGroup> > TagHandler< Matrix, SymmGroup >::get_operator_table ( )
inlineinherited

Definition at line 128 of file op_handler.h.

128 { return operator_table; }
template<class Matrix, class SymmGroup>
std::pair< typename OPTable< Matrix, SymmGroup >::tag_type, typename TagHandler< Matrix, SymmGroup >::value_type > TagHandler< Matrix, SymmGroup >::get_product_tag ( const tag_type  t1,
const tag_type  t2 
)
inherited

Definition at line 88 of file op_handler.hpp.

92 {
93  assert( t1 < operator_table->size() && t2 < operator_table->size() );
94 
95  // return tag of product, if already there
96  try {
97 #if defined(__xlC__) || defined(__FCC_VERSION)
98  if (product_tags.count(std::make_pair(t1, t2)) == 0)
99  throw std::out_of_range("");
100 
101  return product_tags[std::make_pair(t1, t2)];
102 #else
103  return product_tags.at(std::make_pair(t1, t2));
104 #endif
105  }
106 
107  // compute and register the product, then return the new tag
108  catch(const std::out_of_range& e) {
109 
110  op_t product;
111  op_t& op1 = (*operator_table)[t1];
112  op_t& op2 = (*operator_table)[t2];
113 
114  gemm(op1, op2, product);
116  if (sign_table[t1] != sign_table[t2])
117  prod_kind = tag_detail::fermionic;
118 
119  std::pair<tag_type, value_type> ret = this->checked_register(product, prod_kind);
120  product_tags[std::make_pair(t1, t2)] = ret;
121  return ret;
122  }
123 }
OPTable< Matrix, SymmGroup >::op_t op_t
Definition: op_handler.h:62
std::pair< tag_type, value_type > checked_register(op_t const &sample, tag_detail::operator_kind kind)
Definition: op_handler.h:80
void gemm(block_matrix< Matrix1, SymmGroup > const &A, block_matrix< Matrix2, SymmGroup > const &B, block_matrix< Matrix3, SymmGroup > &C)
template<class Matrix, class SymmGroup>
bool TagHandler< Matrix, SymmGroup >::is_fermionic ( tag_type  query_tag) const
inlineinherited

Definition at line 115 of file op_handler.h.

115 { return sign_table[query_tag]; }
template<class Matrix, class SymmGroup>
bool KronHandler< Matrix, SymmGroup >::is_uniform ( tag_type  t)
inline

Definition at line 164 of file op_handler.h.

164 { return uniform[t]; }
template<class Matrix, class SymmGroup>
tag_type TagHandler< Matrix, SymmGroup >::prod_duplicates ( ) const
inlineinherited

Definition at line 122 of file op_handler.h.

122 { return duplicates_(product_tags); }
template<class Matrix , class SymmGroup >
OPTable< Matrix, SymmGroup >::tag_type TagHandler< Matrix, SymmGroup >::register_op ( const op_t op_,
tag_detail::operator_kind  kind 
)
inherited

Definition at line 60 of file op_handler.hpp.

60  {
61  sign_table.push_back(kind);
62  return operator_table->register_op(op_);
63 }
template<class Matrix, class SymmGroup>
tag_type TagHandler< Matrix, SymmGroup >::total_size ( ) const
inlineinherited

Definition at line 125 of file op_handler.h.

125 { return operator_table->size(); }

The documentation for this class was generated from the following files: