Commit 0d687694 authored by Jakob Gabriel's avatar Jakob Gabriel Committed by Ferdinand Fischer
Browse files

finally, everything works but

     unittests.quantity.testBasicVariable/testBasicVariableInit    X         X       Errored.
     unittests.signals.signalsTest/testGevreyBump                  X         X       Errored.
parent 22cc729a
......@@ -38,7 +38,7 @@ myParser = misc.Parser();
for it = 1 : numel(myInputNameUnique)
myParser.addParameter(myInputNameUniqueValidFieldName{it}, ...
quantity.Discrete(zeros(numel(t), myInputLength(it)), ...
'grid', t, 'gridName', 't', 'name', myInputNameUnique{it}), ...
quantity.Domain("t", t), 'name', myInputNameUnique{it}), ...
@(v) isa(v, 'quantity.Discrete') & isvector(v) & (numel(v)==myInputLength(it)));
end
......
......@@ -28,18 +28,19 @@ x1 = optArgs.x1;
t = t(:);
t0 = t(1);
t1 = t(end);
tDomain = quantity.Domain({optArgs.domainName}, t);
%% Compute the state transition matrix: Phi(t,tau) = expm(A*(t-tau) )
% Att0 = sys.A * quantity.Symbolic( sym('t') - sym('tau'), 'grid', {t, t}, 'gridName', {'t', 'tau'} );
Phi_t0 = expm(sys.A * quantity.Discrete( t - t0, 'grid', {t}, 'gridName', {optArgs.domainName} ));
Phi_t0 = expm(sys.A * quantity.Discrete( t - t0, tDomain));
invPhi_t1 = expm(sys.A * quantity.Discrete( t1 - t, 'grid', {t}, 'gridName', {optArgs.domainName} ));
invPhi_t1 = expm(sys.A * quantity.Discrete( t1 - t, tDomain));
%% compute the gramian controllability matrix
% W1 = misc.ss.gramian(sys, t, t0, optArgs.domainName);
% int_t0^t1 expm(A*(tau-t0)) * b * b^T * expm(A^T(tau-t0)) dtau
W1 = cumInt( Phi_t0 * sys.b * sys.b' * expm(sys.A' * quantity.Discrete( t - t0, 'grid', {t}, 'gridName', {optArgs.domainName} )), ...
W1 = cumInt( Phi_t0 * sys.b * sys.b' * expm(sys.A' * quantity.Discrete( t - t0, tDomain)), ...
Phi_t0(1).domain, t0, optArgs.domainName);
W1_t1 = W1.at(t1);
......
......@@ -110,16 +110,14 @@ for idx = 1 : numel(signalNames)
z = quantity.Domain("z", thisGrid{1});
end
quantityStruct = misc.setfield(quantityStruct, signalNames{idx}, ...
quantity.Discrete(thisSignalSorted, ...
'name', signalNames{idx}, ...
"domain", [t, z]));
quantity.Discrete(thisSignalSorted, [t, z], ...
'name', signalNames{idx}));
else
quantityStruct = misc.setfield(quantityStruct, signalNames{idx}, ...
quantity.Discrete( ...
simOutput(:, strcmp(outputNamesUnenumerated, signalNames{idx})), ...
'name', signalNames{idx}, ....
'domain', t));
simOutput(:, strcmp(outputNamesUnenumerated, signalNames{idx})), t, ...
'name', signalNames{idx}));
end
end
end
......
......@@ -115,7 +115,7 @@ classdef Backstepping < handle & matlab.mixin.Copyable
end
xOriginal = quantity.Discrete(...
ones(101, size(obj.kernel, 1)), ...
'grid', {linspace(0, 1, 101)}, 'gridName', {'z'});
quantity.Domain('z', linspace(0, 1, 101)));
xTilde = obj.transform(xOriginal);
xOriginalAgain = obj.transformInverse(xTilde);
myError = max(median(abs(xOriginal-xOriginalAgain)));
......@@ -238,11 +238,11 @@ classdef Backstepping < handle & matlab.mixin.Copyable
% create quantities as output parameters
K_dzeta = quantity.Discrete(K_dzetaMat, ...
'domain', quantityDomain , ...
quantityDomain , ...
'name', "d_{zeta}" + thisKernel(1).name);
K_dz = quantity.Discrete(K_dzMat, ...
'domain', quantityDomain , ...
quantityDomain , ...
'name', "d_z" + thisKernel(1).name);
end % gradient()
......@@ -269,11 +269,11 @@ classdef Backstepping < handle & matlab.mixin.Copyable
syms z zeta
if isequal(obj.integralBounds, {0, 'z'})
domainSelector = quantity.Discrete(quantity.Symbolic(zeta<=z, ...
'domain', obj.kernel(1).domain));
obj.kernel(1).domain));
elseif isequal(obj.integralBounds, {'z', 1})
domainSelector = quantity.Discrete(quantity.Symbolic(zeta>=z, ...
'domain', obj.kernel(1).domain));
obj.kernel(1).domain));
end
end % get.domainSelector()
......
......@@ -65,7 +65,7 @@ if NameValueArgs.D.abs.MAX() >= 1e3*eps
c5a = permute(numeric.trapz_fast_nDim(z.grid(1:zIdx), integrand), [2, 3, 1]);
end % for zIdx = 2 : z.n
N = quantity.Discrete(permute(Ndouble, [3, 1, 2]), 'domain', z, 'name', "N");
N = quantity.Discrete(permute(Ndouble, [3, 1, 2]), z, 'name', "N");
for it = 1 : 2
% improve by result by successive approximation for which
% Cnew = C(z) + int_0^z D(z, zeta) N(zeta) dzeta
......@@ -87,7 +87,7 @@ else
z.grid.', ...
ic(:));
N = quantity.Discrete(reshape(myN, [z.n, n, m]), 'domain', z, 'name', "N");
N = quantity.Discrete(reshape(myN, [z.n, n, m]), z, 'name', "N");
end
......
......@@ -442,8 +442,8 @@ classdef Symbolic < quantity.Function
obj(it).variable, varNew(s)), varNew(0)==ic);
end
solution = quantity.Symbolic(symbolicSolution, ...
'gridName', {myParser.Results.newGridName, 'ic'}, ...
'grid', {myParser.Results.variableGrid, myParser.Results.initialValueGrid}, ...
[quantity.Domain(myParser.Results.newGridName, myParser.Results.variableGrid), ...
quantity.Domain('ic', myParser.Results.initialValueGrid)], ...
'name', "solve(" + obj(1).name + ")");
end % solveDVariableEqualQuantity()
......
......@@ -79,8 +79,7 @@ classdef TaylorPolynomial < quantity.Discrete
occurrence);
obj@quantity.Discrete( val, ...
'gridName', {'t'}, ...
'grid', {myGlobalGrid}, ...
quantity.Domain("t", myGlobalGrid), ...
'name', ['f_' num2str(index)]);
% put all the values to local variables
......@@ -128,12 +127,11 @@ classdef TaylorPolynomial < quantity.Discrete
end
function monomials = getMonomials(degree, t, tStar, myLocalGrid, T)
monomials = quantity.Symbolic.zeros([degree, 1], ...
'domain', quantity.Domain.empty(), ...
quantity.Domain.empty(), ...
'name', 'varphi_k');
for k = 1:degree
monomials(k, 1) = quantity.Symbolic((t-tStar)^(k-1), ...
'gridName', cellfun(@char, {t, tStar}, 'UniformOutput', false), ...
'grid', {myLocalGrid, T}, ...
[quantity.Domain(char(t), myLocalGrid), quantity.Domain(char(tStar), T)], ...
'name', 'varphi_k');
end
end
......
......@@ -40,7 +40,7 @@ classdef PolyBump < quantity.Function
fun = signals.PolyBump.polyBumpFunction(a, b, c, T0, T1);
obj@quantity.Function(fun, 'domain', t);
obj@quantity.Function(fun, t);
obj.a = a;
obj.b = b;
......
......@@ -69,13 +69,13 @@ classdef PolynomialOperator < handle & matlab.mixin.Copyable
for k = 1 : numel(A)
if isnumeric(A{k})
obj(k).coefficient = ...
quantity.Discrete(A{k}, 'domain', prsr.Results.domain);
quantity.Discrete(A{k}, prsr.Results.domain);
else
obj(k).coefficient = A{k}; %#ok<AGROW>
end
end
elseif isnumeric(A)
obj(1).coefficient = quantity.Discrete(A, 'domain', prsr.Results.domain);
obj(1).coefficient = quantity.Discrete(A, prsr.Results.domain);
end
[obj.s] = deal(s);
......@@ -200,7 +200,7 @@ classdef PolynomialOperator < handle & matlab.mixin.Copyable
c = cell(1, size(C, 3));
for k = 1:size(C, 3)
c{k} = quantity.Discrete(double(C(:,:,k)), ...
'gridName', {}, 'grid', {}, 'name', "adj(" + obj(1).coefficient(1).name + ")");
quantity.Domain.empty(), 'name', "adj(" + obj(1).coefficient(1).name + ")");
end
C = signals.PolynomialOperator(c);
......@@ -214,7 +214,7 @@ classdef PolynomialOperator < handle & matlab.mixin.Copyable
c = cell(1, size(C, 3));
for k = 1:size(C, 3)
c{k} = quantity.Discrete(double(C(:,:,k)), ...
'domain', quantity.Domain.empty(), ...
quantity.Domain.empty(), ...
'name', "det(" + A(1).coefficient(1).name + ")");
end
......@@ -363,10 +363,9 @@ classdef PolynomialOperator < handle & matlab.mixin.Copyable
end
f = quantity.Discrete(...
misc.fundamentalMatrix.odeSolver_par( A_full, spatialDomain ), ...
'grid', {spatialDomain, spatialDomain}, 'gridName', {'z', 'zeta'});
[quantity.Domain("z", spatialDomain), quantity.Domain("zeta", spatialDomain)]);
b = quantity.Discrete(B_full, 'grid', spatialDomain, ...
'gridName', 'zeta');
b = quantity.Discrete(B_full, quantity.Domain("zeta", spatialDomain));
p = cumInt(f * b, 'zeta', spatialDomain(1), 'z');
z0 = A(1).grid{1}(1);
......
......@@ -83,7 +83,7 @@ classdef TimeDelayOperator < handle & matlab.mixin.Copyable
end
function t = t(obj)
t = quantity.Symbolic(sym(obj.timeDomain.name), 'domain', obj.timeDomain);
t = quantity.Symbolic(sym(obj.timeDomain.name), obj.timeDomain);
end
function d = diag(obj)
......@@ -129,7 +129,7 @@ classdef TimeDelayOperator < handle & matlab.mixin.Copyable
end
qinf = quantity.Discrete(infValue, ...
'domain', namedArgs.spatialDomain);
namedArgs.spatialDomain);
o = signals.TimeDelayOperator(qinf, timeDomain, 'isZero', true);
end
end
......
classdef WhiteGaussianNoise
%WhiteGaussianNoise
properties
sigma;
mue = 0;
end
properties (Dependent)
variance;
end
methods
function obj = WhiteGaussianNoise(sigma)
obj.sigma = sigma;
end
function s = get.variance(obj)
s = obj.sigma^2;
end
function o = noise(obj, t)
o = randn(size(t)) * sqrt(obj.variance);
end
function plotProbabilityDistributionFunction(obj, noise)
histogram(noise);
end
function p = probabilityDensityFunction(obj, varargin)
prsr = misc.Parser();
prsr.addParameter('grid', linspace(- 5* obj.sigma, 5 * obj.sigma)');
prsr.parse(varargin{:});
x = sym('x', 'real');
p = quantity.Symbolic( 1 / sqrt( 2 * pi ) / obj.sigma * ...
exp( - (x - obj.mue)^2 / 2 / obj.sigma^2 ), ...
'grid', prsr.Results.grid, ...
'variable', x);
end
function P = cumulativeDistributionFunction(obj, varargin)
p = obj.probabilityDensityFunction(varargin{:});
P = p.cumInt('x', p.grid{1}(1), 'x');
end
function p = probability(obj, z)
% computes the probability, that a value is inside the domain
% abs(x) < z
P = obj.cumulativeDistributionFunction;
p = 2 * P.at(abs(z - obj.mue)) - 1;
end
function
%CALCULATETREHSHOLDFORPROBABILITY computes the threshold for fault
%detection for a given probability detection
%
% fB = calculateProbabilityforDetection(X, MUE, SIGMA), calculate the
% treshold fB for a correct detection of the fault given the probability for
% detection X. Based on a normal distributed random variable with probability
% function P for a mean value MUE and a standard deviation SIGMA.
% The probability X is computed by
% P(|f(t)| <= fB) = P(-fB < f(t) <= fB) - P( |f(t)| <= fB)
% = F(fB) - F(-fB)
% F(fB) is the cumulative distribution function for a normal distribution
% with mean mue and sigma X = F(fB) = 0.5(1+erf((fB-mu)/(sqrt(2)*sigma)))
% Solving for fB with the inverse erf function and erf(-x) = -erf(x) yields
% fB = sqrt(2) * sigma * erfinv(X) + mue
fB = sqrt(2)*sigma*erfinv(X) + mue;
end
end
......@@ -89,16 +89,14 @@ classdef WhiteGaussianNoise
prsr.parse(varargin{:});
x = sym('x', 'real');
xDomain = quantity.Domain("x", prsr.Results.grid);
p = quantity.Symbolic(zeros(size(obj)), ...
'grid', prsr.Results.grid, 'variable', x);
p = quantity.Symbolic(zeros(size(obj)), xDomain);
for i = 1:numel(obj)
p(i) = quantity.Symbolic( 1 / sqrt( 2 * pi ) / obj(i).sigma * ...
exp( - (x - obj(i).mue)^2 / 2 / obj(i).sigma^2 ), ...
'grid', prsr.Results.grid, ...
'variable', x);
exp( - (x - obj(i).mue)^2 / 2 / obj(i).sigma^2 ), xDomain);
end
end
......
......@@ -22,6 +22,6 @@ o = zeros(1, deg);
s = spline([optArg.domain.lower, optArg.domain.upper], ...
[o optArg.s0.', optArg.s1.' o], optArg.domain.grid);
S = quantity.Discrete(s, 'domain', optArg.domain);
S = quantity.Discrete(s, optArg.domain);
end
\ No newline at end of file
......@@ -164,19 +164,19 @@ end
function testCombineInputSignals(tc)
myStateSpace = ss(-1, [1, 2, 3], 1, [], 'InputName', {'control', 'disturbance', 'my.fault'});
t = quantity.Domain('t', linspace(0, 4, 201));
disturbanceSignal = quantity.Symbolic(sin(sym('t')), 'domain', t, 'name', 'disturbance');
faultSignal = quantity.Symbolic(sin(sym('t')), 'domain', t, 'name', 'my.fault');
disturbanceSignal = quantity.Symbolic(sin(sym('t')), t, 'name', 'disturbance');
faultSignal = quantity.Symbolic(sin(sym('t')), t, 'name', 'my.fault');
% case 1: only disturbance
u = misc.ss.combineInputSignals(myStateSpace, t.grid, 'disturbance', disturbanceSignal);
y = quantity.Discrete(lsim(myStateSpace, u.on(), t.grid), 'domain', t, 'name', 'y');
y = quantity.Discrete(lsim(myStateSpace, u.on(), t.grid), t, 'name', 'y');
odeResiduum = - y.diff("t") - y + 2*disturbanceSignal;
tc.verifyEqual(odeResiduum.abs.median(), 0, 'AbsTol', 5e-4);
% case 2: fault and disturbance
u2 = misc.ss.combineInputSignals(myStateSpace, t.grid, 'disturbance', disturbanceSignal, ...
'my.fault', faultSignal);
y2 = quantity.Discrete(lsim(myStateSpace, u2.on(), t.grid), 'domain', t, 'name', 'y');
y2 = quantity.Discrete(lsim(myStateSpace, u2.on(), t.grid), t, 'name', 'y');
odeResiduum = - y2.diff("t") - y2 + 2*disturbanceSignal + 3*faultSignal;
tc.verifyEqual(odeResiduum.abs.median(), 0, 'AbsTol', 5e-4);
end
......
......@@ -10,17 +10,17 @@ myGrid = linspace(0, 1, 31);
myDomain = [quantity.Domain('z', myGrid), quantity.Domain('zeta', myGrid)];
kernelData = quantity.Symbolic(...
[z^2/2, sin(z); 1/(2-z), -z] * magic(2) * [-zeta^2/2, sin(2*zeta); 1/(2-zeta), zeta], ...
'domain', myDomain, 'name', 'K');
myDomain, 'name', 'K');
% calculate derivatives symbolic on raw data
domainSelector = quantity.Discrete(quantity.Symbolic(zeta<=z, ...
'domain', myDomain, 'name', ''));
myDomain, 'name', ''));
kernelData_dz = domainSelector * quantity.Symbolic(...
diff([z^2/2, sin(z); 1/(2-z), -z] * magic(2) * [-zeta^2/2, sin(2*zeta); 1/(2-zeta), zeta], z), ...
'domain', myDomain, 'name', 'K');
myDomain, 'name', 'K');
kernelData_dzeta = domainSelector * quantity.Symbolic(...
diff([z^2/2, sin(z); 1/(2-z), -z] * magic(2) * [-zeta^2/2, sin(2*zeta); 1/(2-zeta), zeta], zeta), ...
'domain', myDomain, 'name', 'K');
myDomain, 'name', 'K');
% set up kernel data in misc.Backstepping objects
k = misc.Backstepping('kernelInverse', kernelData, ...
......@@ -40,7 +40,7 @@ myGrid = linspace(0, 1, 31);
myDomain = [quantity.Domain('z', myGrid), quantity.Domain('zeta', myGrid)];
kernelData = quantity.Symbolic(...
[z^2/2, sin(z); 1/(2-z), -z] * magic(2) * [-zeta^2/2, sin(2*zeta); 1/(2-zeta), zeta], ...
'domain', myDomain, 'name', 'K');
myDomain, 'name', 'K');
% set up kernel data in misc.Backstepping objects
k(1) = misc.Backstepping('kernel', kernelData, ...
......@@ -68,10 +68,10 @@ for it = 1 : numel(k)
end
% compare to old implementation for int_0^z
myDomain = quantity.Discrete(quantity.Symbolic(zeta<z, 'domain', myDomain));
myDomain = quantity.Discrete(quantity.Symbolic(zeta<z, myDomain));
Kref = quantity.Discrete(...
misc.invertBacksteppingKernel(kernelData.on({myGrid, myGrid}, {'z', 'zeta'}), -1), ...
'domain', [quantity.Domain('z', myGrid), quantity.Domain('zeta', myGrid)]);
[quantity.Domain('z', myGrid), quantity.Domain('zeta', myGrid)]);
k1Diff = myDomain * (Kref - k(1).kernelInverse);
k5Diff = myDomain * (Kref - k(5).kernel);
testCase.verifyEqual(MAX(abs(k1Diff)), 0, 'AbsTol', 1e-5);
......
......@@ -121,11 +121,11 @@ end
function test3variables(testCase)
z = linspace(0, pi, 7);
t = linspace(0, pi, 5);
v = 0:pi/2:3*pi/2;
[z, t] = ndgrid(z, t);
[v, t2] = ndgrid(v, t(1,:));
zDom = quantity.Domain("z", linspace(0, pi, 7));
tDom = quantity.Domain("t", linspace(0, pi, 5));
vDom = quantity.Domain("v", 0:pi/2:3*pi/2);
[z, t] = ndgrid(zDom.grid, tDom.grid);
[v, t2] = ndgrid(vDom.grid, t(1,:));
syms V T Z
bb = [cos(Z), 0; 0, sin(T)];
......@@ -154,12 +154,10 @@ bc = misc.multArray(b, c, 4, 3, 2);
bc = permute(bc, [ 1 2 4 3 5 ]);
testCase.verifyTrue(numeric.near(bc, bbcc));
B = quantity.Discrete(b, 'size', [ 2, 2 ], 'gridName', {'z', 't'}, 'grid', {z(:,1), t(1,:)});
C = quantity.Discrete(c, 'size', [ 2, 3 ], 'gridName', {'v', 't'}, 'grid', {v(:,1), t2(1,:)});
B = quantity.Discrete(b, [zDom, tDom]);
C = quantity.Discrete(c, [vDom, tDom]);
BC = B*C;
bcon = BC.on();
testCase.verifyTrue(numeric.near(bc, BC.on()));
......
......@@ -17,11 +17,11 @@ classdef testSolveVolterraIntegroDifferentialIVP < matlab.unittest.TestCase
methods(TestClassSetup)
function tc = initData(tc)
tc.zeta = quantity.Domain("zeta", tc.z.grid);
tc.M = quantity.Symbolic([1+sym("z"), sin(sym("z")); 0, 2], 'domain', tc.z);
tc.A = quantity.Symbolic([1+sym("z"), 0; -sym("z")^2, 2], 'domain', tc.z);
tc.B = quantity.Symbolic([1+sym("z"), 0, 0.1; 0.2, 0, 2; -1, 0.5, 0.5], 'domain', tc.z);
tc.C = quantity.Symbolic([1+sym("z"), 0, -1; 0, 2, -1], 'domain', tc.z);
tc.D = quantity.Symbolic([1+sym("z"), sym("z")*sym("zeta"); sym("zeta"), 2], 'domain', [tc.z, tc.zeta]);
tc.M = quantity.Symbolic([1+sym("z"), sin(sym("z")); 0, 2], tc.z);
tc.A = quantity.Symbolic([1+sym("z"), 0; -sym("z")^2, 2], tc.z);
tc.B = quantity.Symbolic([1+sym("z"), 0, 0.1; 0.2, 0, 2; -1, 0.5, 0.5], tc.z);
tc.C = quantity.Symbolic([1+sym("z"), 0, -1; 0, 2, -1], tc.z);
tc.D = quantity.Symbolic([1+sym("z"), sym("z")*sym("zeta"); sym("zeta"), 2], [tc.z, tc.zeta]);
tc.N = misc.solveVolterraIntegroDifferentialIVP(tc.z, tc.ic, ...
'M', tc.M, 'A', tc.A, 'B', tc.B, 'C', tc.C, 'D', tc.D);
end
......
......@@ -498,14 +498,14 @@ end
function testSqrt(testCase)
% 1 spatial variable
quanScalar1d = quantity.Discrete((linspace(0,2).^2).', quantity.Domain("z", linspace(0, 1)), ...
'size', [1, 1], 'name', "s1d");
'name', "s1d");
quanScalarRoot = quanScalar1d.sqrt();
testCase.verifyEqual(quanScalarRoot.on(), linspace(0, 2).');
% 2 spatial variables
quanScalar2d = quantity.Discrete((linspace(0, 2, 21).' + linspace(0, 2, 41)).^2, ...
[quantity.Domain("z", linspace(0, 1, 21)), quantity.Domain("zeta", linspace(0, 1, 41))], ...
'size', [1, 1], 'name', 's2d');
'name', 's2d');
quanScalar2dRoot = quanScalar2d.sqrt();
testCase.verifyEqual(quanScalar2dRoot.on(), (linspace(0, 2, 21).' + linspace(0, 2, 41)));
......@@ -522,10 +522,10 @@ end
function testSqrtm(testCase)
quanScalar1d = quantity.Discrete((linspace(0,2).^2).', quantity.Domain("z", linspace(0, 1)), ...
'size', [1, 1], 'name', 's1d');
'name', 's1d');
quanScalar2d = quantity.Discrete((linspace(0, 2, 21).' + linspace(0, 2, 41)).^2, ...
[quantity.Domain("z", linspace(0, 1, 21)), quantity.Domain("zeta", linspace(0, 1, 41))], ...
'size', [1, 1], 'name', 's2d');
'name', 's2d');
% diagonal matrix - 1 spatial variable
quanDiag = [quanScalar1d, 0*quanScalar1d; 0*quanScalar1d, (2)*quanScalar1d];
quanDiagRoot = quanDiag.sqrt(); % only works for diagonal matrices
......@@ -611,11 +611,16 @@ end
function testSolveDVariableEqualQuantityConstant(testCase)
%% simple constant case
quan = quantity.Discrete(ones(3, 1), quantity.Domain("z", linspace(0, 1, 3)), ...
'size', [1, 1], 'name', 'a');
quan = quantity.Discrete(ones(3, 1), quantity.Domain("z", linspace(0, 1, 3)));
solution = quan.solveDVariableEqualQuantity();
[referenceResult1, referenceResult2] = ndgrid(linspace(0, 1, 3), linspace(0, 1, 3));
testCase.verifyEqual(solution.on(), referenceResult1 + referenceResult2, 'AbsTol', 10*eps);
% %% 2x2 constant case
%Lambda = quantity.Discrete(quantity.Symbolic([1+sym("z")^2; sym("z")-2], quantity.Domain("z", linspace(0, 1, 101))));
%Lambda = quantity.Discrete(quantity.Symbolic([2; -1], quantity.Domain("z", linspace(0, 1, 11))));
%solution = Lambda.solveDVariableEqualQuantity();
%[referenceResult1, referenceResult2] = ndgrid(linspace(0, 1, 3), linspace(0, 1, 3));
%testCase.verifyEqual(solution.on(), referenceResult1 + referenceResult2, 'AbsTol', 10*eps);
end
function testSolveDVariableEqualQuantityNegative(testCase)
......@@ -642,8 +647,8 @@ function testSolveDVariableEqualQuantityComparedToSym(testCase)
z = testCase.TestData.sym.z;
Z = quantity.Domain("z", linspace(0, 1, 5));
assume(z>0 & z<1);
quanBSym = quantity.Symbolic(1+z, Z, 'name', 'bSym', 'gridName', {'z'});
quanBDiscrete = quantity.Discrete(quanBSym.on(), Z, 'name', 'bDiscrete', 'size', size(quanBSym));
quanBSym = quantity.Symbolic(1+z, Z);
quanBDiscrete = quantity.Discrete(quanBSym.on(), Z);
solutionBSym = quanBSym.solveDVariableEqualQuantity();
solutionBDiscrete = quanBDiscrete.solveDVariableEqualQuantity();
%solutionBSym.plot(); solutionBDiscrete.plot();
......@@ -673,9 +678,9 @@ end
function testMtimesDifferentGridLength(testCase)
%%
a = quantity.Discrete(ones(11, 1), quantity.Domain("z", linspace(0, 1, 11)), ...
'size', [1, 1], 'name', 'a');
'name', 'a');
b = quantity.Discrete(ones(5, 1), quantity.Domain("z", linspace(0, 1, 5)), ...
'size', [1, 1], 'name', 'b');
'name', 'b');
ab = a*b;
%
z = testCase.TestData.sym.z;
......
......@@ -21,7 +21,7 @@ d = 1;
sig = 3 / d^2 * z^2 - 2 / d^3 * z^3;
Z = quantity.Domain('z', linspace(0, 1, 101));
SI = quantity.Symbolic(sig, 'domain', Z);
SI = quantity.Symbolic(sig, Z);
% compute step by function
si = quantity.Symbolic( misc.ss.setPointChange(0, 1, 0, 1, 1, "var", Z.name), 'domain', Z );
......
......@@ -8,7 +8,7 @@ function setupOnce(testCase)
%%
z = sym('z', 'real');
s = sym('s');
Z = linspace(0, 1, 11)';
Z = quantity.Domain("z", linspace(0, 1, 11));
% init with symbolic values
A = cat(3, [ 0, 0, 0, 0; ...
......@@ -27,7 +27,7 @@ A = cat(3, [ 0, 0, 0, 0; ...
B = cat(3, [1, 0, 0, 0]', zeros(4, 1), zeros(4, 1));
for k = 1:3
a{k} = quantity.Symbolic(A(:,:,k), 'grid', Z, 'gridName', 'z');
a{k} = quantity.Symbolic(A(:,:,k), Z);
end
A = signals.PolynomialOperator(a, 's', s);
......@@ -49,7 +49,7 @@ function testApplyTo(testCase)
t = sym('t', 'real');
sol.y = quantity.Symbolic( t.^3 .* (1 - t).^3, ...
'grid', linspace(0, 1, 1e2), 'gridName', 't');
quantity.Domain("t", linspace(0, 1, 1e2)));
sol.u = detsIA.applyTo(sol.y);
sol.x = adjB.applyTo(sol.y);
......@@ -71,9 +71,9 @@ function testFundamentalMatrixSpaceDependent(testCase)
%
a = 20;
z = sym('z', 'real');
Z = linspace(0, 1, 5)';
Z = quantity.Domain("z", linspace(0, 1, 5));