Commit 5e70eb01 authored by Ferdinand Fischer's avatar Ferdinand Fischer
Browse files

changed implementation of quantity.Discrete so that the domain is a required input argument

-> unittest for testDiscrete are working
parent 7f212f5b
......@@ -33,12 +33,14 @@ end
methods
%% CONSTRUCTOR
function obj = BasicVariable(valueContinuous, varargin)
function obj = BasicVariable(valueContinuous, myDomain, varargin)
parentVarargin = {};
if nargin > 0 && ~isempty(varargin)
% #todo
error("This constructor must be reworked!")
% make default grid:
preParser = misc.Parser();
preParser.addParameter('T', 1);
......@@ -66,16 +68,7 @@ function obj = BasicVariable(valueContinuous, varargin)
preResults.N_diff = preParser.Results.N_diff;
prsr = misc.Parser();
prsr.addParameter('grid', {linspace(0, preParser.Results.T, N_t)'} );
prsr.addParameter('gridName', {'t'});
preParserUnmateched = misc.struct2namevaluepair(preParser.Unmatched);
prsr.parse(preParserUnmateched{:});
uargin = misc.struct2namevaluepair(prsr.Unmatched);
pargin = misc.struct2namevaluepair(prsr.Results);
parentVarargin = [{valueContinuous}, uargin(:)', pargin(:)'];
parentVarargin = [{valueContinuous}, myDomain, ];
end
obj@quantity.Function(parentVarargin{:});
......
......@@ -39,9 +39,9 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
%--------------------
% --- Constructor ---
%--------------------
function obj = Discrete(valueOriginal, varargin)
function obj = Discrete(valueOriginal, myDomain, varargin)
% DISCRETE a quantity, represented by discrete values.
% obj = Discrete(valueOriginal, varargin) initializes a
% obj = Discrete(valueOriginal, myDomain, varargin) initializes a
% quantity. The parameters to be set are:
% 'valueOrigin' must be
% 1) a cell-array of double arrays with
......@@ -53,12 +53,14 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
% parameter 'domain' must be set with quantity.Domain
% objects, according to the domains Z and T.
% OR
% 2) adouble-array with
% 2) a double-array with
% size(valueOriginal) == [gridSize, size(quantity)]
% Furthermore, 'gridName' must be part of the name-value-pairs
% in varargin. Additional parameters can be specified using
% 'myDomain' must be a quantity.Domain object
%
% Additional parameters can be specified using
% name-value-pair-syntax in varargin.
% TODO specify the name-value-pair arguments
% to allow the initialization as object array, the constructor
% must be allowed to be called without arguments, i.e. nargin == 0.
% Then no parameters are set.
......@@ -83,10 +85,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
myParser.addParameter('name', "", @mustBe.gridName);
myParser.addParameter('figureID', 1, @isnumeric);
myParser.parse(varargin{:});
%% domain parser
myDomain = quantity.Domain.parser(varargin{:});
%% get the sizes of obj and grid
gridLength = myDomain.gridLength;
......@@ -202,12 +201,12 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
d = obj.on();
end
function o = quantity.Function(obj)
props = nameValuePair( obj(1) );
args = obj(1).optArgList;
for k = 1:numel(obj)
F = griddedInterpolant(obj(k).grid{:}', obj(k).on());
o(k) = quantity.Function(@(varargin) F(varargin{:}), ...
props{:});
o(k) = quantity.Function(@(varargin) F(varargin{:}), obj(1).domain, args{:});
end
o = reshape(o, size(obj));
......@@ -395,10 +394,9 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
end
% *) build a new valueDiscrete on the correct grid.
obj_hat = quantity.Discrete( newValues, ...
obj_hat = quantity.Discrete( newValues, tmpDomain.join, ...
'name', obj.name + "°" + g.name, ...
'size', size(obj), ...
'domain', tmpDomain.join);
'size', size(obj));
end
......@@ -733,9 +731,8 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
M = zeros([prod(obj(1).domain.gridLength), size(value(l))]);
end
M = reshape(M, [obj(1).domain.gridLength, size(value)]);
o = quantity.Discrete( M, ...
'size', size(value), ...
'domain', obj(1).domain);
o = quantity.Discrete( M, obj(1).domain, ...
'size', size(value));
end
objCell{k} = o;
......@@ -849,9 +846,10 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
assert(numel(obj(1).gridName) == 1);
assert(isequal(size(obj), [1, 1]));
inverse = quantity.Discrete(repmat(obj(1).grid{obj(1).domain.gridIndex(gridName)}(:), [1, size(obj)]), ...
inverse = quantity.Discrete(...
repmat(obj(1).grid{obj(1).domain.gridIndex(gridName)}(:), [1, size(obj)]), ...
quantity.Domain([obj(1).name], obj.on()), ...
'size', size(obj), ...
'domain', quantity.Domain([obj(1).name], obj.on()), ...
'name', gridName);
end % invert()
......@@ -917,8 +915,8 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
% return result as quantity-object
solution = quantity.Discrete(...
reshape(odeSolution, [myGridSize, size(obj)]), ...
'domain', [quantity.Domain(myParser.Results.newGridName, variableGrid), ...
quantity.Domain('ic', myParser.Results.initialValueGrid)], ...
[quantity.Domain(myParser.Results.newGridName, variableGrid), ...
quantity.Domain('ic', myParser.Results.initialValueGrid)], ...
'size', size(obj), ...
'name', "solve(" + obj(1).name + ")");
end % solveDVariableEqualQuantity()
......@@ -1059,8 +1057,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
if isempty(newDomain)
solution = newValue;
else
solution = quantity.Discrete(newValue, ...
'domain', newDomain, ...
solution = quantity.Discrete(newValue, newDomain, ...
'name', obj(1).name);
end
if numel(gridName2Replace) > 1
......@@ -1297,7 +1294,25 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
end % greek2tex()
end % plot()
function [s] = optArgList(obj, exclude)
% OPTARGLIST returns optional arguments of the quantity.Discrete
% S = optArgList(OBJ, EXCLUDE) returns the optional arguments for the OBJ as
% cell-array. With EXCLUDE as string-array, properties can be excluded
%
assert(numel(obj) == 1, "argList must NOT be called for an array object");
s = struct(obj);
s = rmfield(s, ["domain", "grid", "gridName"]);
if nargin == 2
s = rmfield(s, exclude);
end
s = misc.struct2namevaluepair(s);
end
function s = nameValuePair(obj, varargin)
% NAMEVALUEPAIR returns a name value pair list for the object
% S = nameValuePair(OBJ, VARARGIN) returns the properties of the object as
% name-value-pair.
warning("DEPRECATED! Use quantity.Discrete/optArgList insted")
assert(numel(obj) == 1, "nameValuePair must NOT be called for an array object");
s = struct(obj);
if ~isempty(varargin)
......@@ -1349,8 +1364,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
for it = 1 : numel(myGridName)
bMat = flip(bMat, gridIdx(it));
end
b = quantity.Discrete(bMat, ...
'domain', a(1).domain, ...
b = quantity.Discrete(bMat, a(1).domain, ...
'name', "flip(" + a(1).name + ")");
end % flipGrid()
......@@ -1474,20 +1488,18 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
z = sym(gridName1, 'real');
zeta = sym(gridName2, 'real');
f0 = expm(obj.atIndex(1)*(z - zeta));
F = quantity.Symbolic(f0, 'domain', myDomain);
F = quantity.Symbolic(f0, myDomain);
elseif isa(obj, 'quantity.Symbolic')
f0 = misc.fundamentalMatrix.odeSolver_par(obj.function_handle, myGrid);
F = quantity.Discrete(f0, ...
'size', [size(obj, 1), size(obj, 2)], ...
'domain', myDomain);
F = quantity.Discrete(f0, myDomain, ...
'size', [size(obj, 1), size(obj, 2)]);
else
f0 = misc.fundamentalMatrix.odeSolver_par( ...
obj.on(myGrid), ...
myGrid );
F = quantity.Discrete(f0, ...
'size', [size(obj, 1), size(obj, 2)], ...
'domain', myDomain);
F = quantity.Discrete(f0, myDomain, ...
'size', [size(obj, 1), size(obj, 2)]);
end
end
......@@ -1499,8 +1511,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
obj;
dim = 1:ndims(obj);
end % arguments
s = quantity.Discrete(sum(obj.on(), obj.nargin + dim), ...
'domain', obj(1).domain, ...
s = quantity.Discrete(sum(obj.on(), obj.nargin + dim), obj(1).domain, ...
'name', "sum(" + obj(1).name + ")");
end % sum()
......@@ -1512,16 +1523,14 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
obj;
dim = 1:ndims(obj);
end % arguments
P = quantity.Discrete(prod(obj.on(), obj(1).nargin + dim), ...
'domain', obj(1).domain, ...
P = quantity.Discrete(prod(obj.on(), obj(1).nargin + dim), obj(1).domain, ...
'name', "prod(" + obj(1).name + ")");
end % prod()
function y = sqrt(x)
% quadratic root for scalar and diagonal quantities
y = quantity.Discrete(sqrt(x.on()), ...
'size', size(x), 'domain', x(1).domain, ...
'name', "sqrt(" + x(1).name + ")");
y = quantity.Discrete(sqrt(x.on()), x(1).domain, ...
'name', "sqrt(" + x(1).name + ")");
end % sqrt()
......@@ -1541,9 +1550,8 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
for k = 1 : prod(x(1).domain.gridLength)
yUnmuted(:,:,k) = sqrt(xPermuted(:,:,k));
end
y = quantity.Discrete(permute(yUnmuted, permuteBack), ...
'size', size(x), 'domain', x(1).domain, ...
'name', "sqrtm(" + x(1).name + ")");
y = quantity.Discrete(permute(yUnmuted, permuteBack), x(1).domain, ...
'size', size(x), 'name', "sqrtm(" + x(1).name + ")");
else
error('sqrtm() is only implemented for quadratic matrices');
end
......@@ -1586,13 +1594,11 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
if isa(b, 'double')
if numel(b) == 1
% simple multiplication in scalar case
P = quantity.Discrete(a.on() * b, 'size', size(a),...
'domain', a(1).domain, ...
'name', a(1).name + num2str(b));
P = quantity.Discrete(a.on() * b, a(1).domain, ...
'size', size(a), 'name', a(1).name + num2str(b));
return
else
b = quantity.Discrete(b, 'size', size(b), ...
'domain', quantity.Domain.empty());
b = quantity.Discrete(b, quantity.Domain.empty(), 'size', size(b));
end
end
......@@ -1672,8 +1678,6 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
newDomainA = quantity.Domain.empty(); % for later call of a.on() with fine grid
newDomainB = quantity.Domain.empty(); % for later call of b.on() with fine grid
for i = 1 : numel(joinedDomain)
parameters.domain(i) = joinedDomain(i);
% if there is a component of the original domain in the
% joined domain, it can happen the length of a domain has
......@@ -1699,7 +1703,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
% values to the right order
C = misc.multArray(valueA, valueB, idx.A.value(end), idx.B.value(1), idx.common);
C = permute(C, permuteGrid);
P = quantity.Discrete(C, parameters{:});
P = quantity.Discrete(C, joinedDomain, parameters{:});
end
function y = inv(obj)
......@@ -1709,8 +1713,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
objDiscreteOriginal = obj.on();
if isscalar(obj)
% use ./ for scalar case
y = quantity.Discrete(1 ./ objDiscreteOriginal, ...
'domain', obj(1).domain, ...
y = quantity.Discrete(1 ./ objDiscreteOriginal, obj(1).domain, ...
'name', "(" + obj(1).name + ")^{-1}");
else
% reshape and permute objDiscrete such that only on for
......@@ -1723,9 +1726,8 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
invDiscrete(it, :, :) = inv(objDiscreteReshaped(:, :, it));
end
y = quantity.Discrete(reshape(invDiscrete, size(objDiscreteOriginal)),...
'domain', obj(1).domain, ...
'name', "{(" + obj(1).name + ")}^{-1}");
y = quantity.Discrete(reshape(invDiscrete, size(objDiscreteOriginal)), ...
obj(1).domain, 'name', "{(" + obj(1).name + ")}^{-1}");
end
end % inv()
......@@ -1744,8 +1746,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
if ~isempty(objT)
objCtMat = conj(objT.on());
objCt = quantity.Discrete(objCtMat, ...
'domain', obj(1).domain, ...
objCt = quantity.Discrete(objCtMat, obj(1).domain, ...
'name', "{" + obj(1).name + "}^{H}");
else
objCt = objT;
......@@ -1754,8 +1755,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
function y = exp(obj)
% exp() is the exponential function using obj as the exponent.
y = quantity.Discrete(exp(obj.on()), ...
'domain', obj(1).domain, ...
y = quantity.Discrete(exp(obj.on()), obj(1).domain, ...
'name', "exp(" + obj(1).name + ")", ...
'size', size(obj));
end % exp()
......@@ -1821,9 +1821,8 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
for k = 1 : prod(x(1).domain.gridLength)
yUnmuted(:,:,k) = expm(xPermuted(:,:,k));
end
y = quantity.Discrete(permute(yUnmuted, permuteBack), ...
'size', size(x), 'domain', x(1).domain, ...
'name', "expm(" + x(1).name + ")");
y = quantity.Discrete(permute(yUnmuted, permuteBack), x(1).domain, ...
'size', size(x), 'name', "expm(" + x(1).name + ")");
end
end
......@@ -1843,8 +1842,8 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
function x = rdivide(A, B)
if isnumeric(A)
x = quantity.Discrete( A ./ B.on(), 'size', size(B), ...
'domain', B(1).domain, 'name', "1 ./ " + B(1).name);
x = quantity.Discrete( A ./ B.on(), B(1).domain, ...
'size', size(B), 'name', "1 ./ " + B(1).name);
else
error('Not yet implemented')
end
......@@ -1875,8 +1874,9 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
end
end
argin = nameValuePair(a(1));
P = quantity.Discrete(quantity.Discrete.value2cell(P, [p, q], [n, m]), argin{:});
objOptArgs = a(1).optArgList();
P = quantity.Discrete(quantity.Discrete.value2cell(P, [p, q], [n, m]), a(1).domain,...
objOptArgs{:});
end
function empty = isempty(obj)
% ISEMPTY checks if the quantity object is empty
......@@ -1979,8 +1979,9 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
end
end
argin = nameValuePair(a(1));
P = quantity.Discrete(quantity.Discrete.value2cell(P, [p, q], [n, m]), argin{:});
objOptArgList = a(1).optArgList();
P = quantity.Discrete(quantity.Discrete.value2cell(P, [p, q], [n, m]), a(1).domain, ...
objOptArgList{:});
end
function myGrid = gridOf(obj, myGridName)
......@@ -2017,9 +2018,8 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
end
if obj.isConstant && isempty(obj(1).gridName)
result = quantity.Discrete(zeros(size(obj)), ...
'size', size(obj), 'domain', obj(1).domain, ...
'name', "(d_{.}" + obj(1).name + ")");
result = quantity.Discrete(zeros(size(obj)), obj(1).domain, ...
'size', size(obj), 'name', "(d_{.}" + obj(1).name + ")");
return
end
......@@ -2115,7 +2115,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
% integrate
F = numeric.cumtrapz_fast_nDim(myGrid{intGridIdx}, ...
obj.on(), intGridIdx);
result = quantity.Discrete(F, 'domain', obj(1).domain);
result = quantity.Discrete(F, obj(1).domain);
% int_lowerBound^upperBound f(.) =
% F(upperBound) - F(lowerBound)
......@@ -2138,15 +2138,15 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
% for support of numeric inputs:
if ~isa(A, 'quantity.Discrete')
if isnumeric(A)
A = quantity.Discrete(A, 'name', "c", 'domain', quantity.Domain.empty());
A = quantity.Discrete(A, quantity.Domain.empty(), 'name', "c");
else
error('Not yet implemented')
end
elseif ~isa(B, 'quantity.Discrete')
if isnumeric(B)
B = quantity.Discrete(B, 'name', "c", 'domain', quantity.Domain.empty());
B = quantity.Discrete(B, quantity.Domain.empty(), 'name', "c");
else
B = quantity.Discrete(B, 'name', "c", 'domain', A(1).domain);
B = quantity.Discrete(B, A(1).domain, 'name', "c");
end
end
......@@ -2157,8 +2157,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
[bDiscrete] = B.expandValueDiscrete(joinedDomain);
% create result object
C = quantity.Discrete(aDiscrete + bDiscrete, ...
'domain', joinedDomain, ...
C = quantity.Discrete(aDiscrete + bDiscrete, joinedDomain, ...
'name', A(1).name + "+" + B(1).name);
end
......@@ -2259,8 +2258,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
if isempty(obj)
absQuantity = quantity.Discrete.empty(size(obj));
else
absQuantity = quantity.Discrete(abs(obj.on()), ...
'domain', obj(1).domain, ...
absQuantity = quantity.Discrete(abs(obj.on()), obj(1).domain, ...
'size', size(obj), 'name', "|" + obj(1).name + "|");
end
end % abs()
......@@ -2305,18 +2303,15 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
function y = real(obj)
% real() returns the real part of the obj.
y = quantity.Discrete(real(obj.on()), ...
'name', "real(" + obj(1).name + ")", ...
'domain', obj(1).domain, ...
y = quantity.Discrete(real(obj.on()), obj(1).domain, ...
'name', "real(" + obj(1).name + ")", ...
'size', size(obj));
end % real()
function y = imag(obj)
% real() returns the imaginary part of the obj.
y = quantity.Discrete(imag(obj.on()), ...
'name', "imag(" + obj(1).name + ")", ...
'domain', obj(1).domain, ...
'size', size(obj));
y = quantity.Discrete(imag(obj.on()), obj(1).domain, ...
'name', "imag(" + obj(1).name + ")", 'size', size(obj));
end % imag()
function meanValue = mean(obj, dim)
......@@ -2438,7 +2433,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
P = quantity.Discrete.empty(valueSize);
else
O = ones([domain.gridLength, valueSize(:)']);
P = quantity.Discrete(O, 'size', valueSize, 'domain', domain, varargin{:});
P = quantity.Discrete(O, domain, 'size', valueSize, varargin{:});
end
end
......@@ -2462,7 +2457,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
P = quantity.Discrete.empty(valueSize);
else
O = zeros([domain.gridLength, valueSize(:)']);
P = quantity.Discrete(O, 'size', valueSize, 'domain', domain, varargin{:});
P = quantity.Discrete(O, domain, 'size', valueSize, varargin{:});
end
end
......@@ -2568,9 +2563,8 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
rePermutationVector = [2:(gridIndex), ...
1, (gridIndex+1):ndims(derivativeDiscrete)];
result = quantity.Discrete(...
permute(derivativeDiscrete, rePermutationVector), ...
'size', size(obj), 'domain', obj(1).domain, ...
'name', "(d_{" + diffGridName + "}" + obj(1).name + ")");
permute(derivativeDiscrete, rePermutationVector), obj(1).domain, ...
'size', size(obj), 'name', "(d_{" + diffGridName + "}" + obj(1).name + ")");
if k > 1
% if a higher order derivative is requested, call the function
......
......@@ -8,7 +8,7 @@ classdef Function < quantity.Discrete
%--------------------
% --- Constructor ---
%--------------------
function obj = Function(valueOriginal, varargin)
function obj = Function(valueOriginal, myDomain, varargin)
parentVarargin = {}; % by default the parent-class is called
% with no input.
......@@ -35,19 +35,7 @@ classdef Function < quantity.Discrete
end
end
myParser = misc.Parser();
myParser.addParameter('grid', {linspace(0, 1, 101).'});
if isempty(fun)
gridNameDefault = {};
else
gridNameDefault = misc.getInputNamesOfFunctionHandle(fun{1});
end
myParser.addParameter('gridName', gridNameDefault);
myParser.parse(varargin{:});
unmatched = misc.struct2namevaluepair(myParser.Unmatched);
parentVarargin = {cell(sizeValue), 'grid', myParser.Results.grid, ...
'gridName', myParser.Results.gridName, unmatched{:}};
parentVarargin = [{cell(sizeValue)}, {myDomain}, varargin(:)'];
end
obj@quantity.Discrete(parentVarargin{:});
......@@ -72,13 +60,12 @@ classdef Function < quantity.Discrete
end
function Q = quantity.Discrete(obj, varargin)
% QUANTITY.DISCRETE cast obj to 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);
Q = quantity.Discrete(obj.on(), myParser.Results.domain, 'name', myParser.Results.name);
end
%-----------------------------
......@@ -167,7 +154,7 @@ classdef Function < quantity.Discrete
@(varargin)obj(k).evaluateFunction(varargin{:}), ...
domain.grid);
result = quantity.Discrete(I_val, 'domain', obj(1).domain);
result = quantity.Discrete(I_val, obj(1).domain);
% int_lowerBound^upperBound f(.) =
% F(upperBound) - F(lowerBound)
......
......@@ -8,8 +8,6 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Piecewise < quantity.Discrete
methods
function obj = Piecewise(quantities, optionalArgs)
%quantities Construct an instance of this class
% Detailed explanation goes here
arguments
quantities = {};
% the default value for the domainToJoin is set as a
......@@ -68,8 +66,8 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Piecewise < quantity.Discrete
joinedDomain = quantity.Domain(domainToJoin.name, joinedGrid);
initArgs = {joinedValues, 'size', size(quantities{1}), ...
'domain', joinedDomain, 'name', optionalArgs.name};
initArgs = {joinedValues, joinedDomain, 'size', size(quantities{1}), ...
'name', optionalArgs.name};
end
obj@quantity.Discrete(initArgs{:});
......
......@@ -13,7 +13,7 @@ classdef Symbolic < quantity.Function
methods
function obj = Symbolic(valueContinuous, varargin)
function obj = Symbolic(valueContinuous, myDomain, varargin)
%TODO Contruktor überarbeiten:
% # bei matlabFunction( symbolischer ausdruck ) muss auf die
......@@ -32,23 +32,13 @@ classdef Symbolic < quantity.Function
variableParser = misc.Parser();
variableParser.addParameter('variable', quantity.Symbolic.getVariable(valueContinuous));
variableParser.addParameter('symbolicEvaluation', false);
variableParser.addParameter('gridName', '');
variableParser.addParameter('domain', []);
variableParser.parse(varargin{:});
if ~variableParser.isDefault('variable')
warning('Do not set the variable property. It will be ignored.')
end
if variableParser.isDefault('gridName') && variableParser.isDefault('domain')
warning('Grid names are generated from the symbolic variable. Please set the grid names in a quantity.Domain object explicitly')
variableNames = cellstr(string(variableParser.Results.variable));
varargin = [varargin(:)', {'gridName'}, {variableNames}];
end
if ~variableParser.isDefault('variable')
warning('Do not set the variable property. It will be ignored.')
end
[myDomain, varargin] = quantity.Domain.parser(varargin{:});
s = size(valueContinuous);
s = size(valueContinuous);
S = num2cell(s);
fun = cell(S{:});
......@@ -87,7 +77,7 @@ classdef Symbolic < quantity.Function
% if ~all(strcmp(sort({myDomain.name}), sort(variableName)))
% error('If the gridName(s) are set explicitly, they have to be the same as the variable names!')
% end
parentVarargin = [{fun}, varargin(:)', {'domain'}, {myDomain}];
parentVarargin = [{fun}, {myDomain}, varargin(:)'];
end
% call parent class
obj@quantity.Function(parentVarargin{:});
......@@ -194,8 +184,7 @@ classdef Symbolic < quantity.Function
myParser.addParameter('name', obj(1).name);
myParser.parse(varargin{:});
for k = 1:numel(obj)
F(k) = quantity.Function(obj