79 if( !Ham::baseUp.size() || !Ham::baseDown.size() )
81 std::cerr <<
"Build base before building Hamiltonian" << std::endl;
85 unsigned int NumUp = Ham::baseUp.size();
86 unsigned int NumDown = Ham::baseDown.size();
88 int upjumpsign, downjumpsign;
100 size_Up = ((Ham::L-Ham::Nu)>Ham::Nu) ? 2*Ham::Nu : 2*(Ham::L-Ham::Nu);
101 size_Down = ((Ham::L-Ham::Nd)>Ham::Nd) ? 2*Ham::Nd : 2*(Ham::L-Ham::Nd);
103 Up_data =
new double [NumUp*size_Up];
104 Up_ind =
new unsigned int [NumUp*size_Up];
106 Down_data =
new double [NumDown*size_Down];
107 Down_ind =
new unsigned int [NumDown*size_Down];
109 for(
unsigned int a=0;a<NumUp;a++)
113 for(
unsigned int b=0;b<NumUp;b++)
115 int result = Ham::hopping(Ham::baseUp[a], Ham::baseUp[b],upjumpsign);
119 Up_data[a+count*NumUp] = Ham::J*result;
120 Up_ind[a+count*NumUp] = b;
126 for(
int i=count;i<size_Up;i++)
128 Up_data[a+i*NumUp] = 0;
129 Up_ind[a+i*NumUp] = 0;
131 else if(count > size_Up)
132 std::cerr <<
"Something went terribly wrong!" << std::endl;
135 for(
unsigned int a=0;a<NumDown;a++)
139 for(
unsigned int b=0;b<NumDown;b++)
141 int result = Ham::hopping(Ham::baseDown[a], Ham::baseDown[b],downjumpsign);
145 Down_data[a+count*NumDown] = Ham::J*result;
146 Down_ind[a+count*NumDown] = b;
151 if(count < size_Down)
152 for(
int i=count;i<size_Down;i++)
154 Down_data[a+i*NumDown] = 0;
155 Down_ind[a+i*NumDown] = 0;
157 else if(count > size_Down)
158 std::cerr <<
"Something went terribly wrong!" << std::endl;
168 unsigned int NumUp = Ham::baseUp.size();
169 unsigned int NumDown = Ham::baseDown.size();
171 std::cout <<
"Up:" << std::endl;
173 for(
unsigned int i=0;i<NumUp;i++)
177 for(
unsigned int j=0;j<NumUp;j++)
178 if(count < size_Up && Up_ind[i+count*NumUp] == j)
179 std::cout << Up_data[i + NumUp*count++] <<
"\t";
183 std::cout << std::endl;
186 std::cout <<
"Down:" << std::endl;
188 for(
unsigned int i=0;i<NumDown;i++)
192 for(
unsigned int j=0;j<NumDown;j++)
193 if(count < size_Down && Down_ind[i + count*NumDown] == j)
194 std::cout << Down_data[i + NumDown*count++] <<
"\t";
198 std::cout << std::endl;
208 unsigned int NumUp = Ham::baseUp.size();
209 unsigned int NumDown = Ham::baseDown.size();
211 std::cout <<
"Up:" << std::endl;
213 std::cout <<
"Data:" << std::endl;
214 for(
unsigned int i=0;i<NumUp;i++)
216 for(
int j=0;j<size_Up;j++)
217 std::cout << Up_data[i+j*NumUp] <<
"\t";
219 std::cout << std::endl;
222 std::cout <<
"Indices:" << std::endl;
223 for(
unsigned int i=0;i<NumUp;i++)
225 for(
int j=0;j<size_Up;j++)
226 std::cout << Up_ind[i+j*NumUp] <<
"\t";
228 std::cout << std::endl;
231 std::cout <<
"Down:" << std::endl;
233 std::cout <<
"Data:" << std::endl;
234 for(
unsigned int i=0;i<NumDown;i++)
236 for(
int j=0;j<size_Down;j++)
237 std::cout << Down_data[i+j*NumDown] <<
"\t";
239 std::cout << std::endl;
242 std::cout <<
"Indices:" << std::endl;
243 for(
unsigned int i=0;i<NumDown;i++)
245 for(
int j=0;j<size_Down;j++)
246 std::cout << Down_ind[i+j*NumDown] <<
"\t";
248 std::cout << std::endl;
261 int NumUp = Ham::baseUp.size();
262 int NumDown = Ham::baseDown.size();
266 for(
int i=0;i<NumUp;i++)
268 #pragma omp parallel for
269 for(
int k=0;k<NumDown;k++)
272 y[i*NumDown+k] = alpha*y[i*NumDown+k] + Ham::U * Ham::CountBits(Ham::baseUp[i] & Ham::baseDown[k]) * x[i*NumDown+k];
275 for(
int l=0;l<size_Down;l++)
276 y[i*NumDown+k] += Down_data[k+l*NumDown] * x[i*NumDown + Down_ind[k+l*NumDown]];
280 for(
int l=0;l<size_Up;l++)
281 daxpy_(&NumDown,&Up_data[i+l*NumUp],&x[Up_ind[i+l*NumUp]*NumDown],&incx,&y[i*NumDown],&incx);
292 double *Umat =
new double[Ham::getDim()];
294 int NumDown = Ham::baseDown.size();
296 for(
int i=0;i<Ham::getDim();i++)
300 Umat[i] = Ham::U * Ham::CountBits(Ham::baseUp[a] & Ham::baseDown[b]);