Commit 84fae0c5 authored by Jakob Gabriel's avatar Jakob Gabriel
Browse files

quantity.Discrete & Symbolic: use gridIndex and gridLength of domain now

parent 3e9ff67e
......@@ -485,7 +485,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete < handle & matlab.mi
else
referenceGridName = a(1).gridName;
referenceGrid = a(1).grid;
referenceGridSize = a(1).gridSize(referenceGridName);
referenceGridSize = [a(1).domain.n];
end
for it = 1 : numel(varargin)
......@@ -495,14 +495,14 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete < handle & matlab.mi
assert(numel(referenceGridName) == numel(varargin{it}(1).gridName), ...
['For getFinestGrid, the gridName of all objects must be equal', ...
'. Maybe gridJoin() does what you want?']);
comparisonGridSize = varargin{it}(1).gridSize(referenceGridName);
for jt = 1 : numel(referenceGridName)
comparisonGridSize = varargin{it}(1).domain.find(referenceGridName{jt}).n;
comparisonGrid = varargin{it}.gridOf(referenceGridName{jt});
assert(referenceGrid{jt}(1) == comparisonGrid(1), 'Grids must have same domain for combining them')
assert(referenceGrid{jt}(end) == comparisonGrid(end), 'Grids must have same domain for combining them')
if comparisonGridSize(jt) > referenceGridSize(jt)
if comparisonGridSize > referenceGridSize(jt)
referenceGrid{jt} = comparisonGrid;
referenceGridSize(jt) = comparisonGridSize(jt);
referenceGridSize(jt) = comparisonGridSize;
end
end
end
......@@ -1262,7 +1262,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete < handle & matlab.mi
if ~iscell(myGridName)
myGridName = {myGridName};
end
gridIdx = a.gridIndex(myGridName);
gridIdx = a(1).domain.gridIndex(myGridName);
for it = 1 : numel(myGridName)
bMat = flip(bMat, gridIdx(it));
end
......@@ -1452,7 +1452,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete < handle & matlab.mi
permuteBack = [(1:x.nargin)+2, [1, 2]];
xPermuted = permute(xMat, permuteGridAndIdx);
yUnmuted = 0*xPermuted;
for k = 1 : prod(x(1).gridSize)
for k = 1 : prod(x(1).domain.gridLength)
yUnmuted(:,:,k) = sqrt(xPermuted(:,:,k));
end
y = quantity.Discrete(permute(yUnmuted, permuteBack), ...
......@@ -1707,7 +1707,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete < handle & matlab.mi
permuteBack = [(1:x.nargin)+2, [1, 2]];
xPermuted = permute(xMat, permuteGridAndIdx);
yUnmuted = 0*xPermuted;
for k = 1 : prod(x(1).gridSize)
for k = 1 : prod(x(1).domain.gridLength)
yUnmuted(:,:,k) = expm(xPermuted(:,:,k));
end
y = quantity.Discrete(permute(yUnmuted, permuteBack), ...
......
......@@ -758,7 +758,7 @@ classdef Symbolic < quantity.Function
% create grid for result
gridI = cell(1, numel(gridNameI));
for it = 1 : numel(gridNameI)
gridIdx = obj.gridIndex(gridNameI{it});
gridIdx = obj(1).domain.gridIndex(gridNameI{it});
if (gridIdx ~= 0) && ~isempty(gridIdx)
gridI{it} = obj.gridOf(gridNameI{it});
else
......@@ -801,7 +801,7 @@ classdef Symbolic < quantity.Function
% input parser since some default values depend on intGridName.
myParser = misc.Parser;
myParser.addRequired('domain', @(d) obj.gridIndex(d) ~= 0);
myParser.addRequired('domain', @(d) obj(1).domain.gridIndex(d) ~= 0);
myParser.addRequired('lowerBound', ...
@(l) isnumeric(l) || ischar(l) );
myParser.addRequired('upperBound', ...
......
......@@ -1270,8 +1270,8 @@ testCase.verifyEqual(quanZetaZeta.on(), quanZetaZetaReference);
testCase.verifyEqual(quanEta(1).gridName, {'eta', 'zeta'})
testCase.verifyEqual(quanPt.on(), shiftdim(quan.on({1, quan(1).grid{2}})));
testCase.verifyEqual( gridSize( quanZetaZeta.subs( ...
quantity.Domain('zeta', linspace(0,1,3))) ), 3);
myQuantity = quanZetaZeta.subs(quantity.Domain('zeta', linspace(0,1,3)));
testCase.verifyEqual(myQuantity(1).domain.gridLength, 3);
% 4d-case
myTestArray4d = rand(11, 21, 31, 41, 1, 2);
......
......@@ -197,7 +197,7 @@ testCase.verifyTrue(F(2,2) == f2);
f3 = quantity.Symbolic(cos(z), 'grid', {linspace(0, 1, 13)}, 'gridName', {'z'}, 'name', 'f1');
F = [f1, f3];
testCase.verifyEqual(F(2).gridSize, f1.gridSize)
testCase.verifyEqual(F(2).domain.gridLength, f1(1).domain.gridLength)
% concatenate quantitySymbolics and other values
F = [f1, 0];
......@@ -663,7 +663,7 @@ q = quantity.Symbolic(magic(3), 'grid', {linspace(0, 1, 4)'}, 'gridName', 'z');
%%
magic7 = magic(3);
magic700 = zeros(4, 3, 3);
for k = 1:q.gridSize()
for k = 1:q(1).domain.gridLength()
magic700(k, :,:) = magic7;
end
......
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