diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m index d43f45664fd16b7d83fe153e2b4eb02310a5f0f4..2be94988ec756985d489208d47b13fe96365404d 100644 --- a/matlab/dynare_config.m +++ b/matlab/dynare_config.m @@ -62,6 +62,7 @@ addpath([dynareroot '/utilities/tests/']) addpath([dynareroot '/utilities/dates/']) addpath([dynareroot '/utilities/dataset/']) addpath([dynareroot '/utilities/general/']) +addpath([dynareroot '/reports/']) % For functions that exist only under some Octave versions % or some MATLAB versions, and for which we provide some replacement functions diff --git a/matlab/reports/@objArray/addObj.m b/matlab/reports/@objArray/addObj.m new file mode 100644 index 0000000000000000000000000000000000000000..c190b403b7264ef3f688f358d01fb1304ffa872b --- /dev/null +++ b/matlab/reports/@objArray/addObj.m @@ -0,0 +1,32 @@ +function oa = addObj(oa, varargin) +%function oa = addObj(oa, varargin) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +assert(nargin >= 2 && nargin <= 3) +assert(isa(oa, 'objArray'), 'First argument must be an objArray'); +assert(isobject(varargin{1}), 'Optional 2nd arg must be an object'); +if nargin == 3 + assert(isnumeric(varargin{2}), 'Optional 3rd arg must be an index'); +end + +if nargin == 2 + oa.objs{end+1} = varargin{1}; +elseif nargin == 3 + oa.objs{varargin{2}} = varargin{1}; +end \ No newline at end of file diff --git a/matlab/reports/@objArray/display.m b/matlab/reports/@objArray/display.m new file mode 100644 index 0000000000000000000000000000000000000000..e1665a1dfafa049b0d4f396a8b5b2d8ffca404b7 --- /dev/null +++ b/matlab/reports/@objArray/display.m @@ -0,0 +1,35 @@ +function display(oa) +%function display(oa) +% Display an objArray object +% +% INPUTS +% none +% +% OUTPUTS +% none +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +disp(' '); +disp([inputname(1) '.objs = ']); +disp(' '); +disp(oa.objs); +end \ No newline at end of file diff --git a/matlab/reports/@objArray/getObjs.m b/matlab/reports/@objArray/getObjs.m new file mode 100644 index 0000000000000000000000000000000000000000..5074710827d82525cb0f13cf0d7986baa48013ac --- /dev/null +++ b/matlab/reports/@objArray/getObjs.m @@ -0,0 +1,29 @@ +function e = getObjs(oa, varargin) +%function e = getObjs(oa, varargin) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +switch nargin + case 1 + e = oa.objs; + case 2 + e = oa.objs{varargin{1}}; + otherwise + error('objArray getObjs: invalid number of arguments'); +end +end \ No newline at end of file diff --git a/matlab/reports/@objArray/numObjs.m b/matlab/reports/@objArray/numObjs.m new file mode 100644 index 0000000000000000000000000000000000000000..513f15b4788102a4820ab52f3cdb38a58cde524d --- /dev/null +++ b/matlab/reports/@objArray/numObjs.m @@ -0,0 +1,22 @@ +function no = numObjs(oa) +%function no = numObjs(oa) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +no = size(oa.objs, 2); +end \ No newline at end of file diff --git a/matlab/reports/@objArray/objArray.m b/matlab/reports/@objArray/objArray.m new file mode 100644 index 0000000000000000000000000000000000000000..5ac61e7097e8a5c30b2d11525e51003f5e85f9a1 --- /dev/null +++ b/matlab/reports/@objArray/objArray.m @@ -0,0 +1,43 @@ +function oa = objArray(varargin) +%function oa = objArray(varargin) +% ObjArray Class Constructor +% +% INPUTS +% none +% +% OUTPUTS +% none +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +switch nargin + case 0 + oa = struct; + oa.objs = cell(0); + oa = class(oa, 'objArray'); + case 1 + assert(isa(varargin{1}, 'objArray'), ['ObjArray constructor: the only ' ... + 'valid arguments are objArray objects']); + oa = varargin{1}; + otherwise + error('ObjArray constructor: invalid number of arguments'); +end +end \ No newline at end of file diff --git a/matlab/reports/@objArray/subsasgn.m b/matlab/reports/@objArray/subsasgn.m new file mode 100644 index 0000000000000000000000000000000000000000..b1777ab1f2ea58c3ac76473c6254f60b9533d3fe --- /dev/null +++ b/matlab/reports/@objArray/subsasgn.m @@ -0,0 +1,39 @@ +function B = subsasgn(A, S, V) +% function B = subsasgn(A, S, V) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +B = A; +if length(S) > 1 + for i=1:(length(S)-1) + B = subsref(B, S(i)); + end + B = subsasgn(B, S(end), V); + B = subsasgn(A, S(1:(end-1)), B); + return +end + +switch S.type + case '()' + index = S.subs{:}; + assert(isnumeric(index)); + B.objs{index} = V; + otherwise + error('objArray subsasgn syntax error') +end +end \ No newline at end of file diff --git a/matlab/reports/@objArray/subsref.m b/matlab/reports/@objArray/subsref.m new file mode 100644 index 0000000000000000000000000000000000000000..f5e15e6907ebe175e55a79b0385300a5ce36da74 --- /dev/null +++ b/matlab/reports/@objArray/subsref.m @@ -0,0 +1,48 @@ +function A = subsref(A, S) +%function A = subsref(A, S) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +switch S(1).type + case '.' + switch S(1).subs + case fieldnames(A) + A = A.(S(1).subs); + case methods(A) + if areParensNext(S) + A = feval(S(1).subs, A, S(2).subs{:}); + S = shiftS(S); + else + A = feval(S(1).subs, A); + end + otherwise + error(['ObjArray Class: unknown field or method: ' S(1).subs]); + end + case '()' + A = getObjs(A, S(1).subs{:}); + case '{}' + error(['ObjArray Class: ' S(1).type ' indexing not supported.']); + otherwise + error('ObjArray Class: subsref.m impossible case') +end + +S = shiftS(S); +if length(S) >= 1 + A = subsref(A, S); +end +end diff --git a/matlab/reports/@page/addSection.m b/matlab/reports/@page/addSection.m new file mode 100644 index 0000000000000000000000000000000000000000..3b02c922ec3d014c5c52d954b486d0a6367d0b10 --- /dev/null +++ b/matlab/reports/@page/addSection.m @@ -0,0 +1,50 @@ +function p = addSection(p, varargin) +%function p = addSection(p, varargin) +% Add a section to the Cell Array of sections in the report +% +% INPUTS +% 1 args => add empty section +% 2 args => add given section +% 3 args => add section at index +% +% OUTPUTS +% updated report object +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +assert(nargin >= 1 && nargin <= 3, ['incorrect number of arguments passed ' ... + 'to addSection']); +assert(isa(p, 'page'), 'First argument must be a page object'); +if nargin > 1 + assert(isa(varargin{1},'section'), ['Optional 2nd arg to addSection must be a ' ... + 'Section']); + if nargin > 2 + assert(isnumeric(varargin{2}), ['Optional 3rd arg to addSection must be ' ... + 'an index']); + end +end + +if nargin == 1 + p.sections = p.sections.addSection(section()); +elseif nargin == 2 || nargin == 3 + p.sections = p.sections.addSection(varargin{:}); +end +end diff --git a/matlab/reports/@page/numSections.m b/matlab/reports/@page/numSections.m new file mode 100644 index 0000000000000000000000000000000000000000..faa61e7b72e3945d06ac7fa510763df2fc5520fc --- /dev/null +++ b/matlab/reports/@page/numSections.m @@ -0,0 +1,32 @@ +function ns = numSections(p) +%function ns = numSections(p) +% return the number of sections currently in the page +% +% INPUTS +% none +% +% OUTPUTS +% none +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +ns = p.sections.numSections(); +end \ No newline at end of file diff --git a/matlab/reports/@page/page.m b/matlab/reports/@page/page.m new file mode 100644 index 0000000000000000000000000000000000000000..ded4d5d278d1fec0d2cff06d6dbd92418a60b1f8 --- /dev/null +++ b/matlab/reports/@page/page.m @@ -0,0 +1,45 @@ +function p = page(varargin) +%function p = page(varargin) +% Page Class Constructor +% +% INPUTS +% 0 args => empty page +% 1 arg (page class) => copy object +% +% OUTPUTS +% none +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +p = struct; +p.sections = sections(); + +switch nargin + case 0 + p = class(p, 'page'); + case 1 + assert(isa(varargin{1}, 'page'), ['Page constructor: the only valid ' ... + 'arguments are page objects']); + p = varargin{1}; + otherwise + error('Page constructor: invalid number of arguments'); +end +end \ No newline at end of file diff --git a/matlab/reports/@page/subsasgn.m b/matlab/reports/@page/subsasgn.m new file mode 100644 index 0000000000000000000000000000000000000000..385309030ca0448af6d227434def001c908be2e6 --- /dev/null +++ b/matlab/reports/@page/subsasgn.m @@ -0,0 +1,46 @@ +function B = subsasgn(A, S, V) +% function B = subsasgn(A, S, V) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +B = A; +if length(S) > 1 + for i=1:(length(S)-1) + B = subsref(B, S(i)); + end + B = subsasgn(B, S(end), V); + B = subsasgn(A, S(1:(end-1)), B); + return +end + +switch S.type + case '()' + index = S.subs{:}; + assert(isnumeric(index)); + B{index} = V; + case '.' + switch S.subs + case fields(A) + B.(S.subs) = V; + otherwise + error(['field ' S.subs 'does not exist in the page class']) + end + otherwise + error('report subsasign syntax error') +end +end \ No newline at end of file diff --git a/matlab/reports/@page/subsref.m b/matlab/reports/@page/subsref.m new file mode 100644 index 0000000000000000000000000000000000000000..7b3826bb94208d97283882811f845e46cee36672 --- /dev/null +++ b/matlab/reports/@page/subsref.m @@ -0,0 +1,48 @@ +function A = subsref(A, S) +%function A = subsref(A, S) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +switch S(1).type + case '.' + switch S(1).subs + case fieldnames(A) + A = A.(S(1).subs); + case methods(A) + if areParensNext(S) + A = feval(S(1).subs, A, S(2).subs{:}); + S = shiftS(S); + else + A = feval(S(1).subs, A); + end + otherwise + error(['Page Class: unknown field or method: ' S(1).subs]); + end + case '()' + A = getSections(A, S(1).subs{:}); + case '{}' + error(['Page Class: ' S(1).type ' indexing not supported.']); + otherwise + error('Page Class: subsref.m impossible case') +end + +S = shiftS(S); +if length(S) >= 1 + A = subsref(A, S); +end +end diff --git a/matlab/reports/@pages/addPage.m b/matlab/reports/@pages/addPage.m new file mode 100644 index 0000000000000000000000000000000000000000..072f04f575d5640d47c29688f975d80d2825e8cb --- /dev/null +++ b/matlab/reports/@pages/addPage.m @@ -0,0 +1,27 @@ +function ps = addPage(ps, varargin) +% function ps = addPage(ps, varargin) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +assert(nargin >= 1 && nargin <= 3) +if nargin == 1 + ps.objArray = ps.objArray.addObj(page()); +else + ps.objArray = ps.objArray.addObj(varargin{:}); +end +end \ No newline at end of file diff --git a/matlab/reports/@pages/getPages.m b/matlab/reports/@pages/getPages.m new file mode 100644 index 0000000000000000000000000000000000000000..2fd7f7f1446d2a68d588455eac2fbe9d856e8d53 --- /dev/null +++ b/matlab/reports/@pages/getPages.m @@ -0,0 +1,22 @@ +function e = getPages(ps, varargin) +% function e = getPages(ps, varargin) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +e = ps.objArray.getObjs(varargin{:}); +end \ No newline at end of file diff --git a/matlab/reports/@pages/numPages.m b/matlab/reports/@pages/numPages.m new file mode 100644 index 0000000000000000000000000000000000000000..8347e8347804ab26b339f5e5efc98b8fb7c0fd4a --- /dev/null +++ b/matlab/reports/@pages/numPages.m @@ -0,0 +1,22 @@ +function np = numPages(ps) +% function np = numPages(ps) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +np = ps.objArray.numObjs(); +end \ No newline at end of file diff --git a/matlab/reports/@pages/pages.m b/matlab/reports/@pages/pages.m new file mode 100644 index 0000000000000000000000000000000000000000..189ab2d7dc58a8073fdf8d4208121ca60214c991 --- /dev/null +++ b/matlab/reports/@pages/pages.m @@ -0,0 +1,42 @@ +function ps = pages(varargin) +%function ps = pages(varargin) +% Pages Class Constructor +% +% INPUTS +% Optional pages object +% +% OUTPUTS +% pages object +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +switch nargin + case 0 + ps = class(struct, 'pages', objArray()); + case 1 + assert(isa(varargin{1}, 'pages'), ... + ['With one arg to pages constructor, you must pass an ' ... + 'pages object or a char.']); + ps = varargin{1}; + otherwise + error('Pages constructor: invalid number of arguments'); +end +end \ No newline at end of file diff --git a/matlab/reports/@pages/subsasgn.m b/matlab/reports/@pages/subsasgn.m new file mode 100644 index 0000000000000000000000000000000000000000..1916c1a5c3400acd69e24a64eca62c361dd65037 --- /dev/null +++ b/matlab/reports/@pages/subsasgn.m @@ -0,0 +1,39 @@ +function B = subsasgn(A, S, V) +% function B = subsasgn(A, S, V) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +B = A; +if length(S) > 1 + for i=1:(length(S)-1) + B = subsref(B, S(i)); + end + B = subsasgn(B, S(end), V); + B = subsasgn(A, S(1:(end-1)), B); + return +end + +switch S.type + case '()' + index = S.subs{:}; + assert(isnumeric(index)); + B.objArray(index) = V; + otherwise + error('objArray subsasign syntax error') +end +end \ No newline at end of file diff --git a/matlab/reports/@pages/subsref.m b/matlab/reports/@pages/subsref.m new file mode 100644 index 0000000000000000000000000000000000000000..8d78e5c2632954d8fa8ab4c28559cebd44e71526 --- /dev/null +++ b/matlab/reports/@pages/subsref.m @@ -0,0 +1,48 @@ +function A = subsref(A, S) +%function A = subsref(A, S) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +switch S(1).type + case '.' + switch S(1).subs + case fieldnames(A) + A = A.(S(1).subs); + case methods(A) + if areParensNext(S) + A = feval(S(1).subs, A, S(2).subs{:}); + S = shiftS(S); + else + A = feval(S(1).subs, A); + end + otherwise + error(['Pages Class: unknown field or method: ' S(1).subs]); + end + case '()' + A = getPages(A, S(1).subs{:}); + case '{}' + error(['Pages Class: ' S(1).type ' indexing not supported.']); + otherwise + error('Pages Class: subsref.m impossible case') +end + +S = shiftS(S); +if length(S) >= 1 + A = subsref(A, S); +end +end diff --git a/matlab/reports/@report/addPage.m b/matlab/reports/@report/addPage.m new file mode 100644 index 0000000000000000000000000000000000000000..9421d2886d84426fb0c44d73d2f88d0122a3e108 --- /dev/null +++ b/matlab/reports/@report/addPage.m @@ -0,0 +1,50 @@ +function r = addPage(r, varargin) +%function r = addPage(r, varargin) +% Add a page to the Cell Array of pages in the report +% +% INPUTS +% 1 args => add empty page +% 2 args => add given page +% 3 args => add page at index +% +% OUTPUTS +% updated report object +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +assert(nargin >= 1 && nargin <= 3, ['incorrect number of arguments passed ' ... + 'to addPage']); +assert(isa(r, 'report'), 'First argument must be a report object'); +if nargin > 1 + assert(isa(varargin{1},'page'), ['Optional 2nd arg to addPage must be a ' ... + 'Page']); + if nargin > 2 + assert(isnumeric(varargin{2}), ['Optional 3rd arg to addPage must be ' ... + 'an index']); + end +end + +if nargin == 1 + r.pages = r.pages.addPage(page()); +elseif nargin == 2 || nargin == 3 + r.pages = r.pages.addPage(varargin{:}); +end +end diff --git a/matlab/reports/@report/display.m b/matlab/reports/@report/display.m new file mode 100644 index 0000000000000000000000000000000000000000..e1080fa0f6043f2b0e0f98ebbf34f3d892f5ae17 --- /dev/null +++ b/matlab/reports/@report/display.m @@ -0,0 +1,47 @@ +function display(r) +%function display(r) +% Display a Report object +% +% INPUTS +% none +% +% OUTPUTS +% none +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +disp(' '); +disp([inputname(1) '.title = ']); +disp(' '); +disp([' ''' r.title '''']); +disp(' ') +disp([inputname(1) '.orientation = ']); +disp(' '); +disp([' ''' r.orientation '''']); +disp(' ') +disp([inputname(1) '.numPages() = ']); +disp(' '); +disp([' ' num2str(numPages(r))]); +disp(' '); +disp([inputname(1) '.pages = ']); +disp(' '); +disp(r.pages.getPages()); +end \ No newline at end of file diff --git a/matlab/reports/@report/numPages.m b/matlab/reports/@report/numPages.m new file mode 100644 index 0000000000000000000000000000000000000000..27bc12ed0d0264bb2dee9e2b6a907f53cdf31961 --- /dev/null +++ b/matlab/reports/@report/numPages.m @@ -0,0 +1,32 @@ +function np = numPages(r) +%function np = numPages(r) +% return the number of pages currently in the report +% +% INPUTS +% none +% +% OUTPUTS +% none +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +np = r.pages.numPages(); +end \ No newline at end of file diff --git a/matlab/reports/@report/private/validateOrientation.m b/matlab/reports/@report/private/validateOrientation.m new file mode 100644 index 0000000000000000000000000000000000000000..91927669b1883a3576571d1d4128a41be1d4682d --- /dev/null +++ b/matlab/reports/@report/private/validateOrientation.m @@ -0,0 +1,35 @@ +function orientation = validateOrientation(orientation) +%function orientation = validateOrientation(orientation) +% Validate orientation string +% +% INPUTS +% char : the orientation +% +% OUTPUTS +% char : lowercase orientation +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +assert(any(strcmpi(orientation, {'portrait', 'landscape'})), ... + ['Valid orientation arguments are: ''portrait'' and ' ... + '''landscape''.']); +orientation = lower(orientation); +end \ No newline at end of file diff --git a/matlab/reports/@report/report.m b/matlab/reports/@report/report.m new file mode 100644 index 0000000000000000000000000000000000000000..cb5cd11faf421bc6e563881722960b05b5b0472f --- /dev/null +++ b/matlab/reports/@report/report.m @@ -0,0 +1,83 @@ +function r = report(varargin) +%function r = report(varargin) +% Report Class Constructor +% +% INPUTS +% 0 args => no title, portrait orientation +% 1 arg (report class) => copy class +% 1 arg (not report class) => title +% 2 args (1st not report class) => title, orientation +% 3 args (1st not report class) => title, orientation, configuraiton +% +% OUTPUTS +% none +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +% default values +r = struct; +r.title = ''; +r.orientation = 'portrait'; +r.pages = pages(); +r.config = ''; + +% Check arguments +if nargin == 1 + assert(isa(varargin{1}, 'report') || ischar(varargin{1}), ... + ['With one arg to report constructor, you must pass either '... + 'a report object or a char.']); +end + +if nargin > 1 + assert(~isa(varargin{1}, 'report'), ... + ['With multiple args to report constructor, first argument ' ... + 'cannot be a report object.']); + for i=1:nargin + assert(ischar(varargin{i}), ... + ['With muliple args to report constructor, all '... + 'arguments must be char.']); + end +end + +% Initialize fields +switch nargin + case 0 + case 1 + if isa(varargin{1}, 'report') + r = varargin{1}; + return + else + r.title = varargin{1}; + end + case 2 + r.title = varargin{1}; + r.orientation = validateOrientation(varargin{2}); + case 3 + r.title = varargin{1}; + r.orientation = validateOrientation(varargin{2}); + r.config = varargin{3}; + otherwise + error('Report constructor: invalid number of arguments'); +end + +% Create report object +r = class(r, 'report'); +end \ No newline at end of file diff --git a/matlab/reports/@report/subsasgn.m b/matlab/reports/@report/subsasgn.m new file mode 100644 index 0000000000000000000000000000000000000000..da1c92e44b78b43ba905a65b9294798e9b5e794d --- /dev/null +++ b/matlab/reports/@report/subsasgn.m @@ -0,0 +1,46 @@ +function B = subsasgn(A, S, V) +% function B = subsasgn(A, S, V) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +B = A; +if length(S) > 1 + for i=1:(length(S)-1) + B = subsref(B, S(i)); + end + B = subsasgn(B, S(end), V); + B = subsasgn(A, S(1:(end-1)), B); + return +end + +switch S.type + case '()' + index = S.subs{:}; + assert(isnumeric(index)); + B.pages(index) = V; + case '.' + switch S.subs + case fields(A) + B.(S.subs) = V; + otherwise + error(['field ' S.subs 'does not exist in the report class']); + end + otherwise + error('report subsasign syntax error'); +end +end \ No newline at end of file diff --git a/matlab/reports/@report/subsref.m b/matlab/reports/@report/subsref.m new file mode 100644 index 0000000000000000000000000000000000000000..8d5fbab47d513a80fcabfc92d28ba16f27074e9d --- /dev/null +++ b/matlab/reports/@report/subsref.m @@ -0,0 +1,50 @@ +function A = subsref(A, S) +%function A = subsref(A, S) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +switch S(1).type + case '.' + switch S(1).subs + case fieldnames(A) + A = A.(S(1).subs); + case methods(A) + if areParensNext(S) + A = feval(S(1).subs, A, S(2).subs{:}); + S = shiftS(S); + else + A = feval(S(1).subs, A); + end + otherwise + error(['Report Class: unknown field or method: ' S(1).subs]); + end + case '()' + index = S(1).subs{:}; + assert(isnumeric(index)); + A = A(index); + case '{}' + error(['Report Class: ' S(1).type ' indexing not supported.']); + otherwise + error('Report Class: subsref.m impossible case'); +end + +S = shiftS(S); +if length(S) >= 1 + A = subsref(A, S); +end +end diff --git a/matlab/reports/@section/addSection.m b/matlab/reports/@section/addSection.m new file mode 100644 index 0000000000000000000000000000000000000000..fab549127df0454d5f9097a3d36c9309ed1d9ddd --- /dev/null +++ b/matlab/reports/@section/addSection.m @@ -0,0 +1,27 @@ +function ss = addSection(ss, varargin) +% function ss = addSection(ss, varargin) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +assert(nargin >= 1 && nargin <= 3) +if nargin == 1 + ss.objArray = ss.objArray.addObj(section()); +else + ss.objArray = ss.objArray.addObj(varargin{:}); +end +end \ No newline at end of file diff --git a/matlab/reports/@section/getSections.m b/matlab/reports/@section/getSections.m new file mode 100644 index 0000000000000000000000000000000000000000..e60f2270d22b11cbb1773bea47783de38c58012f --- /dev/null +++ b/matlab/reports/@section/getSections.m @@ -0,0 +1,22 @@ +function e = getSections(ss, varargin) +% function e = getSections(ss, varargin) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +e = ss.objArray.getObjs(varargin{:}); +end \ No newline at end of file diff --git a/matlab/reports/@section/numSections.m b/matlab/reports/@section/numSections.m new file mode 100644 index 0000000000000000000000000000000000000000..006f4f2bff6e78a7f5d444e571e7c8e08c8085b6 --- /dev/null +++ b/matlab/reports/@section/numSections.m @@ -0,0 +1,22 @@ +function ns = numSections(ss) +% function ns = numSections(ss) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +ns = ss.objArray.numObjs(); +end \ No newline at end of file diff --git a/matlab/reports/@section/section.m b/matlab/reports/@section/section.m new file mode 100644 index 0000000000000000000000000000000000000000..bffe133077a813390d340c7e5a8ea5b2879a68d2 --- /dev/null +++ b/matlab/reports/@section/section.m @@ -0,0 +1,32 @@ +function s = section(varargin) +%function s = section(varargin) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +switch nargin + case 0 + s = class(struct, 'section', objArray()); + case 1 + assert(isa(varargin{1}, 'section'), ['Section constructor: the only ' ... + 'valid arguments are section objects']); + s = varargin{1}; + otherwise + error('Section constructor: invalid number of arguments'); +end +end + diff --git a/matlab/reports/@section/subsasgn.m b/matlab/reports/@section/subsasgn.m new file mode 100644 index 0000000000000000000000000000000000000000..3311423eed38fb06587ccb8a3444ce8a70e76582 --- /dev/null +++ b/matlab/reports/@section/subsasgn.m @@ -0,0 +1,39 @@ +function B = subsasgn(A, S, V) +% function B = subsasgn(A, S, V) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +B = A; +if length(S) > 1 + for i=1:(length(S)-1) + B = subsref(B, S(i)); + end + B = subsasgn(B, S(end), V); + B = subsasgn(A, S(1:(end-1)), B); + return +end + +switch S.type + case '()' + index = S.subs{:}; + assert(isnumeric(index)); + B(index) = V; + otherwise + error('objArray subsasign syntax error') +end +end \ No newline at end of file diff --git a/matlab/reports/@section/subsref.m b/matlab/reports/@section/subsref.m new file mode 100644 index 0000000000000000000000000000000000000000..56773a65e843136aba3574c9ba7b9a07a8a9a397 --- /dev/null +++ b/matlab/reports/@section/subsref.m @@ -0,0 +1,48 @@ +function A = subsref(A, S) +%function A = subsref(A, S) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +switch S(1).type + case '.' + switch S(1).subs + case fieldnames(A) + A = A.(S(1).subs); + case methods(A) + if areParensNext(S) + A = feval(S(1).subs, A, S(2).subs{:}); + S = shiftS(S); + else + A = feval(S(1).subs, A); + end + otherwise + error(['Section Class: unknown field or method: ' S(1).subs]); + end + case '()' + A = getSections(A, S(1).subs{:}); + case '{}' + error(['Section Class: ' S(1).type ' indexing not supported.']); + otherwise + error('Section Class: subsref.m impossible case') +end + +S = shiftS(S); +if length(S) >= 1 + A = subsref(A, S); +end +end diff --git a/matlab/reports/@sections/addSection.m b/matlab/reports/@sections/addSection.m new file mode 100644 index 0000000000000000000000000000000000000000..fab549127df0454d5f9097a3d36c9309ed1d9ddd --- /dev/null +++ b/matlab/reports/@sections/addSection.m @@ -0,0 +1,27 @@ +function ss = addSection(ss, varargin) +% function ss = addSection(ss, varargin) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +assert(nargin >= 1 && nargin <= 3) +if nargin == 1 + ss.objArray = ss.objArray.addObj(section()); +else + ss.objArray = ss.objArray.addObj(varargin{:}); +end +end \ No newline at end of file diff --git a/matlab/reports/@sections/getSections.m b/matlab/reports/@sections/getSections.m new file mode 100644 index 0000000000000000000000000000000000000000..e60f2270d22b11cbb1773bea47783de38c58012f --- /dev/null +++ b/matlab/reports/@sections/getSections.m @@ -0,0 +1,22 @@ +function e = getSections(ss, varargin) +% function e = getSections(ss, varargin) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +e = ss.objArray.getObjs(varargin{:}); +end \ No newline at end of file diff --git a/matlab/reports/@sections/numSections.m b/matlab/reports/@sections/numSections.m new file mode 100644 index 0000000000000000000000000000000000000000..006f4f2bff6e78a7f5d444e571e7c8e08c8085b6 --- /dev/null +++ b/matlab/reports/@sections/numSections.m @@ -0,0 +1,22 @@ +function ns = numSections(ss) +% function ns = numSections(ss) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +ns = ss.objArray.numObjs(); +end \ No newline at end of file diff --git a/matlab/reports/@sections/sections.m b/matlab/reports/@sections/sections.m new file mode 100644 index 0000000000000000000000000000000000000000..bacde01981ca3ed7cb14c473f93200cb9400d60a --- /dev/null +++ b/matlab/reports/@sections/sections.m @@ -0,0 +1,32 @@ +function s = sections(varargin) +%function s = sections(varargin) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +switch nargin + case 0 + s = class(struct, 'sections', objArray()); + case 1 + assert(isa(varargin{1}, 'sections'), ['Sections constructor: the only ' ... + 'valid arguments are sections objects']); + s = varargin{1}; + otherwise + error('Sections constructor: invalid number of arguments'); +end +end + diff --git a/matlab/reports/@sections/subsasgn.m b/matlab/reports/@sections/subsasgn.m new file mode 100644 index 0000000000000000000000000000000000000000..3311423eed38fb06587ccb8a3444ce8a70e76582 --- /dev/null +++ b/matlab/reports/@sections/subsasgn.m @@ -0,0 +1,39 @@ +function B = subsasgn(A, S, V) +% function B = subsasgn(A, S, V) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +B = A; +if length(S) > 1 + for i=1:(length(S)-1) + B = subsref(B, S(i)); + end + B = subsasgn(B, S(end), V); + B = subsasgn(A, S(1:(end-1)), B); + return +end + +switch S.type + case '()' + index = S.subs{:}; + assert(isnumeric(index)); + B(index) = V; + otherwise + error('objArray subsasign syntax error') +end +end \ No newline at end of file diff --git a/matlab/reports/@sections/subsref.m b/matlab/reports/@sections/subsref.m new file mode 100644 index 0000000000000000000000000000000000000000..89e2948f8098fdb651795efe75e4fd6526514821 --- /dev/null +++ b/matlab/reports/@sections/subsref.m @@ -0,0 +1,48 @@ +function A = subsref(A, S) +%function A = subsref(A, S) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +switch S(1).type + case '.' + switch S(1).subs + case fieldnames(A) + A = A.(S(1).subs); + case methods(A) + if areParensNext(S) + A = feval(S(1).subs, A, S(2).subs{:}); + S = shiftS(S); + else + A = feval(S(1).subs, A); + end + otherwise + error(['Sections Class: unknown field or method: ' S(1).subs]); + end + case '()' + A = getSections(A, S(1).subs{:}); + case '{}' + error(['Sections Class: ' S(1).type ' indexing not supported.']); + otherwise + error('Sections Class: subsref.m impossible case') +end + +S = shiftS(S); +if length(S) >= 1 + A = subsref(A, S); +end +end diff --git a/matlab/reports/areParensNext.m b/matlab/reports/areParensNext.m new file mode 100644 index 0000000000000000000000000000000000000000..eb485d762f8b18018829aaa883c234fd526e98bc --- /dev/null +++ b/matlab/reports/areParensNext.m @@ -0,0 +1,26 @@ +function tf = areParensNext(S) +%function tf = areParensNext(S) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +if length(S) > 1 && strcmp(S(2).type, '()') + tf = true; +else + tf = false; +end +end \ No newline at end of file diff --git a/matlab/reports/shiftS.m b/matlab/reports/shiftS.m new file mode 100644 index 0000000000000000000000000000000000000000..044bb4460fa35ecb7b1cef9bfefe4242a62cff25 --- /dev/null +++ b/matlab/reports/shiftS.m @@ -0,0 +1,26 @@ +function S = shiftS(S) +%function S = shiftS(S) + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +if length(S) > 1 + S = S(2:end); +else + S = {}; +end +end