dynSeries: fix scalar subtraction for octave

time-shift
Houtan Bastani 2013-07-22 17:02:13 -04:00
parent 82e45f67aa
commit 7d1899df20
1 changed files with 29 additions and 24 deletions

View File

@ -40,33 +40,38 @@ function A = minus(B,C)
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if isscalar(B) if isnumeric(B) && isreal(B) && isequal(length(B),1) && isa(C,'dynSeries')
assert(isa(C, 'dynSeries')); keyboard
b(1:size(C)) = B; A = dynSeries();
BB = dynSeries(b, C.time(1)); A.freq = C.freq;
BB.freq = C.freq; A.init = C.init;
BB.time = C.time; A.time = C.time;
BB.nobs = C.nobs; A.nobs = C.nobs;
BB.vobs = C.vobs; A.vobs = C.vobs;
BB.name = cell(BB.vobs,1); A.name = cell(A.vobs,1);
BB.tex = cell(BB.vobs,1); A.tex = cell(A.vobs,1);
BB.name(1) = {num2str(B)}; for i=1:A.vobs
A = BB - C; A.name(i) = {['minus(' num2str(B) ',' C.name{i} ')']};
A.tex(i) = {['(' num2str(B) '-' C.tex{i} ')']};
end
A.data = bsxfun(@minus, B, C.data);
return; return;
end end
if isscalar(C) if isnumeric(C) && isreal(C) && isequal(length(C),1) && isa(B,'dynSeries')
assert(isa(B, 'dynSeries')); A = dynSeries();
c(1:size(C)) = C; A.freq = B.freq;
CC = dynSeries(C, B.time(1)); A.init = B.init;
CC.freq = B.freq; A.time = B.time;
CC.time = B.time; A.nobs = B.nobs;
CC.nobs = B.nobs; A.vobs = B.vobs;
CC.vobs = B.vobs; A.name = cell(A.vobs,1);
CC.name = cell(CC.vobs,1); A.tex = cell(A.vobs,1);
CC.tex = cell(CC.vobs,1); for i=1:A.vobs
CC.name(1) = {num2str(C)}; A.name(i) = {['minus(' B.name{i} ',' num2str(C) ')']};
A = B - CC; A.tex(i) = {['(' B.tex{i} '-' num2str(C) ')']};
end
A.data = bsxfun(@minus, B.data, C);
return; return;
end end