-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathopEye.m
75 lines (65 loc) · 2.1 KB
/
opEye.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
classdef opEye < opSpot
%OPEYE Identity operator.
%
% opEye(M) creates the M-by-M identity operator.
%
% opEye(M,N) creates the M-by-N identity operator. If N is omitted
% it is set to M by default. Without any arguments an operator
% corresponding to the scalar 1 is created.
%
% opEye([M N]) is the same as the above.
% Copyright 2009, Ewout van den Berg and Michael P. Friedlander
% See the file COPYING.txt for full copyright information.
% Use the command 'spot.gpl' to locate this file.
% http://www.cs.ubc.ca/labs/scl/spot
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Methods - Public
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
methods
% Constructor
function op = opEye(varargin)
if nargin == 0
m = 1; n = 1;
elseif nargin == 1
if length(varargin{1}) == 2
m = varargin{1}(1);
n = varargin{1}(2);
else
m = varargin{1};
n = m;
end
elseif nargin == 2
m = varargin{1};
n = varargin{2};
else
error('Too many input arguments.');
end
op = op@opSpot('Eye',m,n);
end % function opEye
function A = double(op)
A = eye(size(op));
end % double
end % Methods
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Methods - protected
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
methods( Access = protected )
% Multiplication
function y = multiply(op,x,mode)
[m,n] = size(op);
if mode == 1
if m <= n
y = x(1:m);
else
y = [x; zeros(m-n,1)];
end
else
if n <= m
y = x(1:n);
else
y = [x; zeros(n-m,1)];
end
end
end % multiply
end % Methods
end % Classdef