Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LRT_infinite_dimensional_systems
conI
Commits
89b66f7e
Commit
89b66f7e
authored
Feb 20, 2020
by
Ferdinand Fischer
Browse files
quantity.Discrete/on and cat is now working for constant quantities on an empty domain
parent
6145a465
Changes
2
Hide whitespace changes
Inline
Side-by-side
+quantity/Discrete.m
View file @
89b66f7e
...
...
@@ -372,7 +372,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete < handle & matlab.mi
end
for
it
=
1
:
numel
(
varargin
)
if
isempty
(
varargin
{
it
})
if
isempty
(
varargin
{
it
})
||
isempty
(
varargin
{
it
}(
1
)
.
domain
)
continue
;
end
assert
(
numel
(
referenceGridName
)
==
numel
(
varargin
{
it
}(
1
)
.
gridName
),
...
...
...
@@ -2116,15 +2116,16 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete < handle & matlab.mi
for
k
=
1
:
numel
(
obj
)
v
(:,
k
)
=
obj
(
k
)
.
valueDiscrete
(:);
end
value
=
reshape
(
v
,
[
obj
(
1
)
.
gridSize
(),
size
(
obj
)]);
value
=
reshape
(
v
,
[
obj
(
1
)
.
gridSize
(),
size
(
obj
)]);
if
nargin
==
2
&&
myDomain
~=
obj
(
1
)
.
domain
% if a new domain is specified for the evaluation of
% the quantity, ...
if
obj
.
isConstant
% ... duplicate the constant value on the desired
% domain
value
=
repmat
(
v
alue
,
[
cellfun
(
@
(
v
)
numel
(
v
),
{
myDomain
.
grid
}),
ones
(
1
,
length
(
size
(
obj
)))]);
value
=
repmat
(
v
,
[
cellfun
(
@
(
v
)
numel
(
v
),
{
myDomain
.
grid
}),
ones
(
1
,
length
(
size
(
obj
)))]);
else
%... do an interpolation based on the old data.
indexGrid
=
arrayfun
(
@
(
s
)
1
:
s
,
size
(
obj
),
'UniformOutput'
,
false
);
...
...
+unittests/+quantity/testDiscrete.m
View file @
89b66f7e
...
...
@@ -225,10 +225,17 @@ compareED = quantity.Discrete({tan(t*z), sin(t * z); cos(t * z), cos(t*z)}, 'gri
testCase
.
verifyEqual
(
ED
.
on
(),
compareED
.
on
())
% concatenation of a constant and a function:
const
=
quantity
.
Discrete
([
5
;
2
],
'domain'
,
quantity
.
Domain
.
empty
);
C
=
[
5
;
2
];
const
=
quantity
.
Discrete
(
C
,
'domain'
,
quantity
.
Domain
.
empty
);
%
% [const, A]
% [A, const]
constA
=
[
const
,
A
];
testCase
.
verifyTrue
(
all
(
constA
(
1
,
1
)
.
on
()
==
C
(
1
)));
testCase
.
verifyTrue
(
all
(
constA
(
2
,
1
)
.
on
()
==
C
(
2
)));
Aconst
=
[
A
,
const
];
testCase
.
verifyTrue
(
all
(
Aconst
(
1
,
2
)
.
on
()
==
C
(
1
)));
testCase
.
verifyTrue
(
all
(
Aconst
(
2
,
2
)
.
on
()
==
C
(
2
)));
end
...
...
@@ -548,6 +555,9 @@ testCase.verifyEqual(permute(createTestData(linspace(0, 1, 21), linspace(0, 1, 2
value
(:,:,
1
,
2
)
=
1
+
zGridA
+
zetaGridA
.^
2
;
value
(:,:,
2
,
3
)
=
1
+
zeros
(
numel
(
gridVecA
),
numel
(
gridVecB
));
end
end
function
testOn2
(
testCase
)
...
...
@@ -897,12 +907,17 @@ testCase.verifyTrue( numeric.near( squeeze(double(s * a')), [sin(z * pi) * 42, c
testCase
.
verifyTrue
(
numeric
.
near
(
squeeze
(
double
(
a
*
s
)),
[
sin
(
z
*
pi
)
*
42
,
cos
(
z
*
pi
)
*
42
]));
end
% function testOnConstant(testCase)
%
% const = quantity.Discrete([0 1; 2 3], 'domain', quantity.Domain.empty);
% const.on([1:5]);
%
% end
function
testOnConstant
(
testCase
)
A
=
[
0
1
;
2
3
];
const
=
quantity
.
Discrete
(
A
,
'domain'
,
quantity
.
Domain
.
empty
);
C
=
const
.
on
([
1
:
5
]);
for
k
=
1
:
numel
(
A
)
testCase
.
verifyTrue
(
all
(
A
(
k
)
==
C
(:,
k
)
));
end
end
function
testIsConstant
(
testCase
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment