Commit eba097ff authored by Jakob Gabriel's avatar Jakob Gabriel
Browse files

quantity.Symbolic.subs: bugfix

parent 321082b1
......@@ -262,7 +262,7 @@ classdef Symbolic < quantity.Function
% of this quantity. The domains with the same domain name as
% DOMAIN will be replaced with the corresponding grid in
% DOMAIN.
%
%J
% solution = subs(obj, DOMAINNAME, GRID) can be used to
% change the grid of this quantity. The grid of the domains with the
% DOMAINNAME will be replaced by the values specified in
......@@ -312,8 +312,12 @@ classdef Symbolic < quantity.Function
% rename domains that are affected by symbolic substitution
gridName2ReplaceSymbolicOld = gridName2Replace(~isNumericValue);
gridName2ReplaceSymbolicNew = string(values(~isNumericValue));
resultingName = replace([newDomain.name], gridName2ReplaceSymbolicOld, gridName2ReplaceSymbolicNew);
resultingName = [newDomain.name];
for it = 1 : numel(gridName2ReplaceSymbolicOld)
resultingName(strcmp(resultingName, gridName2ReplaceSymbolicOld(it))) ...
= gridName2ReplaceSymbolicNew(it);
end % for it = 1 : numel(gridName2ReplaceSymbolicOld)
if misc.isunique(resultingName)
newDomain = newDomain.rename(gridName2ReplaceSymbolicNew, gridName2ReplaceSymbolicOld);
else % complicated case, for instance f(x, y).subs("x", "y") = f(y, y)
......
......@@ -868,6 +868,12 @@ solution = f.solveAlgebraic([1, 1], f(1).gridName{1});
testCase.verifyEqual(solution, 0.5);
end
function testSubs3(tc)
zZeta = [quantity.Domain("z", linspace(0, 1, 11)), quantity.Domain("zeta", linspace(0, 1, 11))];
Id = quantity.Symbolic(eye(2), zZeta);
tc.verifyEqual(Id.subs("z", 1).on(), Id.subs("z", "zeta").on(), 'AbsTol', 10*eps);
end % testSubs3()
function testSubs2(tc)
z = quantity.Domain("z", linspace(0, 1, 11));
Id = quantity.Symbolic(eye(2), z);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment