Skip to content

Commit

Permalink
Merge pull request #104 from tristangdwl/kern_shift_ops
Browse files Browse the repository at this point in the history
Added shifted_eval support to kernel.plus
  • Loading branch information
mrachh authored Oct 18, 2024
2 parents 4845da1 + f595ea0 commit 57807af
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions chunkie/@kernel/plus.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,28 @@
assert(f.opdims(1) == g.opdims(1) && f.opdims(2) == g.opdims(2), ...
'kernel dimensions must agree to add');
f.name = ['custom ',f.name,' ',g.name];

if(isa(f.shifted_eval, 'function_handle'))
if(isa(g.shifted_eval, 'function_handle'))
f.shifted_eval = @(varargin) f.shifted_eval(varargin{:})+g.shifted_eval(varargin{:});
else
f.shifted_eval = @(varargin) f.shifted_eval(varargin{:})+g.eval(varargin{1:2});
end
else
if(isa(g.shifted_eval, 'function_handle'))
f.shifted_eval = @(varargin) f.eval(varargin{1:2})+g.shifted_eval(varargin{:});
else
f.shifted_eval = [];
end
end

f.eval = @(varargin) g.eval(varargin{:}) + f.eval(varargin{:});
if (isa(g.fmm,'function_handle') && isa(f.fmm,'function_handle'))
f.fmm = @(varargin) g.fmm(varargin{:}) + f.fmm(varargin{:});
else
f.fmm = [];
end

if or(f.isnan,g.isnan)
f = kernel.nans(f.opdims(1),f.opdims(2));
end
Expand Down

0 comments on commit 57807af

Please sign in to comment.