-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/fastalgorithms/chunkie
- Loading branch information
Showing
11 changed files
with
382 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
function obj = nans(m, n) | ||
%KERNEL.NAN Construct the nan kernel. | ||
% KERNEL.NAN() constructs the nan kernel with operator dimensions | ||
% of 1 x 1. | ||
% | ||
% KERNEL.NAN(N) constructs the nan kernel with operator dimensions | ||
% of N x N. | ||
% | ||
% KERNEL.NAN(M, N) constructs the NAN kernel with operator dimensions | ||
% of M x N. | ||
|
||
if ( nargin < 1 ) | ||
m = 1; | ||
end | ||
|
||
if ( nargin < 2 ) | ||
n = m; | ||
end | ||
|
||
function out = eval_(s, t) | ||
[~, ns] = size(s.r); | ||
[~, nt] = size(t.r); | ||
out = nan(m*nt, n*ns); | ||
end | ||
|
||
function out = shifted_eval_(s, t, o) | ||
[~, ns] = size(s.r); | ||
[~, nt] = size(t.r); | ||
out = nan(m*nt, n*ns); | ||
end | ||
|
||
function varargout = fmm_(eps, s, t, sigma) | ||
|
||
if ( isstruct(t) ) | ||
[~, nt] = size(t.r); | ||
else | ||
[~, nt] = size(t); | ||
end | ||
|
||
if ( nargout > 0 ), varargout{1} = nan(m*nt, 1); end | ||
if ( nargout > 1 ), varargout{2} = nan(2, m*nt); end | ||
if ( nargout > 2 ), varargout{3} = nan(3, m*nt); end | ||
if ( nargout > 3 ) | ||
error('CHUNKIE:kernel:nan', 'Too many output arguments for FMM.'); | ||
end | ||
|
||
end | ||
|
||
obj = kernel(); | ||
obj.name = 'nans'; | ||
obj.opdims = [m n]; | ||
obj.sing = 'smooth'; | ||
obj.eval = @eval_; | ||
obj.shifted_eval = @shifted_eval_; | ||
obj.fmm = @fmm_; | ||
obj.isnan = true; | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
function f = plus(f,g) | ||
% + Pointwise addition for kernel class | ||
% | ||
% Currently only supported for adding two kernel class objects | ||
% or adding a scalar to a kernel class object. | ||
|
||
if (isa(g,'kernel') && isa(f,'kernel')) | ||
assert(f.opdims(1) == g.opdims(1) && f.opdims(1) == g.opdims(2), ... | ||
'kernel dimensions must agree to add'); | ||
f.name = ['custom ',f.name,' ',g.name]; | ||
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 | ||
if and(f.iszero,g.iszero) | ||
f.iszero = true; | ||
else | ||
f.iszero = false; | ||
end | ||
else | ||
error('KERNEL:plus:invalid', ... | ||
'F and G must be either floats or kernel class objects'); | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,5 +53,6 @@ | |
obj.eval = @eval_; | ||
obj.shifted_eval = @shifted_eval_; | ||
obj.fmm = @fmm_; | ||
obj.iszero = true; | ||
|
||
end |
Oops, something went wrong.