diff options
author | Thomas White <taw@physics.org> | 2009-11-25 13:42:04 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2009-11-25 13:42:04 +0100 |
commit | ba0d56c36468e614d0eceb99afc5c878b94eda67 (patch) | |
tree | b4ee92318d4b030fcee2dbb30953b1db75628e42 | |
parent | 11250cd9c15e5c5b6090b4455de9a412e2ccaad2 (diff) |
Make cache for f1f2 work
-rw-r--r-- | src/sfac.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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; |