Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sébastien Villemot
dseries
Commits
8b956787
Commit
8b956787
authored
Feb 21, 2018
by
Stéphane Adjemian
Browse files
Added shortcircuit in lead and lag methods if p==0.
parent
094eafdd
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/@dseries/lag_.m
View file @
8b956787
...
...
@@ -50,10 +50,16 @@ if p<0
error
(
'dseries:WrongInputArguments'
,
'Second input argument must be non negative! Use lead method instead.'
)
end
% Check that p is an integer
if
~
isint
(
p
)
error
(
'dseries:WrongInputArguments'
,
'Second input argument must be an integer!'
)
end
% Return without changing anything if p==0
if
~
p
return
end
% Update data member
o
.
data
=
[
NaN
(
p
,
vobs
(
o
));
o
.
data
(
1
:
end
-
p
,:)];
...
...
@@ -81,4 +87,22 @@ end
%$ end
%$
%$ T = all(t);
%@eof:1
\ No newline at end of file
%@eof:1
%@test:2
%$ try
%$ data = transpose(0:1:50);
%$ ts = dseries(data,'1950Q1');
%$ ts.lag_(0);
%$ t(1) = 1;
%$ catch
%$ t(1) = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(ts.data,data,1e-15);
%$ t(3) = isempty(ts.ops)
%$ end
%$
%$ T = all(t);
%@eof:2
\ No newline at end of file
src/@dseries/lead_.m
View file @
8b956787
...
...
@@ -50,10 +50,16 @@ if p<0
error
(
'dseries:WrongInputArguments'
,
'Second input argument must be non negative! Use lag method instead.'
)
end
% Check that p is an integer
if
~
isint
(
p
)
error
(
'dseries:WrongInputArguments'
,
'Second input argument must be an integer!'
)
end
% Return without changing anything if p==0
if
~
p
return
end
% Update data member
o
.
data
=
[
o
.
data
(
p
+
1
:
end
,:);
NaN
(
p
,
vobs
(
o
));];
...
...
@@ -98,4 +104,22 @@ end
%$ end
%$
%$ T = all(t);
%@eof:2
\ No newline at end of file
%@eof:2
%@test:3
%$ try
%$ data = transpose(0:1:50);
%$ ts = dseries(data,'1950Q1');
%$ ts.lead_(0);
%$ t(1) = 1;
%$ catch
%$ t(1) = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(ts.data,data,1e-15);
%$ t(3) = isempty(ts.ops)
%$ end
%$
%$ T = all(t);
%@eof:3
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment