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

#45 closed: fixed problem with derivatives of symbolic and wrote unittest.

parent aa676bf8
......@@ -151,20 +151,13 @@ classdef Symbolic < quantity.Function
res = ~(A==B);
end
% function Q = quantity.Discrete(obj, varargin)
% % Cast of a quantity.Symbolic object into a quantity.Discrete
% % object.
% myParser = misc.Parser();
% myParser.addParameter('domain', obj(1).domain);
% myParser.addParameter('name', obj(1).name);
% myParser.parse(varargin{:});
% Q = quantity.Discrete(obj.on(), ...
% 'domain', myParser.Results.domain, ...
% 'name', myParser.Results.name);
% end
function f = function_handle(obj)
f = matlabFunction(sym(obj));
end
if nargin(f) ~= nargin(obj)
warning("function_handle has not all domains as variables")
end
end % function_handle
function F = quantity.Function(obj, varargin)
myParser = misc.Parser();
myParser.addParameter('domain', obj(1).domain);
......@@ -806,7 +799,7 @@ classdef Symbolic < quantity.Function
[result.valueDiscrete] = deal([]);
for l = 1:numel(obj)
result(l).valueSymbolic = diff(obj(l).valueSymbolic, diffGridName, k);
result(l).valueContinuous = obj.setValueContinuous(result(l).valueSymbolic, obj(1).variable);
result(l).valueContinuous = obj.setValueContinuous(result(l).valueSymbolic, [obj(1).domain.name]);
end
end
......
......@@ -4,6 +4,20 @@ function [tests ] = testSymbolic()
tests = functiontests(localfunctions());
end
function testDiffOfConstants(tc)
% unittest to fix a bug...
z = quantity.Domain("z", linspace(0, 1, 4));
K0 = quantity.Symbolic.zeros(1, z);%[z, zeta]);
tc.verifyEqual(K0.on(), zeros([4, 1]));
K1 = quantity.Symbolic.ones(1, z);%[z, zeta]);
tc.verifyEqual(K1.diff("z", 1).on(), zeros([4, 1]));
zeta = quantity.Domain("zeta", linspace(0, 1, 5));
K2 = quantity.Symbolic.ones([2, 2], [z, zeta]);
tc.verifyEqual(K2.diff("z", 1).on(), zeros([4, 5, 2, 2]));
end % testDiffOfConstants
function testZeroOn(tc)
% unittest to fix a bug related with isConstant usage in on() of symbolic
z = quantity.Domain("z", linspace(0, 1, 11));
......
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