ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Macros | Functions
indexing_stable.hpp File Reference
#include <vector>
#include <algorithm>
#include <utility>
#include <boost/unordered_map.hpp>
#include <boost/container/flat_set.hpp>
#include <boost/container/flat_map.hpp>
#include <boost/array.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/serialization/vector.hpp>

Go to the source code of this file.

Classes

struct  index_detail::gt< SymmGroup >
 
class  index_detail::is_first_equal< SymmGroup >
 
class  basis_iterator_< SymmGroup >
 
class  Index< SymmGroup >
 
class  ProductBasis< SymmGroup >
 
class  basis_iterator_< SymmGroup >
 

Namespaces

 index_detail
 

Macros

#define IMPL_COMMA(tpl, type)
 
#define IMPL_COMMA_2(tpl, type)
 
#define CO   ,
 

Functions

template<class SymmGroup >
bool index_detail::lt (std::pair< typename SymmGroup::charge, std::size_t > const &a, std::pair< typename SymmGroup::charge, std::size_t > const &b)
 
template<class SymmGroup >
SymmGroup::charge index_detail::get_first (std::pair< typename SymmGroup::charge, std::size_t > const &x)
 
template<class SymmGroup >
std::size_t index_detail::get_second (std::pair< typename SymmGroup::charge, std::size_t > const &x)
 
template<class SymmGroup >
basis_iterator_< SymmGroup > operator+ (basis_iterator_< SymmGroup > it, std::size_t p)
 
template<class SymmGroup >
bool weak_equal (Index< SymmGroup > const &a, Index< SymmGroup > const &b)
 
template<class SymmGroup >
Index< SymmGroup > adjoin (Index< SymmGroup > const &inp)
 
template<class SymmGroup >
std::ostream & operator<< (std::ostream &os, Index< SymmGroup > const &idx)
 
template<class SymmGroup >
Index< SymmGroup > operator* (Index< SymmGroup > const &i1, Index< SymmGroup > const &i2)
 
template<class SymmGroup >
Index< SymmGroup > common_subset (Index< SymmGroup > &a, Index< SymmGroup > &b)
 
template<class charge >
std::pair< charge, std::size_t > operator- (std::pair< charge, std::size_t > const &p)
 
template<class T >
boost::array< T, 1 > _ (T const &a)
 
template<class T >
boost::array< T, 2 > _ (T const &a, T const &b)
 
template<class T , unsigned long L>
boost::array< T, L+1 > operator^ (boost::array< T, L > const &a, T const &b)
 
template<class T , unsigned long L>
boost::array< T, L+1 > operator^ (T const &a, boost::array< T, L > const &b)
 

Macro Definition Documentation

#define CO   ,

Definition at line 581 of file indexing_stable.hpp.

#define IMPL_COMMA (   tpl,
  type 
)
Value:
tpl boost::array<type, 2> operator^(type const & a, type const & b) { \
boost::array<type, 2> ret; \
ret[0] = a; \
ret[1] = b; \
return ret; \
}
boost::array< T, L+1 > operator^(boost::array< T, L > const &a, T const &b)

Definition at line 566 of file indexing_stable.hpp.

#define IMPL_COMMA_2 (   tpl,
  type 
)
Value:
tpl boost::array<type, L+1> operator^(boost::array<type, L> const & a, type const & b) { \
boost::array<type, L+1> ret; \
std::copy(a.begin(), a.end(), ret.begin()); \
ret[L] = b; \
return ret; \
}
boost::array< T, L+1 > operator^(boost::array< T, L > const &a, T const &b)

Definition at line 573 of file indexing_stable.hpp.

Function Documentation

template<class T >
boost::array<T, 1> _ ( T const &  a)

Definition at line 551 of file indexing_stable.hpp.

552 {
553  boost::array<T, 1> r;
554  r[0] = a;
555  return r;
556 }
template<class T >
boost::array<T, 2> _ ( T const &  a,
T const &  b 
)

Definition at line 558 of file indexing_stable.hpp.

559 {
560  boost::array<T, 2> r;
561  r[0] = a;
562  r[1] = b;
563  return r;
564 }
template<class SymmGroup >
Index<SymmGroup> adjoin ( Index< SymmGroup > const &  inp)

Definition at line 469 of file indexing_stable.hpp.

