Cache all Buehlmann factors

not just the last one.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
Robert C. Helling 2017-08-25 23:21:27 +02:00 committed by Dirk Hohndel
parent 515b7b5fea
commit 456e2cec89
5 changed files with 43 additions and 33 deletions

View file

@ -1710,3 +1710,21 @@ char *intdup(int index)
tmpbuf[20] = 0;
return strdup(tmpbuf);
}
QHash<int, double> factor_cache;
extern "C" double cache_value(int tissue, int timestep, enum inertgas inertgas)
{
int key = (timestep << 5) + (tissue << 1);
if (inertgas == HE)
++key;
return factor_cache.value(key);
}
extern "C" void cache_insert(int tissue, int timestep, enum inertgas inertgas, double value)
{
int key = (timestep << 5) + (tissue << 1);
if (inertgas == HE)
++key;
factor_cache.insert(key, value);
}