From fe5f61db61289dcf0a465653fd6f23272bc8c11c Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Tue, 12 Feb 2013 14:23:41 +0100
Subject: [PATCH] reporting (WIP)

---
 matlab/dynare_config.m                        |  1 +
 matlab/reports/@objArray/addObj.m             | 32 +++++++
 matlab/reports/@objArray/display.m            | 35 ++++++++
 matlab/reports/@objArray/getObjs.m            | 29 +++++++
 matlab/reports/@objArray/numObjs.m            | 22 +++++
 matlab/reports/@objArray/objArray.m           | 43 ++++++++++
 matlab/reports/@objArray/subsasgn.m           | 39 +++++++++
 matlab/reports/@objArray/subsref.m            | 48 +++++++++++
 matlab/reports/@page/addSection.m             | 50 +++++++++++
 matlab/reports/@page/numSections.m            | 32 +++++++
 matlab/reports/@page/page.m                   | 45 ++++++++++
 matlab/reports/@page/subsasgn.m               | 46 ++++++++++
 matlab/reports/@page/subsref.m                | 48 +++++++++++
 matlab/reports/@pages/addPage.m               | 27 ++++++
 matlab/reports/@pages/getPages.m              | 22 +++++
 matlab/reports/@pages/numPages.m              | 22 +++++
 matlab/reports/@pages/pages.m                 | 42 ++++++++++
 matlab/reports/@pages/subsasgn.m              | 39 +++++++++
 matlab/reports/@pages/subsref.m               | 48 +++++++++++
 matlab/reports/@report/addPage.m              | 50 +++++++++++
 matlab/reports/@report/display.m              | 47 +++++++++++
 matlab/reports/@report/numPages.m             | 32 +++++++
 .../@report/private/validateOrientation.m     | 35 ++++++++
 matlab/reports/@report/report.m               | 83 +++++++++++++++++++
 matlab/reports/@report/subsasgn.m             | 46 ++++++++++
 matlab/reports/@report/subsref.m              | 50 +++++++++++
 matlab/reports/@section/addSection.m          | 27 ++++++
 matlab/reports/@section/getSections.m         | 22 +++++
 matlab/reports/@section/numSections.m         | 22 +++++
 matlab/reports/@section/section.m             | 32 +++++++
 matlab/reports/@section/subsasgn.m            | 39 +++++++++
 matlab/reports/@section/subsref.m             | 48 +++++++++++
 matlab/reports/@sections/addSection.m         | 27 ++++++
 matlab/reports/@sections/getSections.m        | 22 +++++
 matlab/reports/@sections/numSections.m        | 22 +++++
 matlab/reports/@sections/sections.m           | 32 +++++++
 matlab/reports/@sections/subsasgn.m           | 39 +++++++++
 matlab/reports/@sections/subsref.m            | 48 +++++++++++
 matlab/reports/areParensNext.m                | 26 ++++++
 matlab/reports/shiftS.m                       | 26 ++++++
 40 files changed, 1445 insertions(+)
 create mode 100644 matlab/reports/@objArray/addObj.m
 create mode 100644 matlab/reports/@objArray/display.m
 create mode 100644 matlab/reports/@objArray/getObjs.m
 create mode 100644 matlab/reports/@objArray/numObjs.m
 create mode 100644 matlab/reports/@objArray/objArray.m
 create mode 100644 matlab/reports/@objArray/subsasgn.m
 create mode 100644 matlab/reports/@objArray/subsref.m
 create mode 100644 matlab/reports/@page/addSection.m
 create mode 100644 matlab/reports/@page/numSections.m
 create mode 100644 matlab/reports/@page/page.m
 create mode 100644 matlab/reports/@page/subsasgn.m
 create mode 100644 matlab/reports/@page/subsref.m
 create mode 100644 matlab/reports/@pages/addPage.m
 create mode 100644 matlab/reports/@pages/getPages.m
 create mode 100644 matlab/reports/@pages/numPages.m
 create mode 100644 matlab/reports/@pages/pages.m
 create mode 100644 matlab/reports/@pages/subsasgn.m
 create mode 100644 matlab/reports/@pages/subsref.m
 create mode 100644 matlab/reports/@report/addPage.m
 create mode 100644 matlab/reports/@report/display.m
 create mode 100644 matlab/reports/@report/numPages.m
 create mode 100644 matlab/reports/@report/private/validateOrientation.m
 create mode 100644 matlab/reports/@report/report.m
 create mode 100644 matlab/reports/@report/subsasgn.m
 create mode 100644 matlab/reports/@report/subsref.m
 create mode 100644 matlab/reports/@section/addSection.m
 create mode 100644 matlab/reports/@section/getSections.m
 create mode 100644 matlab/reports/@section/numSections.m
 create mode 100644 matlab/reports/@section/section.m
 create mode 100644 matlab/reports/@section/subsasgn.m
 create mode 100644 matlab/reports/@section/subsref.m
 create mode 100644 matlab/reports/@sections/addSection.m
 create mode 100644 matlab/reports/@sections/getSections.m
 create mode 100644 matlab/reports/@sections/numSections.m
 create mode 100644 matlab/reports/@sections/sections.m
 create mode 100644 matlab/reports/@sections/subsasgn.m
 create mode 100644 matlab/reports/@sections/subsref.m
 create mode 100644 matlab/reports/areParensNext.m
 create mode 100644 matlab/reports/shiftS.m

diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m
index d43f45664f..2be94988ec 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 0000000000..c190b403b7
--- /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 0000000000..e1665a1dfa
--- /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 0000000000..5074710827
--- /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 0000000000..513f15b478
--- /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 0000000000..5ac61e7097
--- /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 0000000000..b1777ab1f2
--- /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 0000000000..f5e15e6907
--- /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 0000000000..3b02c922ec
--- /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 0000000000..faa61e7b72
--- /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 0000000000..ded4d5d278
--- /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 0000000000..385309030c
--- /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 0000000000..7b3826bb94
--- /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 0000000000..072f04f575
--- /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 0000000000..2fd7f7f144
--- /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 0000000000..8347e83478
--- /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 0000000000..189ab2d7dc
--- /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 0000000000..1916c1a5c3
--- /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 0000000000..8d78e5c263
--- /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 0000000000..9421d2886d
--- /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 0000000000..e1080fa0f6
--- /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 0000000000..27bc12ed0d
--- /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 0000000000..91927669b1
--- /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 0000000000..cb5cd11faf
--- /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 0000000000..da1c92e44b
--- /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 0000000000..8d5fbab47d
--- /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 0000000000..fab549127d
--- /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 0000000000..e60f2270d2
--- /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 0000000000..006f4f2bff
--- /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 0000000000..bffe133077
--- /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 0000000000..3311423eed
--- /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 0000000000..56773a65e8
--- /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 0000000000..fab549127d
--- /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 0000000000..e60f2270d2
--- /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 0000000000..006f4f2bff
--- /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 0000000000..bacde01981
--- /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 0000000000..3311423eed
--- /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 0000000000..89e2948f80
--- /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 0000000000..eb485d762f
--- /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 0000000000..044bb4460f
--- /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
-- 
GitLab