24 #ifndef COM_DAFER45_TBTK_LOOKUP_TABLE_MAP
25 #define COM_DAFER45_TBTK_LOOKUP_TABLE_MAP
27 #include "TBTK/FockStateMap/FockStateMap.h"
32 namespace FockStateMap{
34 template<
typename BIT_REGISTER>
35 class LookupTableMap :
public FockStateMap<BIT_REGISTER>{
38 LookupTableMap(
unsigned int exponentialDimension);
41 virtual ~LookupTableMap();
44 virtual unsigned int getBasisSize()
const;
47 virtual unsigned int getBasisIndex(
48 const FockState<BIT_REGISTER> &fockState
52 virtual FockState<BIT_REGISTER> getFockState(
unsigned int index)
const;
55 void addState(
const FockState<BIT_REGISTER> &fockState);
58 std::vector<FockState<BIT_REGISTER>> states;
61 template<
typename BIT_REGISTER>
62 LookupTableMap<BIT_REGISTER>::LookupTableMap(
63 unsigned int exponentialDimension
65 FockStateMap<BIT_REGISTER>(exponentialDimension)
69 template<
typename BIT_REGISTER>
70 LookupTableMap<BIT_REGISTER>::~LookupTableMap(){
73 template<
typename BIT_REGISTER>
74 unsigned int LookupTableMap<BIT_REGISTER>::getBasisSize()
const{
78 template<
typename BIT_REGISTER>
79 unsigned int LookupTableMap<BIT_REGISTER>::getBasisIndex(
80 const FockState<BIT_REGISTER> &fockState
83 unsigned int max = states.size()-1;
85 unsigned int currentState = (
min+
max)/2;
86 if(fockState.getBitRegister() > states.at(currentState).getBitRegister())
87 min = currentState + 1;
88 else if(fockState.getBitRegister() < states.at(currentState).getBitRegister())
89 max = currentState - 1;
90 else if(fockState.getBitRegister() == states.at(currentState).getBitRegister())
94 "LookupTableFockStateMap<BIT_REGISTER>::getBasisIndex()",
95 "FockState not found.",
100 template<
typename BIT_REGISTER>
101 FockState<BIT_REGISTER> LookupTableMap<BIT_REGISTER>::getFockState(
104 return states.at(index);
107 template<
typename BIT_REGISTER>
108 void LookupTableMap<BIT_REGISTER>::addState(
109 const FockState<BIT_REGISTER> &fockState
113 || states.back().getBitRegister() < fockState.getBitRegister()
115 states.push_back(fockState);
118 unsigned int min = 0;
119 unsigned int max = states.size()-1;
121 unsigned int currentState = (
min+
max)/2;
123 fockState.getBitRegister()
124 > states.at(currentState).getBitRegister()
126 min = currentState + 1;
129 fockState.getBitRegister()
130 < states.at(currentState).getBitRegister()
132 max = currentState - 1;
137 fockState.getBitRegister()
143 states.begin() + currentState,
149 states.begin() + currentState