Commit 6da3dcdf authored by Ferdinand Fischer's avatar Ferdinand Fischer
Browse files

Temp state for the implementation of the domain object.

parent 50afa926
This diff is collapsed.
classdef Domain
%DOMAIN class to describes a range of values on which a function can be defined.
% todo:
% todo:
% * EquidistantDomain
% * multi dimensional
......@@ -9,16 +9,18 @@ classdef Domain
% The discrete points of the grid for the evaluation of a
% continuous quantity. For an example, the function f(x) should be
% considered on the domain x \in X = [0, 1]. Then, a grid can be
% generated by X_grid = linspace(0, 1).
grid double {mustBeReal};
% generated by X_grid = linspace(0, 1).
grid double {mustBeReal};
% a speaking name for this domain; Should be unique, so that the
% domain can be identified by the name.
name char;
isConstant = false ;
end
properties (Dependent)
n; % number of discretization points
n; % number of discretization points
lower; % lower bound of the domain
upper; % upper bound of the domain
end
......@@ -29,13 +31,13 @@ classdef Domain
%
if nargin >= 1
parser = misc.Parser();
parser.addParameter('grid', [], @isvector);
parser.addParameter('grid', [], @(g) isvector(g) || isempty(g));
parser.addParameter('name', '', @ischar);
parser.parse(varargin{:});
% todo: assertions
% * ascending ?
obj.grid = parser.Results.grid(:);
obj.name = parser.Results.name;
else
......@@ -72,6 +74,124 @@ classdef Domain
s = [obj.n];
end
function s = eq(obj, obj2)
s = all(obj.gridLength == obj2.gridLength);
for k = 1:numel(obj)
s = s && all(obj(k).grid == obj2(k).grid);
s = s && strcmp(obj(k).name, obj2(k).name);
end
end
function l = ne(obj, obj2)
l = ~(obj == obj2);
end
function [joinedDomain] = gridJoin(obj1, obj2)
%% gridJoin combines the grid and gridName of two objects (obj1,
% obj2), such that every gridName only occurs once and that the
% finer grid of both is used.
[joinedGrid] = union({obj1.name}, {obj2.name}, 'sorted');
joinedDomain = quantity.Domain.empty;
% check for each grid if it is in the domain of obj1 or obj2 or
% both
for i = 1 : numel(joinedGrid)
currentGridName = joinedGrid{i};
[index1, logicalIndex1] = obj1.gridIndex(currentGridName);
[index2, logicalIndex2] = obj2.gridIndex(currentGridName);
%
% if ~any(logicalIndex1)
% joinedDomain(i) = obj2(index2);
% elseif ~any(logicalIndex2)
% joinedDomain(i) = obj1(index1);
% else
%
% Check if a domain is in both domains:
% -> then take the finer one of both
if any(logicalIndex1) && any(logicalIndex2)
tempDomain1 = obj1(index1);
tempDomain2 = obj2(index2);
if ~tempDomain1.isConstant && ~tempDomain2.isConstant
assert(tempDomain1.lower == tempDomain2.lower, 'Grids must have same domain for gridJoin')
assert(tempDomain1.upper == tempDomain2.upper, 'Grids must have same domain for gridJoin')
end
if tempDomain1.gridLength > tempDomain2.gridLength
joinedDomain(i) = tempDomain1;
else
joinedDomain(i) = tempDomain2;
end
% If it is not in both, -> just take the normal grid
elseif any(logicalIndex1)
joinedDomain(i) = obj1(index1);
elseif any(logicalIndex2)
joinedDomain(i) = obj2(index2);
end
end
end % gridJoin()
function [idx, logicalIdx] = gridIndex(obj, names)
%% GRIDINDEX returns the index of the grid
% [idx, log] = gridIndex(obj, names) searches in the gridName
% properties of obj for the "names" and returns its index as
% "idx" and its logical index as "log"
if nargin == 1
names = {obj.name};
end
names = misc.ensureIsCell(names);
idx = zeros(1, length(names));
nArgIdx = 1:obj.ndims();
logicalIdx = false(1, obj.ndims());
for k = 1:length(names)
log = strcmp({obj.name}, names{k});
logicalIdx = logicalIdx | log;
if any(log)
idx(k) = nArgIdx(log);
else
idx(k) = 0;
end
end
end % gridIndex
function matGrid = ndgrid(obj)
% ndgrid calles ndgrid for the default grid, if no other grid
% is specified. Empty grid as input returns empty cell as
% result.
if isempty(obj)
matGrid = {};
else
grids = {obj.grid};
[matGrid{1:obj.ndims}] = ndgrid(grids{:});
end
end % ndgrid()
function [newDomain, idx] = permute(obj, order)
if isa(order, 'quantity.Domain')
names = {order.name};
elseif ischar([order{:}])
names = order;
else
error('the input parameter order must be a array of quantity.Domain objects or a cell-array with string')
end
idx = cellfun(@(v) obj.gridIndex(v), names);
if isa(order, 'quantity.Domain')
newDomain = order;
else
newDomain = obj(idx);
end
end
end
methods (Static)
......@@ -97,7 +217,7 @@ classdef Domain
g(k) = quantity.Domain('grid', O, 'name', name{k});
end
end
end
end
end
......@@ -74,57 +74,25 @@ classdef Function < quantity.Discrete
%-----------------------------
% --- overloaded functions ---
%-----------------------------
function value = on(obj, myGrid, myGridName)
% evaluates obj.valueContinuous function and returns an array
% with the dimensions (n, m, ..., z_disc). n, m, ... are the
% array dimensions of obj.valueContinuous and z_disc is the
% dimensions of the grid.
if nargin == 1
gridSize = obj(1).gridSize;
if gridSize > 2
value = cat(length(gridSize),obj.valueDiscrete);
else % important to include this case for empty grids!
value = [obj.valueDiscrete]; % = cat(2,obj.valueDiscrete)
end
value = reshape(value, [gridSize, size(obj)]);
return
elseif nargin >= 2 && ~iscell(myGrid)
myGrid = {myGrid};
end
gridPermuteIdx = 1:obj(1).nargin;
if isempty(gridPermuteIdx)
gridPermuteIdx = 1;
end
if nargin == 3
if ~iscell(myGridName)
myGridName = {myGridName};
end
assert(numel(myGrid) == numel(myGridName), ...
['If on() is called by using gridNames as third input', ...
', then the cell-array of grid and gridName must have ', ...
'equal number of elements.']);
assert(numel(myGridName) == obj(1).nargin, ...
'All (or none) gridName must be specified');
gridPermuteIdx = cellfun(@(v) obj(1).gridIndex(v), myGridName);
myGrid = myGrid(gridPermuteIdx);
end
% at first the value has to be initialized by different
% dimensions, to simplify the evaluation of each entry:
function value = obj2value(obj, myDomain, recalculate)
gridSize = cellfun('length', myGrid);
if isempty(gridSize), gridSize = 1; end
value = nan([numel(obj), gridSize]);
for k = 1:numel(obj)
ndGrd = obj.ndgrid( myGrid );
tmp = obj(k).evaluateFunction( ndGrd{:} );
% Replaced
% double(subs(obj(k).valueSymbolic, obj.variable, grid));
% because this is very slow!
value(k,:) = tmp(:);
% check if the domain for the evaluation has changed. If not
% we can use the stored values in valueDiscrete:
if nargin < 3
recalculate = false;
end
if ~recalculate && (myDomain == obj(1).domain)
value = obj2value@quantity.Discrete(obj, myDomain);
else
% otherwise the function has to be evaluated on the new
% domain
value = nan([numel(obj), myDomain.gridLength]);
for k = 1:numel(obj)
ndGrd = myDomain.ndgrid;
tmp = obj(k).evaluateFunction( ndGrd{:} );
value(k,:) = tmp(:);
end
end
value = reshape(permute(value, [1+(gridPermuteIdx), 1]), ...
[gridSize(gridPermuteIdx), size(obj)]);
end
function n = nargin(obj)
......
......@@ -472,23 +472,28 @@ testCase.verifyEqual(myQuantityDZzeta(3).on(), zeros(11, 21), 'AbsTol', 10*eps);
end
function testOn(testCase)
%% init data
gridVecA = linspace(0, 1, 27);
gridVecB = linspace(0, 1, 41);
[value] = createTestData(gridVecA, gridVecB);
% init data
domainVecA = quantity.Domain('grid', linspace(0, 1, 27), 'name', 'z');
domainVecB = quantity.Domain('grid', linspace(0, 1, 41), 'name', 'zeta');
[value] = createTestData(domainVecA.grid, domainVecB.grid);
a = quantity.Discrete(value, 'size', [2, 3], ...
'grid', {gridVecA, gridVecB}, 'gridName', {'z', 'zeta'}, 'name', 'A');
'domain', [domainVecA, domainVecB], 'name', 'A');
%%
%
testCase.verifyEqual(value, a.on());
testCase.verifyEqual(permute(value, [2, 1, 3, 4]), ...
a.on({gridVecB, gridVecA}, {'zeta', 'z'}));
a.on([domainVecB, domainVecA]));
testCase.verifyEqual(createTestData(linspace(0, 1, 100), linspace(0, 1, 21)), ...
a.on({linspace(0, 1, 100), linspace(0, 1, 21)}), 'AbsTol', 100*eps);
d24z = quantity.Domain('grid', linspace(0, 1, 24), 'name', 'z');
d21zeta = quantity.Domain('grid', linspace(0, 1, 21), 'name', 'zeta');
testCase.verifyEqual(createTestData(linspace(0, 1, 24), linspace(0, 1, 21)), ...
a.on({linspace(0, 1, 24), linspace(0, 1, 21)}, {'z', 'zeta'}), 'AbsTol', 24*eps);
a.on( [d24z, d21zeta] ), 'AbsTol', 24*eps);
testCase.verifyEqual(permute(createTestData(linspace(0, 1, 21), linspace(0, 1, 24)), [2, 1, 3, 4]), ...
a.on({linspace(0, 1, 24), linspace(0, 1, 21)}, {'zeta', 'z'}), 'AbsTol', 2e-4);
a.on( {linspace(0, 1, 24), linspace(0, 1, 21)}, {'zeta', 'z'}), 'AbsTol', 2e-4);
function [value] = createTestData(gridVecA, gridVecB)
[zGridA , zetaGridA] = ndgrid(gridVecA, gridVecB);
......@@ -531,7 +536,7 @@ b = quantity.Symbolic((eye(2, 2)), 'variable', zeta, ...
'grid', gridVecB);
c = a*b;
%%
%
testCase.verifyEqual(c.on(), a.on());
end
......@@ -575,7 +580,10 @@ KLdKR = KL \ KR;
%%
testCase.verifyEqual(vLdVR.on(), 2 .\ (linspace(1, 2, 21).').^2);
testCase.verifyEqual(KLdKR.on(), permute(repmat(2*eye(2), [1, 1, size(T)]), [4, 3, 1, 2]));
% TODO #discussion: for the following case the operation KL \ KR seems to change the order of the grid in the old version. As this is very unexpected. I would like to change them to not change the order!
testCase.verifyEqual(KLdKR.on(), permute(repmat(2*eye(2), [1, 1, size(T)]), [3, 4, 1, 2]));
end
function testMrdivide(testCase)
......@@ -601,7 +609,9 @@ KLdKR = KL / KR;
%%
testCase.verifyEqual(vLdVR.on(), 2 ./ (linspace(1, 2, 21).').^2);
testCase.verifyEqual(KLdKR.on(), permute(repmat(0.5*eye(2), [1, 1, size(T)]), [4, 3, 1, 2]));
% TODO #discussion: for the following case the operation KL \ KR seems to change the order of the grid in the old version. As this is very unexpected. I would like to change them to not change the order!
testCase.verifyEqual(KLdKR.on(), permute(repmat(0.5*eye(2), [1, 1, size(T)]), [3, 4, 1, 2]));
end
function testInv(testCase)
......@@ -753,61 +763,6 @@ testCase.verifyTrue(all(B_z_1(:,:,2) == 1));
end
function testGridJoin(testCase)
s = linspace(0, 1);
z = linspace(0, 1, 71)';
t = linspace(0, 1, 51);
[Z, T, S] = ndgrid(z, t, s);
a = quantity.Discrete(cat(4, sin(Z.*Z.*S), cos(Z.*T.*S)), ...
'size', [2 1], 'grid', {z, t, s}, 'gridName', {'z', 't', 's'});
b = quantity.Discrete(ones(numel(s), numel(t)), ...
'size', [1 1], 'grid', {s, t}, 'gridName', {'p', 's'});
c = quantity.Discrete(ones(numel(t), 2, 2), ...
'size', [2 2], 'grid', {t}, 'gridName', {'p'});
[gridJoinedAB, gridNameJoinedAB] = gridJoin(a, b);
[gridJoinedCC, gridNameJoinedCC] = gridJoin(c, c);
[gridJoinedBC, gridNameJoinedBC] = gridJoin(b, c);
testCase.verifyEqual(gridNameJoinedAB, {'p', 's', 't', 'z'});
testCase.verifyEqual(gridJoinedAB, {s, s, t, z});
testCase.verifyEqual(gridNameJoinedCC, {'p'});
testCase.verifyEqual(gridJoinedCC, {t});
testCase.verifyEqual(gridNameJoinedBC, {'p', 's'});
testCase.verifyEqual(gridJoinedBC, {s, t});
end
function testGridIndex(testCase)
z = linspace(0, 2*pi, 71)';
t = linspace(0, 3*pi, 51);
s = linspace(0, 1);
[Z, T, S] = ndgrid(z, t, s);
a = quantity.Discrete(cat(4, sin(Z.*Z.*S), cos(Z.*T.*S)), ...
'size', [2 1], 'grid', {z, t, s}, 'gridName', {'z', 't', 's'});
idx = a.gridIndex('z');
testCase.verifyEqual(idx, 1);
idx = a.gridIndex({'z', 't'});
testCase.verifyEqual(idx, [1 2]);
idx = a.gridIndex({'z', 's'});
testCase.verifyEqual(idx, [1 3]);
idx = a.gridIndex('t');
testCase.verifyEqual(idx, 2);
end
function testMTimes(testCase)
% multiplication of a(z) * a(z)'
% a(z) \in (3, 2), z \in (100)
......@@ -836,7 +791,7 @@ testCase.verifyTrue(numeric.near(b1b1', B1B1.on()));
% vector multiplication of b(z, t) * b(v, t)
b2 = cat(3, z .* t, z*0 +1);
b2b2 = misc.multArray(b2, permute(b2, [1 2 4 3]), 4, 3, [1, 2]);
b2b2 = permute(b2b2, [2 1 3 4]);
b2b2 = permute(b2b2, [1 2 3 4]);
B2 = quantity.Discrete(b2, 'size', [ 2, 1 ], 'gridName', {'z', 't'}, 'grid', {z(:,1), t(1,:)});
B2B2 = B2*B2';
testCase.verifyTrue(numeric.near(b2b2, B2B2.on()));
......@@ -845,12 +800,12 @@ c2 = cat(4, sin(z), sin(t), cos(z));
b2c2 = misc.multArray(b2, c2, 4, 3, [1 2]);
C2 = quantity.Discrete(c2, 'size', [1 3], 'gridName', {'z', 't'}, 'grid', {z(:,1), t(1,:)});
B2C2 = B2 * C2;
testCase.verifyTrue(numeric.near(permute(b2c2, [2 1 3 4]), B2C2.on()));
testCase.verifyTrue(numeric.near(permute(b2c2, [1 2 3 4]), B2C2.on()));
% matrix b(z,t) * b(z,t)
b = cat(4, cat(3, z .* t, z*0 +1), cat(3, sin( z ), cos( z .* t )));
bb = misc.multArray(b, b, 4, 3, [1, 2]);
bb = permute(bb, [2 1 3 4]);
bb = permute(bb, [1 2 3 4]);
B = quantity.Discrete(b, 'size', [ 2, 2 ], 'gridName', {'z', 't'}, 'grid', {z(:,1), t(1,:)});
BB = B*B;
testCase.verifyTrue(numeric.near(bb, BB.on));
......@@ -859,8 +814,8 @@ testCase.verifyTrue(numeric.near(bb, BB.on));
c = cat(4, cat(3, v .* t2, v*0 +1), cat(3, sin( v ), cos( v .* t2 )), cat(3, cos( t2 ), tan( v .* t2 )));
bc = misc.multArray(b, c, 4, 3, 2);
bc = permute(bc, [ 1 2 4 3 5 ]);
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, '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,:)});
BC = B*C;
testCase.verifyTrue(numeric.near(bc, BC.on));
......@@ -876,7 +831,7 @@ testCase.verifyTrue( numeric.near( aa(2,2).on() , cos(z * pi) .* cos(z * pi)));
%% test multiplicatin with constants:
C = [3 0; 0 5];
c = quantity.Discrete(C, 'gridName', {}, 'grid', {}, 'name', 'c');
c = quantity.Discrete(C, 'domain', quantity.Domain.empty(), 'name', 'c');
testCase.verifyTrue( numeric.near( squeeze(double(a*c)), [sin(z * pi) * 3, cos(z * pi) * 5]));
testCase.verifyTrue( numeric.near( squeeze(double(a*[3 0; 0 5])), [sin(z * pi) * 3, cos(z * pi) * 5]));
testCase.verifyTrue( numeric.near( double(c*c), C*C));
......@@ -897,7 +852,7 @@ end
function testIsConstant(testCase)
C = quantity.Discrete(rand(3,7), 'gridName', {});
C = quantity.Discrete(rand(3,7), 'domain', quantity.Domain.empty());
testCase.verifyTrue(C.isConstant());
z = linspace(0, pi)';
......@@ -913,7 +868,7 @@ a = cat(3, [myGrid*0, myGrid, sin(myGrid)], [myGrid.^2, myGrid.^3, cos(myGrid)])
c = rand(2, 3); % dim = (2, 3)
A = quantity.Discrete(a, 'size', [3, 2], 'grid', myGrid, 'gridName', {'z'});
C = quantity.Discrete(c, 'gridName', {});
C = quantity.Discrete(c, 'domain', quantity.Domain.empty());
ac = misc.multArray(a, c, 3, 1); % dim = (100, 3, 3)
AC = A*C;
......@@ -1019,7 +974,11 @@ v = {sin(z * t * pi); cos(z * t * pi)};
V = cat(3, v{:});
b = quantity.Discrete(v, 'grid', {z, t}, 'gridName', {'z', 't'});
c = quantity.Discrete(V, 'grid', {z, t}, 'gridName', {'z', 't'});
d = quantity.Discrete(V, 'gridName', {'z', 't'});
Z = quantity.Domain('grid', z, 'name', 'z');
T = quantity.Domain('grid', t, 'name', 't');
d = quantity.Discrete(V, 'domain', [Z, T]);
%%
verifyTrue(testCase, misc.alln(b.on() == c.on()));
......@@ -1071,23 +1030,12 @@ verifyTrue(testCase, numeric.near(A, Anum, 1e-2));
end
% function testNDGrid(testCase)
% %%
% z = linspace(0,1).';
% t = linspace(0,1,101);
% b = quantity.Discrete({sin(z * t * pi); cos(z * t * pi)}, 'grid', {z, t}, 'gridName', {'z', 't'});
% % #TODO
% end
function testDefaultGrid(testCase)
g = quantity.Discrete.defaultGrid([100, 42]);
testCase.verifyEqual(g{1}, linspace(0, 1, 100).');
testCase.verifyEqual(g{2}, linspace(0, 1, 42));
end
function testValue2Cell(testCase)
v = rand([100, 42, 2, 3]);
V = quantity.Discrete( quantity.Discrete.value2cell(v, [100, 42], [2, 3]), 'gridName', {'z', 't'} );
Z = quantity.Domain('grid', linspace(0,1,100), 'name', 'z');
T = quantity.Domain('grid', linspace(0,1,42), 'name', 't');
V = quantity.Discrete( quantity.Discrete.value2cell(v, [100, 42], [2, 3]), ...
'domain', [Z, T]);
verifyTrue(testCase, misc.alln(v == V.on()));
end
......@@ -1139,6 +1087,7 @@ t = linspace(0, 1, 31);
quan = quantity.Discrete({sin(z * t * pi); cos(z * t * pi)}, 'grid', {z, t}, 'gridName', {'z', 't'});
gridSampled = {linspace(0, 1, 11), linspace(0, 1, 21)};
quanCopy = copy(quan);
quanSampled = quanCopy.changeGrid({linspace(0,1,11)}, {'t'});
quanSampled = quanCopy.changeGrid(gridSampled, {'z', 't'});
testCase.verifyEqual(quanSampled.on(), quan.on(gridSampled))
......@@ -1147,14 +1096,16 @@ quanSampled2 = quanCopy2.changeGrid(gridSampled, {'t', 'z'});
testCase.verifyEqual(quanSampled2.on(), permute(quan.on(gridSampled, {'t', 'z'}), [2, 1, 3]));
end
function testSubs(testCase)
%%
myTestArray = ones(21, 41, 2, 3);
myTestArray(:,1,1,1) = linspace(0, 1, 21);
myTestArray(:,:,2,:) = 2;
quan = quantity.Discrete(myTestArray, 'gridName', {'z', 'zeta'}, 'size', [2, 3]);
d1 = quantity.Domain('grid', linspace(0, 1, 21), 'name', 'z');
d2 = quantity.Domain('grid', linspace(0, 1, 41), 'name', 'zeta');
quan = quantity.Discrete(myTestArray, 'domain', [d1, d2]);
quanZetaZ = quan.subs({'z', 'zeta'}, {'zeta', 'z'});
quan10 = quan.subs({'z', 'zeta'}, {1, 0});
quan01 = quan.subs({'z', 'zeta'}, {0, 1});
......@@ -1162,7 +1113,7 @@ quant1 = quan.subs({'z', 'zeta'}, {'t', 1});
quanZetaZeta = quan.subs({'z'}, 'zeta');
quanPt = quan.subs({'z'}, {1});
quanEta = quan.subs({'z'}, {'eta'});
%%
%
testCase.verifyEqual(quan10, shiftdim(quan.on({1, 0})));
testCase.verifyEqual(quan01, shiftdim(quan.on({0, 1})));
testCase.verifyEqual(quanZetaZ.on(), quan.on());
......@@ -1175,9 +1126,17 @@ testCase.verifyEqual(quanZetaZeta.on(), quanZetaZetaReference);
testCase.verifyEqual(quanEta(1).gridName, {'eta', 'zeta'})
testCase.verifyEqual(quanPt.on(), shiftdim(quan.on({1, quan(1).grid{2}})));
%% 4d-case
testCase.verifyEqual( gridSize( quanZetaZeta.subs( quantity.Domain('grid', linspace(0,1,3), 'name', 'zeta')) ), 3);
% 4d-case
myTestArray4d = rand(11, 21, 31, 41, 1, 2);
quan4d = quantity.Discrete(myTestArray4d, 'gridName', {'z', 'zeta', 'eta', 'beta'}, 'name', 'fun5d');
x1 = quantity.Domain('grid', linspace(0, 1, 11), 'name', 'z');
x2 = quantity.Domain('grid', linspace(0, 1, 21), 'name', 'zeta');
x3 = quantity.Domain('grid', linspace(0, 1, 31), 'name', 'eta');
x4 = quantity.Domain('grid', linspace(0, 1, 41), 'name', 'beta');
quan4d = quantity.Discrete(myTestArray4d, 'domain', [x1, x2, x3, x4], 'name', 'fun5d');
quan4dAllEta = quan4d.subs({'z', 'zeta', 'eta', 'beta'}, {'eta', 'eta', 'eta', 'eta'});
testCase.verifyEqual(reshape(quan4d.on({1, 1, 1, 1}), size(quan4d)), ...
reshape(quan4dAllEta.on({1}), size(quan4dAllEta)));
......@@ -1185,6 +1144,8 @@ testCase.verifyEqual(reshape(quan4d.on({1, 1, 1, 1}), size(quan4d)), ...
quan4dArbitrary = quan4d.subs({'z', 'zeta', 'eta', 'beta'}, {'zeta', 'beta', 'z', 1});
testCase.verifyEqual(reshape(quan4d.on({1, 1, 1, 1}), size(quan4d)), ...
reshape(quan4dArbitrary.on({1, 1, 1}), size(quan4dAllEta)));
end
function testZTTimes(testCase)
......
......@@ -42,4 +42,94 @@ d = quantity.Domain();
testCase.verifyTrue( isempty(d) )
end
\ No newline at end of file
end
function testDefaultGrid(testCase)
g = quantity.Domain.defaultGrid([100, 42]);
testCase.verifyEqual(g(1).grid, linspace(0, 1, 100).');
testCase.verifyEqual(g(2).grid, linspace(0, 1, 42).');
end
function testGridJoin(testCase)
s = linspace(0, 1);
z = linspace(0, 1, 71)';
t = linspace(0, 1, 51);
S = quantity.Domain('grid', s, 'name', 's');
Z = quantity.Domain('grid', z, 'name', 'z');
T = quantity.Domain('grid', t, 'name', 't');
Ps = quantity.Domain('grid', s, 'name', 'p');
St = quantity.Domain('grid', t, 'name', 's');
Pt = quantity.Domain('grid', t, 'name', 'p');
a = [Z, T, S];
b = [Ps, St];
c = Pt;
%
%
% a = quantity.Discrete(cat(4, sin(Z.*Z.*S), cos(Z.*T.*S)), ...