Debian Codegraph @

packages/muelu/matlab/tests/ReentrantDemo/modifyP.m

raw
1 %Function to demonstrate reentrant capability in muemex
2 %Take a P from a default MueLu hierarchy and modify it
3 %so that all nonzero values only have one significant figure
4 function P = createP(A)
5 %Create a separate hierarchy to get a fresh, default P
6 disp('Generating inner hierarchy...');
7 newHier = muelu('setup', A, 'coarse: max size', 100, 'verbosity', 'none');
8 P = muelu('get', newHier, 1, 'P'); %This always gives the next prolongator, no matter what the current level # is
9 disp('Done generating inner hierarchy.');
10 muelu('cleanup', newHier); %If not cleaned up, the inner hierarchy will stay in list of problems along with outer one
11 [i, j, s] = find(P);
12 for k = 1:length(s)
13 placeVal = 10^floor(log10(s(k))); %If P(i) is 0.0513, placeVal will be 0.01.
14 s(k) = placeVal * ceil(s(k) / placeVal); %Dividing by placeVal shifts the decimal representation so that exactly one digit is left of decimal place.
15 end
16 P = sparse(i, j, s);
17 end