Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
78f8f045
Commit
78f8f045
authored
Feb 15, 2013
by
Houtan Bastani
Browse files
reporting (WIP)
parent
4fa14176
Changes
42
Hide whitespace changes
Inline
Side-by-side
matlab/reports/@
section/addSection
.m
→
matlab/reports/@
elements/addGraph
.m
View file @
78f8f045
function
ss
=
add
Section
(
ss
,
varargin
)
% function
ss
= add
Section(ss
, varargin)
function
e
=
add
Graph
(
e
,
varargin
)
% function
e
= add
Graph(e
, varargin)
% Copyright (C) 2013 Dynare Team
%
...
...
@@ -20,8 +20,8 @@ function ss = addSection(ss, varargin)
assert
(
nargin
>=
1
&&
nargin
<=
3
)
if
nargin
==
1
ss
.
objArray
=
ss
.
objArray
.
addObj
(
section
());
e
.
objArray
=
e
.
objArray
.
addObj
(
graph
());
else
ss
.
objArray
=
ss
.
objArray
.
addObj
(
varargin
{:});
e
.
objArray
=
e
.
objArray
.
addObj
(
varargin
{:});
end
end
\ No newline at end of file
matlab/reports/@elements/addTable.m
0 → 100644
View file @
78f8f045
function
e
=
addTable
(
e
,
varargin
)
% function e = addTable(e, 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
e
.
objArray
=
e
.
objArray
.
addObj
(
table
());
else
e
.
objArray
=
e
.
objArray
.
addObj
(
varargin
{:});
end
end
\ No newline at end of file
matlab/reports/@elements/display.m
0 → 100644
View file @
78f8f045
function
display
(
o
)
%function display(o)
% Display a Elements 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/>.
name
=
'report.page.section.elements'
;
disp
(
' '
);
disp
([
name
' = '
]);
disp
(
' '
);
disp
(
getElements
(
o
));
end
\ No newline at end of file
matlab/reports/@elements/elements.m
0 → 100644
View file @
78f8f045
function
e
=
elements
(
varargin
)
%function e = elements(varargin)
% Elements Class Constructor
%
% INPUTS
% Optional elements object
%
% OUTPUTS
% elements 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
e
=
class
(
struct
,
'elements'
,
objArray
());
case
1
assert
(
isa
(
varargin
{
1
},
'elements'
),
...
[
'With one arg to elements constructor, you must pass an '
...
'elements object or a char.'
]);
e
=
varargin
{
1
};
otherwise
error
(
'Elements constructor: invalid number of arguments'
);
end
end
\ No newline at end of file
matlab/reports/@
section/getSection
s.m
→
matlab/reports/@
elements/getElement
s.m
View file @
78f8f045
function
e
=
get
Section
s
(
s
s
,
varargin
)
% function e = get
Section
s(
s
s, varargin)
function
e
=
get
Element
s
(
p
s
,
varargin
)
% function e = get
Element
s(
p
s, varargin)
% Copyright (C) 2013 Dynare Team
%
...
...
@@ -18,5 +18,5 @@ function e = getSections(ss, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
e
=
s
s
.
objArray
.
getObjs
(
varargin
{:});
e
=
p
s
.
objArray
.
getObjs
(
varargin
{:});
end
\ No newline at end of file
matlab/reports/@
section/numSection
s.m
→
matlab/reports/@
elements/numElement
s.m
View file @
78f8f045
function
n
s
=
num
Sections
(
ss
)
% function n
s
= num
Sections(ss
)
function
n
=
num
Elements
(
o
)
% function n = num
Elements(o
)
% Copyright (C) 2013 Dynare Team
%
...
...
@@ -18,5 +18,5 @@ function ns = numSections(ss)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
n
s
=
ss
.
objArray
.
numObjs
();
n
=
o
.
objArray
.
numObjs
();
end
\ No newline at end of file
matlab/reports/@elements/subsasgn.m
0 → 100644
View file @
78f8f045
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
(
'Elements subsasign syntax error'
)
end
end
\ No newline at end of file
matlab/reports/@elements/subsref.m
0 → 100644
View file @
78f8f045
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
([
'Elements Class: unknown field or method: '
S
(
1
)
.
subs
]);
end
case
'()'
A
=
getElements
(
A
,
S
(
1
)
.
subs
{:});
case
'{}'
error
([
'Elements Class: '
S
(
1
)
.
type
' indexing not supported.'
]);
otherwise
error
(
'Elements Class: subsref.m impossible case'
)
end
S
=
shiftS
(
S
);
if
length
(
S
)
>=
1
A
=
subsref
(
A
,
S
);
end
end
matlab/reports/@graph/display.m
0 → 100644
View file @
78f8f045
function
display
(
o
)
%function display(o)
% Display a Graph 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/>.
name
=
'report.page.section.graph'
;
disp
(
' '
);
disp
([
name
'.caption = '
]);
disp
(
' '
);
disp
([
'
''
'
o
.
caption
'
''
'
]);
disp
(
' '
);
disp
([
name
'.footnote = '
]);
disp
(
' '
);
disp
([
'
''
'
o
.
footnote
'
''
'
]);
disp
(
' '
);
disp
([
name
'.filename = '
]);
disp
(
' '
);
disp
([
'
''
'
o
.
filename
'
''
'
]);
end
\ No newline at end of file
matlab/reports/@graph/graph.m
0 → 100644
View file @
78f8f045
function
o
=
graph
(
varargin
)
%function o = graph(varargin)
% Graph Class Constructor
%
% INPUTS
% 0 args => empty graph
% 1 arg (graph 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/>.
o
=
struct
;
o
.
caption
=
''
;
o
.
footnote
=
''
;
o
.
filename
=
''
;
o
.
data
=
''
;
o
.
config
=
''
;
if
nargin
==
1
assert
(
isa
(
varargin
{
1
},
'graph'
),[
'With one arg to Graph constructor, '
...
'you must pass a graph object'
]);
o
=
varargin
{
1
};
return
;
elseif
nargin
>
1
if
round
(
nargin
/
2
)
~=
nargin
/
2
error
([
'Options to Graph constructor must be supplied in name/value '
...
'pairs.'
]);
end
optNames
=
lower
(
fieldnames
(
o
));
% overwrite default values
for
pair
=
reshape
(
varargin
,
2
,
[])
field
=
lower
(
pair
{
1
});
if
any
(
strmatch
(
field
,
optNames
,
'exact'
))
o
.
(
field
)
=
pair
{
2
};
else
error
(
'%s is not a recognized option to the Graph constructor.'
,
...
field
);
end
end
end
% Create graph object
o
=
class
(
o
,
'graph'
);
end
\ No newline at end of file
matlab/reports/@graph/subsasgn.m
0 → 100644
View file @
78f8f045
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
'.'
switch
S
.
subs
case
fieldnames
(
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
matlab/reports/@graph/subsref.m
0 → 100644
View file @
78f8f045
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
([
'Graph Class: unknown field or method: '
S
(
1
)
.
subs
]);
end
case
{
'()'
,
'{}'
}
error
([
'Graph Class: '
S
(
1
)
.
type
' indexing not supported.'
]);
otherwise
error
(
'Graph Class: subsref.m impossible case'
)
end
S
=
shiftS
(
S
);
if
length
(
S
)
>=
1
A
=
subsref
(
A
,
S
);
end
end
matlab/reports/@graph/write.m
0 → 100644
View file @
78f8f045
function
write
(
o
,
fid
,
texIndent
)
%function write(o, fid)
% Write a Page 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/>.
assert
(
fid
>
0
);
assert
(
isnumeric
(
texIndent
));
fprintf
(
fid
,
'%d\% Page Object\n'
,
texIndent
);
fprintf
(
fid
,
'%d\newpage\n'
,
texIndent
);
o
.
sections
.
write
(
fid
,
texIndent
+
2
);
fprintf
(
fid
,
'%d\% End Page Object\n'
,
texIndent
);
end
\ No newline at end of file
matlab/reports/@page/addSection.m
View file @
78f8f045
...
...
@@ -8,7 +8,7 @@ function p = addSection(p, varargin)
% 3 args => add section at index
%
% OUTPUTS
% updated
report
object
% updated
page
object
%
% SPECIAL REQUIREMENTS
% none
...
...
matlab/reports/@page/page.m
View file @
78f8f045
function
p
=
page
(
varargin
)
%function
p
= page(varargin)
function
o
=
page
(
varargin
)
%function
o
= page(varargin)
% Page Class Constructor
%
% INPUTS
...
...
@@ -29,17 +29,36 @@ function p = page(varargin)
% 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
();
o
=
struct
;
o
.
caption
=
''
;
o
.
orientation
=
'portrait'
;
o
.
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'
);
if
nargin
==
1
assert
(
isa
(
varargin
{
1
},
'page'
),[
'With one arg to Page constructor, '
...
'you must pass a page object'
]);
o
=
varargin
{
1
};
return
;
elseif
nargin
>
1
if
round
(
nargin
/
2
)
~=
nargin
/
2
error
([
'Options to Page constructor must be supplied in name/value '
...
'pairs.'
]);
end
optNames
=
lower
(
fieldnames
(
o
));
% overwrite default values
for
pair
=
reshape
(
varargin
,
2
,
[])
field
=
lower
(
pair
{
1
});
if
any
(
strmatch
(
field
,
optNames
,
'exact'
))
o
.
(
field
)
=
pair
{
2
};
else
error
(
'%s is not a recognized option to the Page constructor.'
,
...
field
);
end
end
end
% Create page object
o
=
class
(
o
,
'page'
);
end
end
\ No newline at end of file
matlab/reports/@page/subsref.m
View file @
78f8f045
...
...
@@ -23,6 +23,13 @@ switch S(1).type
switch
S
(
1
)
.
subs
case
fieldnames
(
A
)
A
=
A
.
(
S
(
1
)
.
subs
);
case
{
'write'
}
if
areParensNext
(
S
)
write
(
A
,
S
(
2
)
.
subs
{:})
S
=
shiftS
(
S
);
else
assert
(
false
);
end
case
methods
(
A
)
if
areParensNext
(
S
)
A
=
feval
(
S
(
1
)
.
subs
,
A
,
S
(
2
)
.
subs
{:});
...
...
matlab/reports/@page/write.m
0 → 100644
View file @
78f8f045
function
write
(
o
,
fid
,
indent
)
%function write(o, fid, indent)
% Write a Page object
%
% INPUTS
% fid - int, file id
% indent - char, number of spaces to indent tex code
%
% 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/>.
assert
(
fid
~=
-
1
);
fprintf
(
fid
,
'\n%s%% Page Object\n'
,
indent
);
if
strcmpi
(
o
.
orientation
,
'landscape'
)
fprintf
(
fid
,
'%s\\begin{landscape}\n'
,
indent
);