aboutsummaryrefslogtreecommitdiff
path: root/src/sfac.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2009-11-25 13:42:04 +0100
committerThomas White <taw@physics.org>2009-11-25 13:42:04 +0100
commitba0d56c36468e614d0eceb99afc5c878b94eda67 (patch)
treeb4ee92318d4b030fcee2dbb30953b1db75628e42 /src/sfac.c
parent11250cd9c15e5c5b6090b4455de9a412e2ccaad2 (diff)
Make cache for f1f2 work
Diffstat (limited to 'src/sfac.c')
-rw-r--r--src/sfac.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/sfac.c b/src/sfac.c
index 0c82eb2f..a53b97d1 100644
--- a/src/sfac.c
+++ b/src/sfac.c
@@ -32,13 +32,16 @@ static double complex get_f1f2(const char *n, double en)
char *rval;
double last_E, last_f1, last_f2;
static char *memo_n[N_MEMO];
- static double memo_en[N_MEMO];
+ static int memo_eV[N_MEMO];
static double complex memo_res[N_MEMO];
static int n_memo = 0;
+ int eV;
int i;
+ eV = (int)rint(J_to_eV(en));
+
for ( i=0; i<n_memo; i++ ) {
- if ( (memo_en[i] == en) && (strcmp(memo_n[i], n) == 0) ) {
+ if ( (memo_eV[i] == eV) && (strcmp(memo_n[i], n) == 0) ) {
return memo_res[i];
}
}
@@ -97,7 +100,7 @@ static double complex get_f1f2(const char *n, double en)
res = actual_f1 + I*actual_f2;
memo_n[n_memo] = strdup(n);
- memo_en[n_memo] = en;
+ memo_eV[n_memo] = eV;
memo_res[n_memo++] = res;
n_memo = n_memo % N_MEMO;