Skip to content

Commit 73abd21

Browse files
committed
Tweak version checks around broadcasting for Octave
Chebfun only supports Octave >= 11 so there is no need for a specific version check on Octave.
1 parent 25d0549 commit 73abd21

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

@chebfun/dimCheck.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
function out = dimCheck(f, g, ~)
22
%DIMCHECK Check dimension compatibility of two CHEBFUN objects.
3-
% In MATLAB 2016a and below DIMCHECK(F, G) returns:
3+
% The behaviour depends on whether "broadcasting" is suppported.
4+
% Without broacasting (e.g., MATLAB <= 2016a) DIMCHECK(F, G) returns:
45
% 1 if numColumns(F) == numColumns(G)
56
% error otherwise.
67
%
7-
% In MATLAB 2016b and above DIMCHECK(F, G) returns:
8+
% With brodcasting (e.g., MATLAB >= 2016b) DIMCHECK(F, G) returns:
89
% 1 if numColumns(F) == numColumns(G)
910
% -1 if numColumns(F) == 1 or numColumns(G) == 1
1011
% error otherwise.
@@ -29,8 +30,8 @@
2930
end
3031

3132
% Adjust for MATLAB version if out = -1:
32-
if ( (out == -1 ) && verLessThan('matlab', '9.1') )
33-
out = 0;
33+
if ( (out == -1 ) && ~is_octave() && verLessThan('matlab', '9.1') )
34+
out = 0;
3435
end
3536

3637
if ( out == 0 && nargin == 2 )

tests/chebtech/test_minus.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,20 @@
7272
g = testclass.make(g_op, [], pref);
7373
pass(n, 16:17) = test_sub_function_and_function(f, f_op, g, g_op, x);
7474

75-
% This should fail with a dimension mismatch error.
76-
% (Actually, we can do this in R2016a anda above!)
75+
% This used to fail with a dimension mismatch error.
76+
% (But we can do this in R2016a and later b/c of broadcasting)
7777
g_op = @(x) sin(x);
7878
g = testclass.make(g_op, [], pref);
79-
try
79+
try
8080
h = f - g; %#ok<NASGU>
8181
pass(n, 18) = false;
82-
if ( verLessThan('matlab', '9.1') )
82+
if ( ~is_octave() && verLessThan('matlab', '9.1') )
8383
pass(n, 18) = false;
8484
else
8585
pass(n, 18) = true;
8686
end
8787
catch ME
88-
if ( verLessThan('matlab', '9.1') )
88+
if ( ~is_octave() && verLessThan('matlab', '9.1') )
8989
pass(n, 18) = strcmp(ME.identifier, 'MATLAB:dimagree');
9090
else
9191
pass(n, 18) = false;

tests/chebtech/test_plus.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,19 @@
7373
g = testclass.make(g_op, [], pref);
7474
pass(n, 16:17) = test_add_function_to_function(f, f_op, g, g_op, x);
7575

76-
% This should fail with a dimension mismatch error.
76+
% Used to fail with a dimension mismatch error before broadcasting was added
7777
g_op = @(x) sin(x);
7878
g = testclass.make(g_op, [], pref);
79-
try
79+
try
8080
h = f + g; %#ok<NASGU>
8181
pass(n, 18) = false;
82-
if ( verLessThan('matlab', '9.1') )
82+
if ( ~is_octave() && verLessThan('matlab', '9.1') )
8383
pass(n, 18) = false;
8484
else
8585
pass(n, 18) = true;
8686
end
8787
catch ME
88-
if ( verLessThan('matlab', '9.1') )
88+
if ( ~is_octave() && verLessThan('matlab', '9.1') )
8989
pass(n, 18) = strcmp(ME.identifier, 'MATLAB:dimagree');
9090
else
9191
pass(n, 18) = false;

0 commit comments

Comments
 (0)