4
#include <libdpd/dpd.h>
18
void onestack_insert(struct onestack *stack, double value, int i, int a, int level, int stacklen);
19
void twostack_insert(struct twostack *stack, double value, int i, int j, int a, int b,
20
int level, int stacklen);
22
void amp_write_T1(dpdfile2 *T1, int length, FILE *outfile)
24
int m, h, nirreps, Gia;
25
int i, I, a, A, numt1;
27
struct onestack *t1stack;
29
nirreps = T1->params->nirreps;
32
t1stack = (struct onestack *) malloc(length * sizeof(struct onestack));
33
for(m=0; m < length; m++) { t1stack[m].value = 0; t1stack[m].i = 0; t1stack[m].a = 0; }
35
dpd_file2_mat_init(T1);
39
for(h=0; h < nirreps; h++) {
41
numt1 += T1->params->rowtot[h] * T1->params->coltot[h^Gia];
43
for(i=0; i < T1->params->rowtot[h]; i++) {
44
I = T1->params->roworb[h][i];
45
for(a=0; a < T1->params->coltot[h^Gia]; a++) {
46
A = T1->params->colorb[h^Gia][a];
47
value = T1->matrix[h][i][a];
48
for(m=0; m < length; m++) {
49
if((fabs(value) - fabs(t1stack[m].value)) > 1e-12) {
50
onestack_insert(t1stack, value, I, A, m, length);
58
dpd_file2_mat_close(T1);
60
for(m=0; m < ((numt1 < length) ? numt1 : length); m++)
61
if(fabs(t1stack[m].value) > 1e-6)
62
fprintf(outfile, "\t %3d %3d %20.10f\n", t1stack[m].i, t1stack[m].a, t1stack[m].value);
67
void onestack_insert(struct onestack *stack, double value, int i, int a, int level, int stacklen)
74
stack[level].value = value;
82
for(l=level; l < stacklen-1; l++) {
85
stack[l+1].value = value;
95
void amp_write_T2(dpdbuf4 *T2, int length, FILE *outfile)
97
int m, h, nirreps, Gijab, numt2;
98
int ij, ab, i, j, a, b;
100
struct twostack *t2stack;
102
nirreps = T2->params->nirreps;
103
Gijab = T2->file.my_irrep;
105
t2stack = (struct twostack *) malloc(length * sizeof(struct twostack));
106
for(m=0; m < length; m++) {
107
t2stack[m].value = 0;
108
t2stack[m].i = 0; t2stack[m].j = 0;
109
t2stack[m].a = 0; t2stack[m].b = 0;
113
for(h=0; h < nirreps; h++) {
114
dpd_buf4_mat_irrep_init(T2, h);
115
dpd_buf4_mat_irrep_rd(T2, h);
117
numt2 += T2->params->rowtot[h] * T2->params->coltot[h^Gijab];
119
for(ij=0; ij < T2->params->rowtot[h]; ij++) {
120
i = T2->params->roworb[h][ij][0];
121
j = T2->params->roworb[h][ij][1];
122
for(ab=0; ab < T2->params->coltot[h^Gijab]; ab++) {
123
a = T2->params->colorb[h^Gijab][ab][0];
124
b = T2->params->colorb[h^Gijab][ab][1];
126
value = T2->matrix[h][ij][ab];
128
for(m=0; m < length; m++) {
129
if((fabs(value) - fabs(t2stack[m].value)) > 1e-12) {
130
twostack_insert(t2stack, value, i, j, a, b, m, length);
137
dpd_buf4_mat_irrep_close(T2, h);
140
for(m=0; m < ((numt2 < length) ? numt2 : length); m++)
141
if(fabs(t2stack[m].value) > 1e-6)
142
fprintf(outfile, "\t%3d %3d %3d %3d %20.10f\n", t2stack[m].i, t2stack[m].j,
143
t2stack[m].a, t2stack[m].b, t2stack[m].value);
148
void twostack_insert(struct twostack *stack, double value, int i, int j, int a, int b,
149
int level, int stacklen)
152
struct twostack temp;
156
stack[level].value = value;
168
for(l=level; l < stacklen-1; l++) {
171
stack[l+1].value = value;