Eidors-logo    

EIDORS: Electrical Impedance Tomography and Diffuse Optical Tomography Reconstruction Software

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
SourceForge.net Logo

 

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

  1. 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.

  2. 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= 1e-8;
           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', 1e-8, ...
                '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

Last Modified: $Date: 2017-02-28 13:02:17 -0500 (Tue, 28 Feb 2017) $ by $Author: aadler $