ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Macros | Functions
indexing_sorted.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 584 of file indexing_sorted.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 569 of file indexing_sorted.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 576 of file indexing_sorted.hpp.

Function Documentation

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

Definition at line 554 of file indexing_sorted.hpp.

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

Definition at line 561 of file indexing_sorted.hpp.

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

Definition at line 472 of file indexing_sorted.hpp.

473 {
474  typedef typename SymmGroup::charge charge;
475 
476  std::vector<charge> oc = inp.charges(), nc = inp.charges();
477  std::transform(nc.begin(), nc.end(), nc.begin(), std::negate<charge>());
478  std::sort(nc.begin(), nc.end());
479 
480  std::vector<std::size_t> nd(inp.size()), od = inp.sizes();
481  for (unsigned int i = 0; i < nd.size(); ++i)
482  nd[i] = od[std::find(oc.begin(), oc.end(),
483  -nc[i])-oc.begin()];
484 
485  Index<SymmGroup> ret;
486  for (size_t i=0; i<nc.size(); ++i)
487 #if not defined(WIN32) && not defined(WIN64)
488  ret.insert(std::make_pair(nc[i], nd[i]));
489 #else
490  ret.insert(mypair(nc[i], nd[i]));
491 #endif
492  return ret;
493 }
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 533 of file indexing_sorted.hpp.

535 {
536  a.erase(std::remove_if(a.begin(), a.end(),
537  !boost::lambda::bind(&Index<SymmGroup>::has, b,
538  boost::lambda::bind(index_detail::get_first<SymmGroup>, boost::lambda::_1))),
539  a.end());
540 
541  b.erase(std::remove_if(b.begin(), b.end(),
542  !boost::lambda::bind(&Index<SymmGroup>::has, a,
543  boost::lambda::bind(index_detail::get_first<SymmGroup>, boost::lambda::_1))),
544  b.end());
545  return a;
546 }
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 511 of file indexing_sorted.hpp.

513 {
514  typedef typename SymmGroup::charge charge;
515 
516  Index<SymmGroup> ret;
517  for (typename Index<SymmGroup>::const_iterator it1 = i1.begin(); it1 != i1.end(); ++it1)
518  for (typename Index<SymmGroup>::const_iterator it2 = i2.begin(); it2 != i2.end(); ++it2)
519  {
520  charge pdc = SymmGroup::fuse(it1->first, it2->first);
521  std::size_t ps = it1->second * it2->second;
522  std::size_t match = ret.position(pdc);
523  if (match < ret.size())
524  ret[match].second += ps;
525  else
526  ret.insert(std::make_pair(pdc, ps));
527  }
528  ret.sort();
529  return ret;
530 }
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 449 of file indexing_sorted.hpp.

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

Definition at line 549 of file indexing_sorted.hpp.

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

Definition at line 496 of file indexing_sorted.hpp.

497 {
498  os << "|";
499  for (typename Index<SymmGroup>::const_iterator it = idx.begin();
500  it != idx.end();
501  ++it)
502  {
503  os << "( " << it->first << ": " << it->second << " )";
504  }
505  os << "|";
506 
507  return os;
508 }
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 594 of file indexing_sorted.hpp.

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

Definition at line 603 of file indexing_sorted.hpp.

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

Definition at line 466 of file indexing_sorted.hpp.

467 {
468  return (a == b);
469 }