ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Macros | Functions
indexing_unsorted.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 578 of file indexing_unsorted.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 563 of file indexing_unsorted.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 570 of file indexing_unsorted.hpp.

Function Documentation

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

Definition at line 548 of file indexing_unsorted.hpp.

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

Definition at line 555 of file indexing_unsorted.hpp.

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

Definition at line 466 of file indexing_unsorted.hpp.

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

529 {
530  a.erase(std::remove_if(a.begin(), a.end(),
531  !boost::lambda::bind(&Index<SymmGroup>::has, b,
532  boost::lambda::bind(index_detail::get_first<SymmGroup>, boost::lambda::_1))),
533  a.end());
534 
535  b.erase(std::remove_if(b.begin(), b.end(),
536  !boost::lambda::bind(&Index<SymmGroup>::has, a,
537  boost::lambda::bind(index_detail::get_first<SymmGroup>, boost::lambda::_1))),
538  b.end());
539  return a;
540 }
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 506 of file indexing_unsorted.hpp.

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

440 {
441  for ( ; p > 0; --p)
442  ++it;
443  return it;
444 }
template<class charge >
std::pair<charge, std::size_t> operator- ( std::pair< charge, std::size_t > const &  p)

Definition at line 543 of file indexing_unsorted.hpp.

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

Definition at line 491 of file indexing_unsorted.hpp.

492 {
493  os << "|";
494  for (typename Index<SymmGroup>::const_iterator it = idx.begin();
495  it != idx.end();
496  ++it)
497  {
498  os << "( " << it->first << ": " << it->second << " )";
499  }
500  os << "|";
501 
502  return os;
503 }
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 588 of file indexing_unsorted.hpp.

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

Definition at line 597 of file indexing_unsorted.hpp.

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

Definition at line 455 of file indexing_unsorted.hpp.

456 {
457  if (a.size() != b.size())
458  return false;
459  bool ret = true;
460  for (std::size_t i=0; i<a.size() && ret; ++i)
461  ret = (a[i] == b[b.position(a[i].first)]);
462  return ret;
463 }
std::size_t position(charge c) const
std::size_t size() const