


@info:
! @deftypefn {Function File} {@var{b} =} uminus (@var{a})
! @anchor{@dynDate/uplus}
! @sp 1
! Overloads the uminus (unary soustraction) operator for the Dynare dates class (@ref{dynDate}). Decrement the date by one year, quarter,
! month or week depending on the frequency.
! @sp 2
! @strong{Inputs}
! @sp 1
! @table @ @var
! @item a
! Dynare date object instantiated by @ref{dynDate}.
! @end table
! @sp 1
! @strong{Outputs}
! @sp 1
! @table @ @var
! @item b
! Dynare date object instantiated by @ref{dynDate}.
! @end table
! @sp 2
! @strong{This function is called by:}
! @sp 2
! @strong{This function calls:}
! @ref{dynDate}
!
! @end deftypefn
@eod:

0001 function b = uminus(a) 0002 0003 %@info: 0004 %! @deftypefn {Function File} {@var{b} =} uminus (@var{a}) 0005 %! @anchor{@dynDate/uplus} 0006 %! @sp 1 0007 %! Overloads the uminus (unary soustraction) operator for the Dynare dates class (@ref{dynDate}). Decrement the date by one year, quarter, 0008 %! month or week depending on the frequency. 0009 %! @sp 2 0010 %! @strong{Inputs} 0011 %! @sp 1 0012 %! @table @ @var 0013 %! @item a 0014 %! Dynare date object instantiated by @ref{dynDate}. 0015 %! @end table 0016 %! @sp 1 0017 %! @strong{Outputs} 0018 %! @sp 1 0019 %! @table @ @var 0020 %! @item b 0021 %! Dynare date object instantiated by @ref{dynDate}. 0022 %! @end table 0023 %! @sp 2 0024 %! @strong{This function is called by:} 0025 %! @sp 2 0026 %! @strong{This function calls:} 0027 %! @ref{dynDate} 0028 %! 0029 %! @end deftypefn 0030 %@eod: 0031 0032 % Copyright (C) 2011 Dynare Team 0033 % stephane DOT adjemian AT univ DASH lemans DOT fr 0034 % 0035 % This file is part of Dynare. 0036 % 0037 % Dynare is free software: you can redistribute it and/or modify 0038 % it under the terms of the GNU General Public License as published by 0039 % the Free Software Foundation, either version 3 of the License, or 0040 % (at your option) any later version. 0041 % 0042 % Dynare is distributed in the hope that it will be useful, 0043 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0044 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0045 % GNU General Public License for more details. 0046 % 0047 % You should have received a copy of the GNU General Public License 0048 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0049 0050 if ~isa(a,'dynDate') 0051 error(['dynDate::uminus: Input argument ' inputname(1) ' must be a dynDate object.']) 0052 end 0053 0054 b = dynDate(a); 0055 0056 switch b.freq 0057 case 1 0058 b.time(1) = b.time(1)-1; 0059 case 4 0060 if b.time(2)==1 0061 b.time(1) = b.time(1)-1; 0062 b.time(2) = 4; 0063 else 0064 b.time(2) = b.time(2)-1; 0065 end 0066 case 12 0067 if b.time(2)==1 0068 b.time(1) = b.time(1)-1; 0069 b.time(2) = 12; 0070 else 0071 b.time(2) = b.time(2)-1; 0072 end 0073 case 52 0074 if b.time(2)==1 0075 b.time(1) = b.time(1)-1; 0076 b.time(2) = 52; 0077 else 0078 b.time(2) = b.time(2)-1; 0079 end 0080 otherwise 0081 error('dynDate::minus: Unknown frequency!') 0082 end 0083 0084 %@test:1 0085 %$ addpath ../matlab 0086 %$ 0087 %$ % Define some dates 0088 %$ date_1 = '1950Q1'; 0089 %$ date_2 = '1950Q4'; 0090 %$ date_3 = '1950M1'; 0091 %$ date_4 = '1950M12'; 0092 %$ date_5 = '1950W1'; 0093 %$ date_6 = '1950W52'; 0094 %$ date_7 = 2000; 0095 %$ 0096 %$ % Call the tested routine. 0097 %$ d1 = dynDate(date_1); 0098 %$ d2 = dynDate(date_2); 0099 %$ d3 = dynDate(date_3); 0100 %$ d4 = dynDate(date_4); 0101 %$ d5 = dynDate(date_5); 0102 %$ d6 = dynDate(date_6); 0103 %$ d7 = dynDate(date_7); 0104 %$ e1 = -d1; 0105 %$ e2 = -d2; 0106 %$ e3 = -d3; 0107 %$ e4 = -d4; 0108 %$ e5 = -d5; 0109 %$ e6 = -d6; 0110 %$ e7 = -d7; 0111 %$ 0112 %$ % Check the results. 0113 %$ t(1) = dyn_assert(e1.time,[1949 4]); 0114 %$ t(2) = dyn_assert(e2.time,[1950 3]); 0115 %$ t(3) = dyn_assert(e3.time,[1949 12]); 0116 %$ t(4) = dyn_assert(e4.time,[1950 11]); 0117 %$ t(5) = dyn_assert(e5.time,[1949 52]); 0118 %$ t(6) = dyn_assert(e6.time,[1950 51]); 0119 %$ t(7) = dyn_assert(e7.time,[1999 1]); 0120 %$ T = all(t); 0121 %@eof:1