Skip to content

Commit

Permalink
Code now compiles completely with C99 complex. Unchecked, so there ar…
Browse files Browse the repository at this point in the history
…e probably things lurking still.
  • Loading branch information
Albert Deuzeman committed Feb 14, 2012
1 parent f4f65a0 commit 457e651
Show file tree
Hide file tree
Showing 34 changed files with 1,204 additions and 1,270 deletions.
472 changes: 236 additions & 236 deletions D_psi.c

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions Dov_psi.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ Dov_WS *dov_ws=NULL;
void Dov_psi_prec(spinor * const P, spinor * const S) {
/* todo: do preconditioning */
spinorPrecWS *ws=(spinorPrecWS*)g_precWS;
static complex alpha;
static _Complex double alpha;
Dov_psi(P,S);
alpha.re=-1.;
alpha.im=0.0;
alpha = (-1.) + cimag(alpha) * I;
alpha = creal(alpha);
spinorPrecondition(P,P,ws,T,L,alpha,0,1);

}
Expand Down Expand Up @@ -184,7 +184,7 @@ void Dov_psi(spinor * const P, spinor * const S) {
s=lock_Dov_WS_spinor(0);

/* here we do with M = 1 + s */
/* M + m_ov/2 + (M - m_ov/2) \gamma_5 sign(Q(-M)) */
/* M + m_ov/2 + (M - m_ov/2)\gamma_5 sign(Q(-M)) */
c0 = -(1.0 + ov_s - 0.5*m_ov);
c1 = -(1.0 + ov_s + 0.5*m_ov);

Expand Down Expand Up @@ -217,22 +217,22 @@ void Qov_sq_psi_prec(spinor * const P, spinor * const S) {


spinorPrecWS *ws=(spinorPrecWS*)g_precWS;
static complex alpha={0,0};
static _Complex double alpha={0,0};

alpha.re=ws->precExpo[0];
alpha = (ws->precExpo[0]) + cimag(alpha) * I;
spinorPrecondition(P,S,ws,T,L,alpha,0,1);


Dov_psi(g_spinor_field[DUM_MATRIX], P);
gamma5(P, g_spinor_field[DUM_MATRIX], VOLUME);

alpha.re=ws->precExpo[1];
alpha = (ws->precExpo[1]) + cimag(alpha) * I;
spinorPrecondition(P,P,ws,T,L,alpha,0,1);

Dov_psi(g_spinor_field[DUM_MATRIX], P);
gamma5(P, g_spinor_field[DUM_MATRIX], VOLUME);

alpha.re=ws->precExpo[2];
alpha = (ws->precExpo[2]) + cimag(alpha) * I;
spinorPrecondition(P,P,ws,T,L,alpha,0,1);

return;
Expand All @@ -243,7 +243,7 @@ void addproj_q_invsqrt(spinor * const Q, spinor * const P, const int n, const in

int j;
spinor *aux;
complex cnorm, lambda;
_Complex double cnorm, lambda;
static double save_ev[2]={-1.,-1.};
static int * ev_sign = NULL;

Expand All @@ -265,7 +265,7 @@ void addproj_q_invsqrt(spinor * const Q, spinor * const P, const int n, const in
gamma5(aux, aux, N);

lambda = scalar_prod(&(eigenvectors[j*evlength]), aux, N, 1);
if (lambda.re < 0) {
if (creal(lambda) < 0) {
ev_sign[j] = -1;
}
else {
Expand All @@ -280,8 +280,8 @@ void addproj_q_invsqrt(spinor * const Q, spinor * const P, const int n, const in
for(j = 0; j < n; j++) {
cnorm = scalar_prod(&(eigenvectors[j*evlength]), P, N, 1);

cnorm.re *= (double)ev_sign[j];
cnorm.im *= (double)ev_sign[j];
cnorm *= ((double)ev_sign[j]) + cimag(cnorm) * I;
cnorm *= creal(cnorm) + ((double)ev_sign[j]) * I;

assign_add_mul(Q, &(eigenvectors[j*evlength]), cnorm, N);
}
Expand Down Expand Up @@ -375,16 +375,16 @@ void Q_over_sqrt_Q_sqr(spinor * const R, double * const c,
for (j = n-1; j >= 1; j--) {
assign(sv, d, VOLUME);

if ( (j%10) == 0 ) {
if ((j%10) == 0 ) {
assign_sub_lowest_eigenvalues(aux, d, no_eigenvalues-1, VOLUME);
}
else {
assign(aux, d, VOLUME);
}

norm_Q_sqr_psi(R, aux, rnorm);
/* printf("%d %e %e\n", j, R[0].s0.c0.re, R[0].s0.c0.im); */
/* printf("%e %e\n", R[0].s1.c0.re, R[0].s1.c0.im); */
/* printf("%d %e %e\n", j, R[0].creal(s0.c0), R[0].cimag(s0.c0)); */
/* printf("%e %e\n", R[0].creal(s1.c0), R[0].cimag(s1.c0)); */
temp1=-1.0;
temp2=c[j];
assign_mul_add_mul_add_mul_add_mul_r(d, R, dd, aux3, fact2, fact1, temp1, temp2, VOLUME);
Expand Down Expand Up @@ -429,7 +429,7 @@ void Q_over_sqrt_Q_sqr(spinor * const R, double * const c,
assign_add_mul_r(R, aux, temp2, VOLUME);
/* The stoppping criterio tnorm = |T_j(Q^2)| */
tnorm=square_norm(aux, VOLUME, 1);
tnorm*=(temp2*temp2);
tnorm*= temp2*temp2;

/*
auxnorm=square_norm(R);
Expand Down
137 changes: 61 additions & 76 deletions Nondegenerate_Matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#endif
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "global.h"
#include "su3.h"
#include "Hopping_Matrix.h"
Expand Down Expand Up @@ -302,7 +303,7 @@ void Q_Qdagger_ND(spinor * const l_strange, spinor * const l_charm,
* on a half spinor
******************************************/
void Q_tau1_min_cconst_ND(spinor * const l_strange, spinor * const l_charm,
spinor * const k_strange, spinor * const k_charm, const complex z){
spinor * const k_strange, spinor * const k_charm, const _Complex double z){


int ix;
Expand Down Expand Up @@ -360,8 +361,8 @@ void Q_tau1_min_cconst_ND(spinor * const l_strange, spinor * const l_charm,
mul_r(l_charm, phmc_invmaxev, l_charm, VOLUME/2);

/*
printf(" IN UP: %f %f \n", l_strange[0].s2.c1.re, l_strange[0].s2.c1.im);
printf(" IN DN: %f %f \n", l_charm[0].s2.c1.re, l_charm[0].s2.c1.im);
printf(" IN UP: %f %f \n", l_strange[0].creal(s2.c1), l_strange[0].cimag(s2.c1));
printf(" IN DN: %f %f \n", l_charm[0].creal(s2.c1), l_charm[0].cimag(s2.c1));
*/

/* AND FINALLY WE SUBSTRACT THE C-CONSTANT */
Expand All @@ -373,31 +374,31 @@ void Q_tau1_min_cconst_ND(spinor * const l_strange, spinor * const l_charm,
r=l_strange + ix;
s=k_strange + ix;

_complex_times_vector(phi1, z, (*s).s0);
_vector_sub_assign((*r).s0, phi1);
_complex_times_vector(phi1, z, (*s).s1);
_vector_sub_assign((*r).s1, phi1);
_complex_times_vector(phi1, z, (*s).s2);
_vector_sub_assign((*r).s2, phi1);
_complex_times_vector(phi1, z, (*s).s3);
_vector_sub_assign((*r).s3, phi1);
_complex_times_vector(phi1, z, s->s0);
_vector_sub_assign(r->s0, phi1);
_complex_times_vector(phi1, z, s->s1);
_vector_sub_assign(r->s1, phi1);
_complex_times_vector(phi1, z, s->s2);
_vector_sub_assign(r->s2, phi1);
_complex_times_vector(phi1, z, s->s3);
_vector_sub_assign(r->s3, phi1);

r=l_charm + ix;
s=k_charm + ix;

_complex_times_vector(phi1, z, (*s).s0);
_vector_sub_assign((*r).s0, phi1);
_complex_times_vector(phi1, z, (*s).s1);
_vector_sub_assign((*r).s1, phi1);
_complex_times_vector(phi1, z, (*s).s2);
_vector_sub_assign((*r).s2, phi1);
_complex_times_vector(phi1, z, (*s).s3);
_vector_sub_assign((*r).s3, phi1);
_complex_times_vector(phi1, z, s->s0);
_vector_sub_assign(r->s0, phi1);
_complex_times_vector(phi1, z, s->s1);
_vector_sub_assign(r->s1, phi1);
_complex_times_vector(phi1, z, s->s2);
_vector_sub_assign(r->s2, phi1);
_complex_times_vector(phi1, z, s->s3);
_vector_sub_assign(r->s3, phi1);
}

/*
printf(" IN 2 UP: %f %f \n", l_strange[0].s2.c1.re, l_strange[0].s2.c1.im);
printf(" IN 2 DN: %f %f \n", l_charm[0].s2.c1.re, l_charm[0].s2.c1.im);
printf(" IN 2 UP: %f %f \n", l_strange[0].creal(s2.c1), l_strange[0].cimag(s2.c1));
printf(" IN 2 DN: %f %f \n", l_charm[0].creal(s2.c1), l_charm[0].cimag(s2.c1));
*/

/* Finally, we multiply by the constant phmc_Cpol */
Expand Down Expand Up @@ -660,58 +661,45 @@ void mul_one_pm_itau2(spinor * const p, spinor * const q,
}


void mul_one_minus_imubar(spinor * const l, spinor * const k){
complex z,w;
int ix;
void mul_one_minus_imubar(spinor * const l, spinor * const k)
{
spinor *r, *s;
static su3_vector phi1;

z.re = 1.;
z.im = - g_mubar;
w.re = 1.;
w.im = - z.im;

/************ loop over all lattice sites ************/
for(ix = 0; ix < (VOLUME/2); ix++){
for(int ix = 0; ix < (VOLUME/2); ++ix){
r=l + ix;
s=k + ix;
/* Multiply the spinorfield with the inverse of 1+imu\gamma_5 */
_complex_times_vector(phi1, z, (*s).s0);
_vector_assign((*r).s0, phi1);
_complex_times_vector(phi1, z, (*s).s1);
_vector_assign((*r).s1, phi1);
_complex_times_vector(phi1, w, (*s).s2);
_vector_assign((*r).s2, phi1);
_complex_times_vector(phi1, w, (*s).s3);
_vector_assign((*r).s3, phi1);
_complex_times_vector(phi1, (1. - g_mubar * I), s->s0);
_vector_assign(r->s0, phi1);
_complex_times_vector(phi1, (1. - g_mubar * I), s->s1);
_vector_assign(r->s1, phi1);
_complex_times_vector(phi1, (1. + g_mubar * I), s->s2);
_vector_assign(r->s2, phi1);
_complex_times_vector(phi1, (1. + g_mubar * I), s->s3);
_vector_assign(r->s3, phi1);
}
}


void mul_one_plus_imubar(spinor * const l, spinor * const k){
complex z,w;
int ix;
spinor *r, *s;
static su3_vector phi1;

z.re = 1.;
z.im = g_mubar;
w.re = 1.;
w.im = -z.im;

/************ loop over all lattice sites ************/
for(ix = 0; ix < (VOLUME/2); ix++){
for(int ix = 0; ix < (VOLUME/2); ++ix){
r=l + ix;
s=k + ix;
/* Multiply the spinorfield with the inverse of 1+imu\gamma_5 */
_complex_times_vector(phi1, z, (*s).s0);
_vector_assign((*r).s0, phi1);
_complex_times_vector(phi1, z, (*s).s1);
_vector_assign((*r).s1, phi1);
_complex_times_vector(phi1, w, (*s).s2);
_vector_assign((*r).s2, phi1);
_complex_times_vector(phi1, w, (*s).s3);
_vector_assign((*r).s3, phi1);
_complex_times_vector(phi1, (1. + g_mubar * I), s->s0);
_vector_assign(r->s0, phi1);
_complex_times_vector(phi1, (1. + g_mubar * I), s->s1);
_vector_assign(r->s1, phi1);
_complex_times_vector(phi1, (1. - g_mubar * I), s->s2);
_vector_assign(r->s2, phi1);
_complex_times_vector(phi1, (1. - g_mubar * I), s->s3);
_vector_assign(r->s3, phi1);
}
return;
}
Expand Down Expand Up @@ -770,7 +758,7 @@ void Qtau1_P_ND(spinor * const l_strange, spinor * const l_charm,
/* this is neccessary for the calculation of the polynomial */

void Qtm_pm_min_cconst_nrm(spinor * const l, spinor * const k,
const complex z){
const _Complex double z){
static su3_vector phi1;
spinor *r,*s;
int ix;
Expand All @@ -786,14 +774,14 @@ void Qtm_pm_min_cconst_nrm(spinor * const l, spinor * const k,
r=l + ix;
s=k + ix;

_complex_times_vector(phi1, z, (*s).s0);
_vector_sub_assign((*r).s0, phi1);
_complex_times_vector(phi1, z, (*s).s1);
_vector_sub_assign((*r).s1, phi1);
_complex_times_vector(phi1, z, (*s).s2);
_vector_sub_assign((*r).s2, phi1);
_complex_times_vector(phi1, z, (*s).s3);
_vector_sub_assign((*r).s3, phi1);
_complex_times_vector(phi1, z, s->s0);
_vector_sub_assign(r->s0, phi1);
_complex_times_vector(phi1, z, s->s1);
_vector_sub_assign(r->s1, phi1);
_complex_times_vector(phi1, z, s->s2);
_vector_sub_assign(r->s2, phi1);
_complex_times_vector(phi1, z, s->s3);
_vector_sub_assign(r->s3, phi1);

}

Expand Down Expand Up @@ -860,16 +848,13 @@ void red_noise_nd(spinor * const lse, spinor * const lso,
{
double nrm0 = (1.-g_epsbar)/(1+g_mubar*g_mubar-g_epsbar*g_epsbar);
double nrm1 = (1.+g_epsbar)/(1+g_mubar*g_mubar-g_epsbar*g_epsbar);
complex z,w;
_Complex double z;
int ix, i;
static su3_vector phi;
spinor * r, * s;

/* need B^\dagger, so change sign of g_mubar */
z.re = 0.;
z.im = g_mubar/(1+g_mubar*g_mubar-g_epsbar*g_epsbar);
w.re = 0;
w.im = -z.im;
z = (g_mubar / (1 + g_mubar * g_mubar - g_epsbar * g_epsbar)) * I;

/* first multiply with Hopping matrix */
Hopping_Matrix(EO, g_spinor_field[DUM_MATRIX], lso);
Expand Down Expand Up @@ -902,14 +887,14 @@ void red_noise_nd(spinor * const lse, spinor * const lso,
for(ix = 0; ix < (VOLUME/2); ix++){
/* Multiply the spinorfield with (i epsbar \gamma_5)/c */
/* and add it to */
_complex_times_vector(phi, z, (*s).s0);
_vector_add_assign((*r).s0, phi);
_complex_times_vector(phi, z, (*s).s1);
_vector_add_assign((*r).s1, phi);
_complex_times_vector(phi, w, (*s).s2);
_vector_add_assign((*r).s2, phi);
_complex_times_vector(phi, w, (*s).s3);
_vector_add_assign((*r).s3, phi);
_complex_times_vector(phi, z, s->s0);
_vector_add_assign(r->s0, phi);
_complex_times_vector(phi, z, s->s1);
_vector_add_assign(r->s1, phi);
_complex_times_vector(phi, -z, s->s2);
_vector_add_assign(r->s2, phi);
_complex_times_vector(phi, -z, s->s3);
_vector_add_assign(r->s3, phi);
r++; s++;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Nondegenerate_Matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void Q_Qdagger_ND_BI(bispinor * const bisp_l, bispinor * const bisp_k);

void Q_tau1_min_cconst_ND(spinor * const l_strange, spinor * const l_charm,
spinor * const k_strange, spinor * const k_charm,
const complex z);
const _Complex double z);

void H_eo_ND(spinor * const l_strange, spinor * const l_charm,
spinor * const k_strange, spinor * const k_charm,
Expand All @@ -69,7 +69,7 @@ void Qtau1_P_ND(spinor * const l_strange, spinor * const l_charm,
spinor * const k_strange, spinor * const k_charm);

void Qtm_pm_Ptm_pm_psi(spinor * const l, spinor * const k);
void Qtm_pm_min_cconst_nrm(spinor * const l, spinor * const k,const complex z);
void Qtm_pm_min_cconst_nrm(spinor * const l, spinor * const k,const _Complex double z);

/* ************************************************
* for noise reduction
Expand Down
Loading

0 comments on commit 457e651

Please sign in to comment.