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
bc5009d0
Commit
bc5009d0
authored
May 27, 2019
by
Jakob Gabriel
Browse files
quantity: added unitary minus and plus (uminus and uplus): -quant = (-1)*quant
parent
69fe72d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
+quantity/Discrete.m
View file @
bc5009d0
...
...
@@ -1487,6 +1487,18 @@ classdef (InferiorClasses = {?quantity.Symbolic, ?quantity.Operator}) Discrete
[
C
.
name
]
=
deal
([
A
(
1
)
.
name
,
'-'
,
B
(
1
)
.
name
]);
end
function
C
=
uplus
(
A
)
% unitary plus: C = +A
C
=
copy
(
A
);
end
function
C
=
uminus
(
A
)
% unitary plus: C = -A
C
=
(
-
1
)
*
A
;
[
C
.
name
]
=
deal
([
'-'
,
A
(
1
)
.
name
]);
end
function
[
P
,
supremum
]
=
relativeErrorSupremum
(
A
,
B
)
assert
(
numel
(
A
)
==
numel
(
B
),
'Not implemented'
)
...
...
+unittests/+quantity/testDiscrete.m
View file @
bc5009d0
...
...
@@ -4,6 +4,23 @@ function [tests] = testDiscrete()
tests
=
functiontests
(
localfunctions
);
end
function
testUnitaryPluasAndMinus
(
testCase
)
syms
z
zeta
qSymbolic
=
quantity
.
Symbolic
(
...
[
1
+
z
*
zeta
,
-
zeta
;
-
z
,
z
^
2
],
'grid'
,
{
linspace
(
0
,
1
,
21
),
linspace
(
0
,
1
,
41
)},
...
'variable'
,
{
z
,
zeta
},
'name'
,
'q'
);
qDiscrete
=
quantity
.
Discrete
(
qSymbolic
);
qDoubleArray
=
qSymbolic
.
on
();
testCase
.
verifyEqual
(
on
(
-
qSymbolic
),
-
qDoubleArray
);
testCase
.
verifyEqual
(
on
(
-
qDiscrete
),
-
qDoubleArray
);
testCase
.
verifyEqual
(
on
(
+
qSymbolic
),
+
qDoubleArray
);
testCase
.
verifyEqual
(
on
(
+
qDiscrete
),
+
qDoubleArray
);
testCase
.
verifyEqual
(
on
(
+
qDiscrete
),
on
(
+
qSymbolic
));
testCase
.
verifyEqual
(
on
(
-
qDiscrete
),
on
(
-
qSymbolic
));
end
function
testConcatenate
(
testCase
)
t
=
linspace
(
0
,
pi
)
'
;
...
...
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