-
Notifications
You must be signed in to change notification settings - Fork 0
/
energy.cpp
46 lines (35 loc) · 837 Bytes
/
energy.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "uti.h"
#include "trace.h"
#include "comm.h"
#include "matfive_mult.h"
//#include "mat_mult.h"
complex < double >
energy (complex < double >x[L][M][N][N], complex < double >&E)
{
complex < double >x_comm[L][M][M][N][N], x_comm_sq[L][M][M][N][N],
Energy[N][N];
E = complex < double >(0.0, 0.0);
complex < double >y;
comm (x, x, x_comm);
matfive_mult (x_comm, x_comm, x_comm_sq);
for (int row = 0; row < N; row++)
{
for (int col = 0; col < N; col++)
{
Energy[row][col] = complex < double >(0.0, 0.0);
for (int l = 0; l < L; l++)
{
for (int m = 0; m < M; m++)
{
for (int m2 = m + 1; m2 < M; m2++)
{
Energy[row][col] -= 1.5 * x_comm_sq[l][m][m2][row][col];
}
}
}
}
}
trace (Energy, y);
E += (N * 0.25 * T / lambda) * y;
return E;
}