EIDORS
(mirror)
Main
Documentation
Tutorials
Download
Contrib Data
GREIT
Browse Docs
Browse SVN
News
Mailing list
(archive)
FAQ
Developer
− Examples
− Structure
− Objects
− Caching
Hosted by
 
EIDORS: Programming / Caching
It is essential for numerical efficiency be able to cache values that
are reused. The design of EIDORStries to make this
as clean as possible, so that the long calculation steps
can be sped up without resorting to convoluted code.
The design requirements are as follows:
Requirements
 Caching should be 'natural'
This part of the
'overloaded' accessor functions, so for example,
calc_image_prior used to be
image_prior= feval( inv_model.image_prior.func, inv_model);
now it is (using the eidors_obj function):
image_prior = eidors_obj('cache', inv_model, 'image_prior');
if isempty(image_prior)
image_prior= feval( inv_model.image_prior.func, inv_model);
eidors_obj('cache', inv_model, 'image_prior', image_prior);
end
so this means that the function 'pointer' in
inv_model.image_prior.func = 'np_calc_image_prior'
doesn't need to know anything about possible caching.
 Cached values should not appear when the underlying
model has changed.
This is ensured by creating an 'object repository' using the
eidors_obj function. eidors objects now must be constructed
using this function, either as
demo_inv.name= 'Nick Polydorides EIT inverse';
demo_inv.solve= 'np_inv_solve';
demo_inv.hyperparameter= 1e8;
demo_inv.image_prior.func= 'np_calc_image_prior';
demo_inv= eidors_obj('inv_model', demo_inv);
or as
demo_inv= eidors_obj( ...
'inv_model', 'Nick Polydorides EIT inverse',...
'solve', 'np_inv_solve', ...
'hyperparameter', 1e8, ...
'func', 'np_calc_image_prior');
whenever an 'object' is modified, such as
eidors_obj('set', demo_inv, 'solve', 'NEW_SOLVER_CODE' );
then all cached values are flushed.
Implementation
