-
Notifications
You must be signed in to change notification settings - Fork 2
/
oplWindow1Davg.m
102 lines (92 loc) · 3.05 KB
/
oplWindow1Davg.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
classdef oplWindow1Davg < opSpot
%oplWindow1Davg tapered windowing for CARP-CG method
%
% oplWindow1Davg(N,P,H)
%
% ARGUMENTS:
% N = length of the input vector
% P = number of processors
% H = half of the overlap's size
%
% ATTRIBUTES:
% oshape = (p,3) vector holding start, size, end indecies
% of the default distribution of the input vector in every window
% yshape = (p,3) vector holding start, size, end indecies
% of the default distribution of the output vector in every window
% xshape = (p,3) vector holding start, size, end indecies
% of the input vector that will end up in every ouput window
%
% Notes:
% 1. This is not a parallel/distributed operator
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Properties
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
properties (SetAccess = private)
p = 0;
h = 0;
oshape = 0;
yshape = 0;
xshape = 0;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Methods - Public
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
methods
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Constructor
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function op = oplWindow1Davg(varargin)
assert(nargin==3,'lWindow1Davg: wrong # of arguments')
n = varargin{1};
p = varargin{2};
h = varargin{3};
[ m os ys xs ] = pSPOT.pWindow.funWindow1DShape( n, p, h );
op = op@opSpot('lWindow1Davg',m,n);
op.p = p;
op.h = h;
op.oshape = os;
op.yshape = ys;
op.xshape = xs;
end % function oplWindow1Davg
% xtratests
function result = xtratests(op)
T = 14;
x0=rand(op.n,1);
y=op*x0;
x1=op'*y;
check=norm(x1-x0);
if check < op.n*10^-T
result = true;
else
result = false;
end
end % xtratests
% utest ( skip dottest )
function output = utest(op,k,verbose)
try
addpath(fullfile(spot.path,'tests','xunit'))
catch ME
error('Can''t find xunit toolbox.')
end
if nargin < 3, verbose = 0; end
if nargin < 2, k = 5; end
assertTrue(op.xtratests,k);
output = 'PASSED!';
end % utest
end % Methods
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Methods - protected
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
methods( Access = protected )
% Multiplication
function y = multiply(op,x,mode)
if (mode == 1)
[ A ] = pSPOT.pWindow.funWindow1DavgFor(op.n,op.p,op.h);
y = A * x;
else
[ B ] = pSPOT.pWindow.funWindow1DavgBck(op.n,op.p,op.h);
y = B * x;
end
end % Multipy
end % Methods
end % Classdef