470 {
471  typedef typename SymmGroup::charge charge;
472 
473  std::vector<charge> oc = inp.charges(), nc = inp.charges();
474  std::transform(nc.begin(), nc.end(), nc.begin(), std::negate<charge>());
475  std::sort(nc.begin(), nc.end());
476 
477  std::vector<std::size_t> nd(inp.size()), od = inp.sizes();
478  for (unsigned int i = 0; i < nd.size(); ++i)
479  nd[i] = od[std::find(oc.begin(), oc.end(),
480  -nc[i])-oc.begin()];
481 
482  Index<SymmGroup> ret;
483  for (size_t i=0; i<nc.size(); ++i)
484 #if not defined(WIN32) && not defined(WIN64)
485  ret.insert(std::make_pair(nc[i], nd[i]));
486 #else
487  ret.insert(mypair(nc[i], nd[i]));
488 #endif
489  return ret;
490 }
std::vector< std::size_t > sizes() const
std::size_t insert(std::pair< charge, std::size_t > const &x)
std::size_t size() const
std::vector< charge > charges() const
template<class SymmGroup >
Index<SymmGroup> common_subset ( Index< SymmGroup > &  a,
Index< SymmGroup > &  b 
)

Definition at line 530 of file indexing_stable.hpp.

532 {
533  a.erase(std::remove_if(a.begin(), a.end(),
534  !boost::lambda::bind(&Index<SymmGroup>::has, b,
535  boost::lambda::bind(index_detail::get_first<SymmGroup>, boost::lambda::_1))),
536  a.end());
537 
538  b.erase(std::remove_if(b.begin(), b.end(),
539  !boost::lambda::bind(&Index<SymmGroup>::has, a,
540  boost::lambda::bind(index_detail::get_first<SymmGroup>, boost::lambda::_1))),
541  b.end());
542  return a;
543 }
iterator begin()
iterator erase(iterator p)
iterator end()
template<class SymmGroup >
Index<SymmGroup> operator* ( Index< SymmGroup > const &  i1,
Index< SymmGroup > const &  i2 
)

Definition at line 508 of file indexing_stable.hpp.

510 {
511  typedef typename SymmGroup::charge charge;
512 
513  Index<SymmGroup> ret;
514  for (typename Index<SymmGroup>::const_iterator it1 = i1.begin(); it1 != i1.end(); ++it1)
515  for (typename Index<SymmGroup>::const_iterator it2 = i2.begin(); it2 != i2.end(); ++it2)
516  {
517  charge pdc = SymmGroup::fuse(it1->first, it2->first);
518  std::size_t ps = it1->second * it2->second;
519  std::size_t match = ret.position(pdc);
520  if (match < ret.size())
521  ret[match].second += ps;
522  else
523  ret.insert(std::make_pair(pdc, ps));
524  }
525  ret.sort();
526  return ret;
527 }
void sort()
base_t::const_iterator const_iterator
iterator begin()
iterator end()
std::size_t position(charge c) const
std::size_t insert(std::pair< charge, std::size_t > const &x)
std::size_t size() const
T fuse(const A &ind, T d)
Fuse indices n[i] into one p = n[i] d^i.
template<class SymmGroup >
basis_iterator_<SymmGroup> operator+ ( basis_iterator_< SymmGroup >  it,
std::size_t  p 
)

Definition at line 446 of file indexing_stable.hpp.

447 {
448  for ( ; p > 0; --p)
449  ++it;
450  return it;
451 }
template<class charge >
std::pair<charge, std::size_t> operator- ( std::pair< charge, std::size_t > const &  p)

Definition at line 546 of file indexing_stable.hpp.

547 {
548  return std::make_pair(-p.first, p.second);
549 }
template<class SymmGroup >
std::ostream& operator<< ( std::ostream &  os,
Index< SymmGroup > const &  idx 
)

Definition at line 493 of file indexing_stable.hpp.

494 {
495  os << "|";
496  for (typename Index<SymmGroup>::const_iterator it = idx.begin();
497  it != idx.end();
498  ++it)
499  {
500  os << "( " << it->first << ": " << it->second << " )";
501  }
502  os << "|";
503 
504  return os;
505 }
base_t::const_iterator const_iterator
iterator begin()
iterator end()
template<class T , unsigned long L>
boost::array<T, L+1> operator^ ( boost::array< T, L > const &  a,
T const &  b 
)

Definition at line 591 of file indexing_stable.hpp.

592 {
593  boost::array<T, L+1> ret;
594  std::copy(a.begin(), a.end(), ret.begin());
595  ret[L] = b;
596  return ret;
597 }
template<class T , unsigned long L>
boost::array<T, L+1> operator^ ( T const &  a,
boost::array< T, L > const &  b 
)

Definition at line 600 of file indexing_stable.hpp.

601 {
602  boost::array<T, L+1> ret;
603  ret[0] = a;
604  for (int i = 0; i < L; i++)
605  ret[i+1] = b[i];
606  return ret;
607 }
template<class SymmGroup >
bool weak_equal ( Index< SymmGroup > const &  a,
Index< SymmGroup > const &  b 
)

Definition at line 463 of file indexing_stable.hpp.

464 {
465  return (a == b);
466 }