3 % compute diffusivity tensor
for geometry transformation and store results in a
6 persistent Dcache hashes cache_filled callerids;
7 warning(
'off',
'diffcached:cache:redundance');
9 %% force clearance of cache
18 if ~isempty(glob) && size(glob,1) < size(glob,2)
19 warning('coordinates in variable glob are given row-wise, but expected them to be column-wise');
29 %ishashed = @(x)(min (cellfun(@(y)(all(y==x)), hashes)) == 1);
31 hasharray = [size(X), X(1), Y(1),callerid];
42 row1 = [res1{1}, res1{2}];
43 row2 = [res2{1}, res2{2}];
46 temp0 = reshape([ sum(row1 .* row1, 2), sum(row2 .* row2, 2) ]
',2*vlen,1);
47 tempm1 = reshape([ sum(row2 .* row1, 2), zeros(vlen,1) ]', 2*vlen, 1);
48 tempp1 = reshape([ zeros(vlen,1), sum(row1 .* row2, 2) ]
', 2*vlen, 1);
49 % temp1 = [ sum(row1 .* row1, 2), sum(row1 .* row2, 2) ];
50 % temp2 = [ sum(row2 .* row1, 2), sum(row2 .* row2, 2) ];
51 diff = spdiags([tempm1,temp0,tempp1],-1:1,2*vlen,2*vlen);
54 hashind = gethash(hasharray, hashes);
58 if(~(isempty(hashind)) && callerid == callerids{hashind})
59 warning('diffcached:cache:redundance
', 'two identical hashvalues
');
60 if(max(max(Dcache{hashind} ~= diff)) ==1 )
65 hashind = length(Dcache)+1;
66 hashes{hashind} = hasharray;
67 Dcache{hashind} = diff;
68 callerids{hashind} = callerid;
72 hashind = gethash(hasharray, hashes);
73 diff = Dcache{hashind};
78 function [ind]=gethash(X,hashes)
79 % function [ind]=gethash(X,hashes)
80 % compute a hash for the cache function in diffusivity_cached()
81 ind = find(cellfun(@(y)(all(y==X)), hashes),1);
function diff = diffusivity_cached(glob, params, callerid)
compute diffusivity tensor for geometry transformation and store results in a cache ...
function [ P1res , P2res ] = inv_geo_trans_derivative(model, glob, P1derivates, P2derivates, callerid)
computes entries of a geometry transformation function's inverse transposed jacobian ...