28 #ifndef _chemistry_qc_intv3_storage_h
29 #define _chemistry_qc_intv3_storage_h
38 #include <util/class/class.h>
39 #include <util/keyval/keyval.h>
40 #include <util/container/eavlmmap.h>
45 #define SH_BITS 15 // the number of bits holding a shell index
46 #define PE_BITS 1 // the number of bits holding a permutation
48 #define SH_MASK ((1<<SH_BITS)-1)
49 #define PE_MASK ((1<<PE_BITS)-1)
52 #define SH1_SHIFT (SH_BITS + SH0_SHIFT)
53 #define P12_SHIFT (SH_BITS + SH1_SHIFT)
54 #define P34_SHIFT (PE_BITS + P12_SHIFT)
56 #define SH3_SHIFT (SH_BITS + SH2_SHIFT)
57 #define P13P24_SHIFT (SH_BITS + SH3_SHIFT)
60 unsigned int sh0_sh1_p12_p34;
61 unsigned int sh2_sh3_p13p24;
66 return (sh0_sh1_p12_p34 == k.sh0_sh1_p12_p34)
67 && (sh2_sh3_p13p24 == k.sh2_sh3_p13p24);
70 return ((sh0_sh1_p12_p34 < k.sh0_sh1_p12_p34)?
71 true:(sh2_sh3_p13p24 < k.sh2_sh3_p13p24));
73 int sh0()
const {
return (sh0_sh1_p12_p34>>SH0_SHIFT) & SH_MASK; }
74 int sh1()
const {
return (sh0_sh1_p12_p34>>SH1_SHIFT) & SH_MASK; }
75 int p12()
const {
return (sh0_sh1_p12_p34>>P12_SHIFT) & PE_MASK; }
76 int p34()
const {
return (sh0_sh1_p12_p34>>P34_SHIFT) & PE_MASK; }
77 int sh2()
const {
return (sh2_sh3_p13p24>>SH2_SHIFT) & SH_MASK; }
78 int sh3()
const {
return (sh2_sh3_p13p24>>SH3_SHIFT) & SH_MASK; }
79 int p13p24()
const {
return (sh2_sh3_p13p24>>P13P24_SHIFT) & PE_MASK; }
83 IntegralKey::IntegralKey(
int sh1_,
int sh2_,
int sh3_,
int sh4_,
84 int p12_,
int p34_,
int p13p24_)
86 sh0_sh1_p12_p34 = (sh1_<<SH0_SHIFT)
90 sh2_sh3_p13p24 = (sh3_<<SH2_SHIFT)
92 |(p13p24_<<P13P24_SHIFT);
96 IntegralKey::IntegralKey(
const IntegralKey& ik)
98 sh0_sh1_p12_p34 = ik.sh0_sh1_p12_p34;
99 sh2_sh3_p13p24 = ik.sh2_sh3_p13p24;
103 compare(
const IntegralKey&k1,
const IntegralKey&k2)
105 if (k1.sh0_sh1_p12_p34 < k2.sh0_sh1_p12_p34)
return -1;
106 else if (k1.sh0_sh1_p12_p34 > k2.sh0_sh1_p12_p34)
return 1;
108 if (k1.sh2_sh3_p13p24 < k2.sh2_sh3_p13p24)
return -1;
109 else if (k1.sh2_sh3_p13p24 > k2.sh2_sh3_p13p24)
return 1;
120 static int size_to_actualsize(
int size);
122 int actualsize()
const;
124 static int shells_to_hash(
int,
int,
int,
int);
125 int cost()
const {
return costlist.key; }
129 double* buffer() {
return (
double*)&
this[1]; }
130 void*
operator new(size_t, int);
131 void operator delete(
void*, int);
132 void operator delete(
void*);
136 IntegralLink::shells_to_hash(
int sh1,
int sh2,
int sh3,
int sh4)
138 return sh1 ^ (sh4<<4) ^ (sh2<<8) ^ (sh3<<12);
142 IntegralLink::hash()
const
144 return shells_to_hash(intlist.key.sh0(),
151 IntegralLink::size_to_actualsize(
int size)
153 return size*
sizeof(double) +
sizeof(IntegralLink) +
sizeof(
void*)*2;
157 IntegralLink::actualsize()
const
159 return size_to_actualsize(size);
175 void init(
int nbytes);
178 int should_store(
int cost,
int actualsize);
180 int size,
int cost,
int actualsize);
182 int table_size()
const {
return table_size_; }