Commit e8db3aa2 authored by Ferdinand Fischer's avatar Ferdinand Fischer
Browse files

Fixed muliplication of empty quantities

parent 6fbaea5c
......@@ -1656,8 +1656,9 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
sa = size(a);
sb = size(b);
if sa(2) == 0 && sb(1) == 0
error("Error: quantities with dimensions (n, 0) * (0, m) cannot be multiplied");
if sa(2) == 0 && sb(1) == 0 && sb(end) ~= 0
error("quantity:Discrete:mTimes", ...
"Error: quantities with dimensions (n, 0) * (0, m) cannot be multiplied");
else
P = quantity.Discrete.empty([sa(1:end-1) sb(2:end)]);
end
......
......@@ -1310,6 +1310,13 @@ testCase.verifyTrue( numeric.near( squeeze(double(a * 42)), [sin(z * pi) * 42, c
testCase.verifyTrue( numeric.near( squeeze(double(s * a')), [sin(z * pi) * 42, cos(z * pi) * 42]));
testCase.verifyTrue( numeric.near( squeeze(double(a * s)), [sin(z * pi) * 42, cos(z * pi) * 42]));
%% test multiplication with empty quantities
e1 = quantity.Discrete.empty([3, 0]);
testCase.verifyTrue( isempty( e1.' * e1 ) );
testCase.verifyError( @() e1 * e1.', "quantity:Discrete:mTimes" )
testCase.verifyEqual( size(e1 * quantity.Discrete.empty()), [3 0])
end
function testOnConstant(testCase)
......
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