Skip to content

Commit 7dccb49

Browse files
committed
Added support for older-style operator overloading for octave
1 parent 1e66c17 commit 7dccb49

File tree

1 file changed

+20
-31
lines changed

1 file changed

+20
-31
lines changed

src/+otp/RHS.m

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
classdef RHS < matlab.mixin.indexing.RedefinesParen
1+
classdef RHS
22
properties (SetAccess = private)
33
F
44

@@ -21,29 +21,6 @@
2121
HessianAdjointVectorProduct
2222
OnEvent
2323
end
24-
25-
methods (Access = protected)
26-
function newRHS = parenReference(obj, indexClass)
27-
objF = obj.F;
28-
subst.type = '()';
29-
subst.subs = indexClass.Indices;
30-
newF = @(t, y) subsref(objF(t, y), subst);
31-
newRHS = otp.RHS(newF);
32-
end
33-
34-
function newRHS = parenAssign(~, ~,~)
35-
error('');
36-
end
37-
38-
function newRHS = parenListLength(~, ~,~)
39-
error('');
40-
end
41-
42-
function newRHS = parenDelete(~, ~,~)
43-
error('');
44-
end
45-
end
46-
4724

4825
methods
4926
function obj = RHS(F, varargin)
@@ -57,22 +34,34 @@
5734
end
5835
end
5936

37+
function newRHS = subsref(obj, vs)
38+
if strcmp(vs(1).type, '()')
39+
objF = obj.F;
40+
newF = @(t, y) subsref(objF(t, y), vs);
41+
newRHS = otp.RHS(newF);
42+
else
43+
newRHS = builtin('subsref', obj, vs);
44+
end
45+
end
46+
6047
function newRHS = plus(obj, other)
6148
objF = obj.F;
6249
otherF = other.F;
6350
newF = @(t, y) objF(t, y) + otherF(t, y);
6451
newRHS = otp.RHS(newF);
6552
end
6653

67-
function newRHS = cat(dim, varargin)
54+
function newRHS = vertcat(varargin)
6855
newF = @(t, y) [];
69-
if dim == 1
70-
for i = 1:numel(varargin)
71-
oldRHS = varargin{i};
72-
oldF = oldRHS.F;
73-
newF = @(t, y) [newF(t, y); oldF(t, y)];
74-
end
56+
57+
for i = 1:numel(varargin)
58+
oldRHS = varargin{i};
59+
oldF = oldRHS.F;
60+
61+
newF = @(t, y) [newF(t, y); oldF(t, y)];
62+
7563
end
64+
7665
newRHS = otp.RHS(newF);
7766
end
7867

0 commit comments

Comments
 (0)