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
dc784651
Commit
dc784651
authored
Aug 31, 2020
by
Ferdinand Fischer
Browse files
fixed a bug in the evaluation of quantity.Symbolic on numeric grids,
parent
7902191f
Changes
2
Hide whitespace changes
Inline
Side-by-side
+quantity/Discrete.m
View file @
dc784651
...
...
@@ -427,7 +427,13 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
myDomain
=
misc
.
ensureIsCell
(
myDomain
);
newGrid
=
myDomain
;
if
obj
(
1
)
.
isConstant
()
% Check if the object has a domain with a name:
% If there is no name, the object has an empty quantity.Domain, i.e., it is a
% constant. Then, the gridNames should be ''
% The check "isConstant" can not be used here, because it also returns true, if
% the constant value is defined over a domain. Then, the object has a domain
% with a name that should be used.
if
isempty
(
obj
(
1
)
.
domain
.
name
)
gridNames
=
repmat
({
''
},
length
(
newGrid
));
else
gridNames
=
{
obj
(
1
)
.
domain
.
name
};
...
...
+unittests/+quantity/testSymbolic.m
View file @
dc784651
...
...
@@ -853,22 +853,32 @@ testCase.verifyEqual(on( - fDisc), on(-f));
end
function
testConstantValues
(
testCase
)
%%
%%
evaluation of a constant on the same grid
syms
z
myDomain
=
quantity
.
Domain
.
defaultDomain
(
4
,
"z"
);
q
=
quantity
.
Symbolic
(
magic
(
3
),
myDomain
);
%%
magic7
=
magic
(
3
);
magic700
=
zeros
(
4
,
3
,
3
);
for
k
=
1
:
q
(
1
)
.
domain
.
gridLength
()
magic700
(
k
,
:,:)
=
magic7
;
end
%%
testCase
.
verifyEqual
(
magic700
,
q
.
on
());
testCase
.
verifyTrue
(
q
.
isConstant
());
%% evaluation of a constant on a different grid
myDomain2
=
quantity
.
Domain
.
defaultDomain
(
7
,
"z"
);
magic7
=
magic
(
3
);
magic700
=
zeros
(
myDomain2
.
n
,
3
,
3
);
for
k
=
1
:
myDomain2
.
n
magic700
(
k
,
:,:)
=
magic7
;
end
q
.
on
(
myDomain2
);
testCase
.
verifyEqual
(
magic700
,
q
.
on
(
myDomain2
));
%%
p
=
quantity
.
Symbolic
([
0
0
0
0
z
],
myDomain
);
testCase
.
verifyFalse
(
p
.
isConstant
());
...
...
@@ -935,6 +945,9 @@ Q2D = quantity.Symbolic(magic(2), [Z, Zeta]);
%%
verifyEqual
(
testCase
,
shiftdim
(
Q
.
on
(),
1
),
magic
(
2
))
verifyEqual
(
testCase
,
shiftdim
(
Q2D
.
on
(),
2
),
magic
(
2
))
%% test the evaluation on numeric grids
verifyEqual
(
testCase
,
shiftdim
(
Q
.
on
(
1
),
1
),
magic
(
2
))
end
function
testSize
(
testCase
)
...
...
Ferdinand Fischer
@po59cyfi
mentioned in commit
5667ed5c
·
Sep 01, 2020
mentioned in commit
5667ed5c
mentioned in commit 5667ed5c53e00e4bffeb9169a9829dad4240822d
Toggle commit list
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