Merge branch 'master' into remove-dynDate-class
commit
8f3e10ea1b
|
@ -3774,7 +3774,7 @@ variables in declaration order.
|
||||||
|
|
||||||
Of course, the shown form of the approximation is only stylized, because it neglects the required different ordering in @math{y^s} and @math{y^h_t}. The precise form of the approximation that shows the way Dynare deals with differences between declaration and DR-order, is
|
Of course, the shown form of the approximation is only stylized, because it neglects the required different ordering in @math{y^s} and @math{y^h_t}. The precise form of the approximation that shows the way Dynare deals with differences between declaration and DR-order, is
|
||||||
|
|
||||||
@math{y_t(oo_.dr.order_var) = y^s(oo_.dr.order_var) + A (y_{t-1}(oo_.dr.order_var(k2))-y^s(oo_.dr.order_var(k2))) + B u_t}
|
@math{y_t(oo\_.dr.order\_var) = y^s(oo\_.dr.order\_var) + A \cdot y_{t-1}(oo\_.dr.order\_var(k2))-y^s(oo\_.dr.order\_var(k2)) + B\cdot u_t}
|
||||||
|
|
||||||
where @math{k2} selects the state variables, @math{y_t} and @math{y^s} are in declaration order and the coefficient matrices are in DR-order. Effectively, all variables on the right hand side are brought into DR order for computations and then assigned to @math{y_t} in declaration order.
|
where @math{k2} selects the state variables, @math{y_t} and @math{y^s} are in declaration order and the coefficient matrices are in DR-order. Effectively, all variables on the right hand side are brought into DR order for computations and then assigned to @math{y_t} in declaration order.
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "utils/cc/exception.h"
|
#include "utils/cc/exception.h"
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
using namespace ogp;
|
using namespace ogp;
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ for i=1:nargin-1
|
||||||
while ~isempty(expression)
|
while ~isempty(expression)
|
||||||
[token, expression] = strtok(expression,',');
|
[token, expression] = strtok(expression,',');
|
||||||
candidate = [VariableName(1:idArobase(1)-1), token, VariableName(idArobase(2)+1:end)];
|
candidate = [VariableName(1:idArobase(1)-1), token, VariableName(idArobase(2)+1:end)];
|
||||||
id = strmatch(candidate,B.name,'exact');
|
id = find(strcmp(candidate,B.name));
|
||||||
if isempty(id)
|
if isempty(id)
|
||||||
error(['dynSeries::extract: Variable ''' candidate ''' does not exist in dynSeries object ''' inputname(1) '''!'])
|
error(['dynSeries::extract: Variable ''' candidate ''' does not exist in dynSeries object ''' inputname(1) '''!'])
|
||||||
else
|
else
|
||||||
|
@ -88,7 +88,7 @@ for i=1:nargin-1
|
||||||
while ~isempty(expression_2)
|
while ~isempty(expression_2)
|
||||||
[token_2, expression_2] = strtok(expression_2,',');
|
[token_2, expression_2] = strtok(expression_2,',');
|
||||||
candidate = [VariableName(1:idArobase(1)-1), token_1, VariableName(idArobase(2)+1:idArobase(3)-1), token_2, VariableName(idArobase(4)+1:end)];
|
candidate = [VariableName(1:idArobase(1)-1), token_1, VariableName(idArobase(2)+1:idArobase(3)-1), token_2, VariableName(idArobase(4)+1:end)];
|
||||||
id = strmatch(candidate,B.name,'exact');
|
id = find(strcmp(candidate,B.name));
|
||||||
if isempty(id)
|
if isempty(id)
|
||||||
error(['dynSeries::extract: Variable ''' candidate ''' does not exist in dynSeries object ''' inputname(1) '''!'])
|
error(['dynSeries::extract: Variable ''' candidate ''' does not exist in dynSeries object ''' inputname(1) '''!'])
|
||||||
else
|
else
|
||||||
|
@ -114,7 +114,7 @@ end
|
||||||
% Get indices of the selected variables
|
% Get indices of the selected variables
|
||||||
idVariableName = NaN(length(VariableName_),1);
|
idVariableName = NaN(length(VariableName_),1);
|
||||||
for i = 1:length(idVariableName)
|
for i = 1:length(idVariableName)
|
||||||
idx = strmatch(VariableName_{i},B.name,'exact');
|
idx = find(strcmp(VariableName_{i},B.name));
|
||||||
if isempty(idx)
|
if isempty(idx)
|
||||||
error(['dynSeries::extract: Variable ' VariableName_{i} ' is not a member of ' inputname(1) '!'])
|
error(['dynSeries::extract: Variable ' VariableName_{i} ' is not a member of ' inputname(1) '!'])
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,7 +45,7 @@ function [ts,id] = pop(ts,a) % --*-- Unitary tests --*--
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
id = strmatch(a,ts.name,'exact');
|
id = find(strcmp(a,ts.name));
|
||||||
if isempty(id)
|
if isempty(id)
|
||||||
id = 0;
|
id = 0;
|
||||||
return
|
return
|
||||||
|
|
|
@ -21,7 +21,7 @@ if ~ischar(old) || ~ischar(new)
|
||||||
error(['dynSeries::rename: Input arguments ''' inputname(2) ''' and ''' inputname(3) ''' have to be strings!'])
|
error(['dynSeries::rename: Input arguments ''' inputname(2) ''' and ''' inputname(3) ''' have to be strings!'])
|
||||||
end
|
end
|
||||||
|
|
||||||
idname = strmatch(old,ts.name,'exact');
|
idname = find(strcmp(old,ts.name));
|
||||||
|
|
||||||
if isempty(idname)
|
if isempty(idname)
|
||||||
error(['dynSeries::rename: Variable ' old ' is unknown in dynSeries object ' inputname(1) '!'])
|
error(['dynSeries::rename: Variable ' old ' is unknown in dynSeries object ' inputname(1) '!'])
|
||||||
|
|
|
@ -84,7 +84,7 @@ switch length(S)
|
||||||
for i = 1:B.vobs
|
for i = 1:B.vobs
|
||||||
if ~isequal(S(1).subs{i},B.name{i})
|
if ~isequal(S(1).subs{i},B.name{i})
|
||||||
% Rename a variable.
|
% Rename a variable.
|
||||||
id = strmatch(S(1).subs{i},A.name);
|
id = find(strcmp(S(1).subs{i},A.name));
|
||||||
if isempty(id)
|
if isempty(id)
|
||||||
% Add a new variable a change its name.
|
% Add a new variable a change its name.
|
||||||
B.name(i) = {S(1).subs{i}};
|
B.name(i) = {S(1).subs{i}};
|
||||||
|
@ -118,7 +118,7 @@ switch length(S)
|
||||||
% Single variable selection.
|
% Single variable selection.
|
||||||
if ~isequal(S(1).subs,B.name{1})
|
if ~isequal(S(1).subs,B.name{1})
|
||||||
% Rename a variable.
|
% Rename a variable.
|
||||||
id = strmatch(S(1).subs,A.name);
|
id = find(strcmp(S(1).subs,A.name));
|
||||||
if isempty(id)
|
if isempty(id)
|
||||||
% Add a new variable a change its name.
|
% Add a new variable a change its name.
|
||||||
B.name(1) = {S(1).subs};
|
B.name(1) = {S(1).subs};
|
||||||
|
|
|
@ -154,7 +154,7 @@ switch S(1).type
|
||||||
B = feval(S(1).subs,A,S(2).subs{:});
|
B = feval(S(1).subs,A,S(2).subs{:});
|
||||||
S = shiftS(S);
|
S = shiftS(S);
|
||||||
otherwise % Extract a sub-object by selecting one variable.
|
otherwise % Extract a sub-object by selecting one variable.
|
||||||
ndx = strmatch(S(1).subs,A.name,'exact');
|
ndx = find(strcmp(S(1).subs,A.name));
|
||||||
if ~isempty(ndx)
|
if ~isempty(ndx)
|
||||||
B = dynSeries();
|
B = dynSeries();
|
||||||
B.data = A.data(:,ndx);
|
B.data = A.data(:,ndx);
|
||||||
|
|
|
@ -32,7 +32,7 @@ assert(ischar(newtex), 'dynSeries::tex_rename: the newtex name must be a string'
|
||||||
if nargin == 2
|
if nargin == 2
|
||||||
idname = 1;
|
idname = 1;
|
||||||
else
|
else
|
||||||
idname = strmatch(name, ts.name, 'exact');
|
idname = find(strcmp(name, ts.name));
|
||||||
if isempty(idname)
|
if isempty(idname)
|
||||||
error(['dynSeries::tex_rename: Variable ' name ' is unknown in dynSeries object ' inputname(1) '!'])
|
error(['dynSeries::tex_rename: Variable ' name ' is unknown in dynSeries object ' inputname(1) '!'])
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
function irf_shocks_indx=getIrfShocksIndx()
|
function irf_shocks_indx=getIrfShocksIndx()
|
||||||
|
% irf_shocks_indx=getIrfShocksIndx()
|
||||||
% Copyright (C) 2011 Dynare Team
|
% returns the unique indices of the exogenous shocks specified for IRF
|
||||||
|
% generation using the irf_shocks-command
|
||||||
|
%
|
||||||
|
% Inputs:
|
||||||
|
% none
|
||||||
|
% Outputs:
|
||||||
|
% irf_shocks_indx: [1 by n_irf_shocks] vector storing the indices
|
||||||
|
%
|
||||||
|
% Copyright (C) 2011-13 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
|
@ -26,4 +34,10 @@ else
|
||||||
for i=1:size(options_.irf_shocks,1)
|
for i=1:size(options_.irf_shocks,1)
|
||||||
irf_shocks_indx(i) = find(strcmp(deblank(options_.irf_shocks(i,:)), cellstr(M_.exo_names)));
|
irf_shocks_indx(i) = find(strcmp(deblank(options_.irf_shocks(i,:)), cellstr(M_.exo_names)));
|
||||||
end
|
end
|
||||||
|
irf_shocks_indx_unique=unique(irf_shocks_indx);
|
||||||
|
if options_.debug && (length(irf_shocks_indx_unique) ~= length(irf_shocks_indx))
|
||||||
|
fprintf('\nSTOCH_SIMUL: Warning: The IRFs for some shocks have been requested twice.\n')
|
||||||
|
fprintf('STOCH_SIMUL: The redundant entries will be ignored.\n')
|
||||||
|
end
|
||||||
|
irf_shocks_indx=irf_shocks_indx_unique;
|
||||||
end
|
end
|
||||||
|
|
|
@ -690,7 +690,7 @@ string eofbuff;
|
||||||
return token::INT_NUMBER;
|
return token::INT_NUMBER;
|
||||||
}
|
}
|
||||||
|
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>-?[0-9]+[Mm]([1-9]|1[0-2])|-?[0-9]+[Qq][1-4]|-?[0-9]+[Ww]([1-9]{1}|[1-4][0-9]|5[0-2]) {
|
<DYNARE_STATEMENT,DYNARE_BLOCK>-?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2])) {
|
||||||
yylval->string_val = new string(yytext);
|
yylval->string_val = new string(yytext);
|
||||||
return token::DATE_NUMBER;
|
return token::DATE_NUMBER;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2449,8 +2449,7 @@ ParsingDriver::add_model_var_or_external_function(string *function_name, bool in
|
||||||
void
|
void
|
||||||
ParsingDriver::add_native(const string &s)
|
ParsingDriver::add_native(const string &s)
|
||||||
{
|
{
|
||||||
string ss = string(s);
|
mod_file->addStatement(new NativeStatement(s));
|
||||||
mod_file->addStatement(new NativeStatement(ss));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Statement.hh"
|
#include "Statement.hh"
|
||||||
#include <boost/xpressive/xpressive.hpp>
|
|
||||||
|
|
||||||
ModFileStructure::ModFileStructure() :
|
ModFileStructure::ModFileStructure() :
|
||||||
check_present(false),
|
check_present(false),
|
||||||
|
@ -66,76 +65,11 @@ Statement::computingPass()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeStatement::NativeStatement(string &native_statement_arg) :
|
NativeStatement::NativeStatement(const string &native_statement_arg) :
|
||||||
native_statement(native_statement_arg)
|
native_statement(native_statement_arg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
NativeStatement::computingPass()
|
|
||||||
{
|
|
||||||
using namespace boost::xpressive;
|
|
||||||
// Return if this is a comment
|
|
||||||
sregex comment_expr = sregex::compile( "\\s*\%.*" );
|
|
||||||
match_results<string::const_iterator> results;
|
|
||||||
if (regex_match(native_statement, results, comment_expr))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Otherwise, look at the line and consider substituting date
|
|
||||||
size_t idx = -1;
|
|
||||||
vector<size_t> apostrophes;
|
|
||||||
while((idx = native_statement.find("'", idx + 1)) != string::npos)
|
|
||||||
if (apostrophes.size() < 2)
|
|
||||||
apostrophes.push_back(idx);
|
|
||||||
else
|
|
||||||
if (idx == apostrophes.back() + 1)
|
|
||||||
apostrophes.pop_back();
|
|
||||||
else
|
|
||||||
apostrophes.push_back(idx);
|
|
||||||
|
|
||||||
bool skip = false;
|
|
||||||
string newstr = "";
|
|
||||||
sregex date_expr = sregex::compile( "-?[0-9]+[Mm](1[0-2]|[1-9])|-?[0-9]+[Qq][1-4]|-?[0-9]+[Ww]([1-4][0-9]|5[0-2]|[1-9])" );
|
|
||||||
string format( "dynDate('$&')" );
|
|
||||||
size_t lastidx = 0;
|
|
||||||
for (size_t i = 0; i < apostrophes.size(); i++)
|
|
||||||
if (apostrophes[i] == 0)
|
|
||||||
skip = true;
|
|
||||||
else
|
|
||||||
if (skip)
|
|
||||||
{
|
|
||||||
newstr.append(native_statement.substr(lastidx, apostrophes[i] - lastidx));
|
|
||||||
lastidx = apostrophes[i];
|
|
||||||
skip = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
newstr.append(regex_replace(native_statement.substr(lastidx, apostrophes[i] - lastidx),
|
|
||||||
date_expr, format));
|
|
||||||
lastidx = apostrophes[i];
|
|
||||||
skip = true;
|
|
||||||
}
|
|
||||||
size_t length = native_statement.length() - lastidx;
|
|
||||||
size_t commentidx = native_statement.substr(lastidx, length).find("%", 0);
|
|
||||||
if (commentidx != string::npos)
|
|
||||||
length = commentidx;
|
|
||||||
|
|
||||||
newstr.append(regex_replace(native_statement.substr(lastidx, length), date_expr, format));
|
|
||||||
|
|
||||||
if (commentidx != string::npos)
|
|
||||||
{
|
|
||||||
lastidx += commentidx;
|
|
||||||
newstr.append(native_statement.substr(lastidx, native_statement.length() - lastidx));
|
|
||||||
}
|
|
||||||
|
|
||||||
native_statement = newstr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
regexReplace()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NativeStatement::writeOutput(ostream &output, const string &basename) const
|
NativeStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -121,12 +121,10 @@ public:
|
||||||
class NativeStatement : public Statement
|
class NativeStatement : public Statement
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
string native_statement;
|
const string native_statement;
|
||||||
public:
|
public:
|
||||||
NativeStatement(string &native_statement_arg);
|
NativeStatement(const string &native_statement_arg);
|
||||||
virtual void computingPass();
|
|
||||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
void regexReplace();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class OptionsList
|
class OptionsList
|
||||||
|
|
Loading…
Reference in New Issue