preprocessor: add option to write equation tags in latex output. closes #477
parent
052d62e150
commit
14f4544a29
|
@ -2097,6 +2097,7 @@ Compiling the @TeX{} file requires the following @LaTeX{} packages:
|
||||||
@anchor{write_latex_dynamic_model}
|
@anchor{write_latex_dynamic_model}
|
||||||
|
|
||||||
@deffn Command write_latex_dynamic_model ;
|
@deffn Command write_latex_dynamic_model ;
|
||||||
|
@deffnx Command write_latex_dynamic_model (@var{OPTIONS}) ;
|
||||||
|
|
||||||
@descriptionhead
|
@descriptionhead
|
||||||
|
|
||||||
|
@ -2143,6 +2144,15 @@ also have been replaced by new auxiliary variables and equations.
|
||||||
|
|
||||||
For the required @LaTeX{} packages, @pxref{write_latex_original_model}.
|
For the required @LaTeX{} packages, @pxref{write_latex_original_model}.
|
||||||
|
|
||||||
|
@optionshead
|
||||||
|
|
||||||
|
@table @code
|
||||||
|
|
||||||
|
@item write_equation_tags
|
||||||
|
Write the equation tags in the latex output
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn Command write_latex_static_model ;
|
@deffn Command write_latex_static_model ;
|
||||||
|
|
|
@ -1617,15 +1617,16 @@ IdentificationStatement::writeOutput(ostream &output, const string &basename, bo
|
||||||
output << "dynare_identification(options_ident);" << endl;
|
output << "dynare_identification(options_ident);" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteLatexDynamicModelStatement::WriteLatexDynamicModelStatement(const DynamicModel &dynamic_model_arg) :
|
WriteLatexDynamicModelStatement::WriteLatexDynamicModelStatement(const DynamicModel &dynamic_model_arg, bool write_equation_tags_arg) :
|
||||||
dynamic_model(dynamic_model_arg)
|
dynamic_model(dynamic_model_arg),
|
||||||
|
write_equation_tags(write_equation_tags_arg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WriteLatexDynamicModelStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
WriteLatexDynamicModelStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
||||||
{
|
{
|
||||||
dynamic_model.writeLatexFile(basename);
|
dynamic_model.writeLatexFile(basename, write_equation_tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteLatexStaticModelStatement::WriteLatexStaticModelStatement(const StaticModel &static_model_arg) :
|
WriteLatexStaticModelStatement::WriteLatexStaticModelStatement(const StaticModel &static_model_arg) :
|
||||||
|
|
|
@ -552,8 +552,9 @@ class WriteLatexDynamicModelStatement : public Statement
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const DynamicModel &dynamic_model;
|
const DynamicModel &dynamic_model;
|
||||||
|
const bool write_equation_tags;
|
||||||
public:
|
public:
|
||||||
WriteLatexDynamicModelStatement(const DynamicModel &dynamic_model_arg);
|
WriteLatexDynamicModelStatement(const DynamicModel &dynamic_model_arg, bool write_equation_tags_arg);
|
||||||
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4378,9 +4378,9 @@ DynamicModel::writeChainRuleDerivative(ostream &output, int eqr, int varr, int l
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicModel::writeLatexFile(const string &basename) const
|
DynamicModel::writeLatexFile(const string &basename, const bool write_equation_tags) const
|
||||||
{
|
{
|
||||||
writeLatexModelFile(basename + "_dynamic", oLatexDynamicModel);
|
writeLatexModelFile(basename + "_dynamic", oLatexDynamicModel, write_equation_tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2003-2016 Dynare Team
|
* Copyright (C) 2003-2017 Dynare Team
|
||||||
*
|
*
|
||||||
* This file is part of Dynare.
|
* This file is part of Dynare.
|
||||||
*
|
*
|
||||||
|
@ -278,7 +278,7 @@ public:
|
||||||
size_t dynamicOnlyEquationsNbr() const;
|
size_t dynamicOnlyEquationsNbr() const;
|
||||||
|
|
||||||
//! Writes LaTeX file with the equations of the dynamic model
|
//! Writes LaTeX file with the equations of the dynamic model
|
||||||
void writeLatexFile(const string &basename) const;
|
void writeLatexFile(const string &basename, const bool write_equation_tags) const;
|
||||||
|
|
||||||
//! Writes LaTeX file with the equations of the dynamic model (for the original model)
|
//! Writes LaTeX file with the equations of the dynamic model (for the original model)
|
||||||
void writeLatexOriginalFile(const string &basename) const;
|
void writeLatexOriginalFile(const string &basename) const;
|
||||||
|
|
|
@ -110,7 +110,7 @@ class ParsingDriver;
|
||||||
%token MODE_CHECK MODE_CHECK_NEIGHBOURHOOD_SIZE MODE_CHECK_SYMMETRIC_PLOTS MODE_CHECK_NUMBER_OF_POINTS MODE_COMPUTE MODE_FILE MODEL MODEL_COMPARISON MODEL_INFO MSHOCKS ABS SIGN
|
%token MODE_CHECK MODE_CHECK_NEIGHBOURHOOD_SIZE MODE_CHECK_SYMMETRIC_PLOTS MODE_CHECK_NUMBER_OF_POINTS MODE_COMPUTE MODE_FILE MODEL MODEL_COMPARISON MODEL_INFO MSHOCKS ABS SIGN
|
||||||
%token MODEL_DIAGNOSTICS MODIFIEDHARMONICMEAN MOMENTS_VARENDO CONTEMPORANEOUS_CORRELATION DIFFUSE_FILTER SUB_DRAWS TAPER_STEPS GEWEKE_INTERVAL RAFTERY_LEWIS_QRS RAFTERY_LEWIS_DIAGNOSTICS MCMC_JUMPING_COVARIANCE MOMENT_CALIBRATION
|
%token MODEL_DIAGNOSTICS MODIFIEDHARMONICMEAN MOMENTS_VARENDO CONTEMPORANEOUS_CORRELATION DIFFUSE_FILTER SUB_DRAWS TAPER_STEPS GEWEKE_INTERVAL RAFTERY_LEWIS_QRS RAFTERY_LEWIS_DIAGNOSTICS MCMC_JUMPING_COVARIANCE MOMENT_CALIBRATION
|
||||||
%token NUMBER_OF_PARTICLES RESAMPLING SYSTEMATIC GENERIC RESAMPLING_THRESHOLD RESAMPLING_METHOD KITAGAWA STRATIFIED SMOOTH
|
%token NUMBER_OF_PARTICLES RESAMPLING SYSTEMATIC GENERIC RESAMPLING_THRESHOLD RESAMPLING_METHOD KITAGAWA STRATIFIED SMOOTH
|
||||||
%token CPF_WEIGHTS AMISANOTRISTANI MURRAYJONESPARSLOW
|
%token CPF_WEIGHTS AMISANOTRISTANI MURRAYJONESPARSLOW WRITE_EQUATION_TAGS
|
||||||
%token NONLINEAR_FILTER_INITIALIZATION FILTER_ALGORITHM PROPOSAL_APPROXIMATION CUBATURE UNSCENTED MONTECARLO DISTRIBUTION_APPROXIMATION
|
%token NONLINEAR_FILTER_INITIALIZATION FILTER_ALGORITHM PROPOSAL_APPROXIMATION CUBATURE UNSCENTED MONTECARLO DISTRIBUTION_APPROXIMATION
|
||||||
%token <string_val> NAME
|
%token <string_val> NAME
|
||||||
%token USE_PENALIZED_OBJECTIVE_FOR_HESSIAN INIT_STATE
|
%token USE_PENALIZED_OBJECTIVE_FOR_HESSIAN INIT_STATE
|
||||||
|
@ -2111,7 +2111,9 @@ ramsey_policy_options : stoch_simul_primary_options
|
||||||
;
|
;
|
||||||
|
|
||||||
write_latex_dynamic_model : WRITE_LATEX_DYNAMIC_MODEL ';'
|
write_latex_dynamic_model : WRITE_LATEX_DYNAMIC_MODEL ';'
|
||||||
{ driver.write_latex_dynamic_model(); }
|
{ driver.write_latex_dynamic_model(false); }
|
||||||
|
| WRITE_LATEX_DYNAMIC_MODEL '(' WRITE_EQUATION_TAGS ')' ';'
|
||||||
|
{ driver.write_latex_dynamic_model(true); }
|
||||||
;
|
;
|
||||||
|
|
||||||
write_latex_static_model : WRITE_LATEX_STATIC_MODEL ';'
|
write_latex_static_model : WRITE_LATEX_STATIC_MODEL ';'
|
||||||
|
|
|
@ -465,6 +465,7 @@ DATE -?[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::ABAND;
|
return token::ABAND;
|
||||||
}
|
}
|
||||||
|
<DYNARE_STATEMENT>write_equation_tags {return token::WRITE_EQUATION_TAGS;}
|
||||||
<DYNARE_STATEMENT>indxap {return token::INDXAP;}
|
<DYNARE_STATEMENT>indxap {return token::INDXAP;}
|
||||||
<DYNARE_STATEMENT>apband {return token::APBAND;}
|
<DYNARE_STATEMENT>apband {return token::APBAND;}
|
||||||
<DYNARE_STATEMENT>indximf {return token::INDXIMF;}
|
<DYNARE_STATEMENT>indximf {return token::INDXIMF;}
|
||||||
|
|
|
@ -1529,7 +1529,7 @@ ModelTree::Write_Inf_To_Bin_File(const string &basename,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output_type) const
|
ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output_type, const bool write_equation_tags) const
|
||||||
{
|
{
|
||||||
ofstream output, content_output;
|
ofstream output, content_output;
|
||||||
string filename = basename + ".tex";
|
string filename = basename + ".tex";
|
||||||
|
@ -1575,6 +1575,17 @@ ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output
|
||||||
{
|
{
|
||||||
content_output << "\\begin{dmath}" << endl
|
content_output << "\\begin{dmath}" << endl
|
||||||
<< "% Equation " << eq+1 << endl;
|
<< "% Equation " << eq+1 << endl;
|
||||||
|
if (write_equation_tags)
|
||||||
|
for (vector<pair<int,pair<string,string> > >::const_iterator iteqt = equation_tags.begin();
|
||||||
|
iteqt != equation_tags.end(); iteqt++)
|
||||||
|
if (iteqt->first == eq)
|
||||||
|
{
|
||||||
|
content_output << "[\\textrm{" << iteqt->second.first << "}";
|
||||||
|
if (!empty(iteqt->second.second))
|
||||||
|
content_output << " = \\textrm{``" << iteqt->second.second << "''}";
|
||||||
|
content_output << "]";
|
||||||
|
}
|
||||||
|
|
||||||
// Here it is necessary to cast to superclass ExprNode, otherwise the overloaded writeOutput() method is not found
|
// Here it is necessary to cast to superclass ExprNode, otherwise the overloaded writeOutput() method is not found
|
||||||
dynamic_cast<ExprNode *>(equations[eq])->writeOutput(content_output, output_type);
|
dynamic_cast<ExprNode *>(equations[eq])->writeOutput(content_output, output_type);
|
||||||
content_output << endl << "\\end{dmath}" << endl;
|
content_output << endl << "\\end{dmath}" << endl;
|
||||||
|
|
|
@ -196,7 +196,7 @@ protected:
|
||||||
void compileModelEquations(ostream &code_file, unsigned int &instruction_number, const temporary_terms_t &tt, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const;
|
void compileModelEquations(ostream &code_file, unsigned int &instruction_number, const temporary_terms_t &tt, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const;
|
||||||
|
|
||||||
//! Writes LaTeX model file
|
//! Writes LaTeX model file
|
||||||
void writeLatexModelFile(const string &basename, ExprNodeOutputType output_type) const;
|
void writeLatexModelFile(const string &basename, ExprNodeOutputType output_type, const bool write_equation_tags = false) const;
|
||||||
|
|
||||||
//! Sparse matrix of double to store the values of the Jacobian
|
//! Sparse matrix of double to store the values of the Jacobian
|
||||||
/*! First index is equation number, second index is endogenous type specific ID */
|
/*! First index is equation number, second index is endogenous type specific ID */
|
||||||
|
|
|
@ -1963,9 +1963,9 @@ ParsingDriver::discretionary_policy()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::write_latex_dynamic_model()
|
ParsingDriver::write_latex_dynamic_model(bool write_equation_tags)
|
||||||
{
|
{
|
||||||
mod_file->addStatement(new WriteLatexDynamicModelStatement(mod_file->dynamic_model));
|
mod_file->addStatement(new WriteLatexDynamicModelStatement(mod_file->dynamic_model, write_equation_tags));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -559,7 +559,7 @@ public:
|
||||||
//! Discretionary policy statement
|
//! Discretionary policy statement
|
||||||
void discretionary_policy();
|
void discretionary_policy();
|
||||||
//! Adds a write_latex_dynamic_model statement
|
//! Adds a write_latex_dynamic_model statement
|
||||||
void write_latex_dynamic_model();
|
void write_latex_dynamic_model(bool write_equation_tags);
|
||||||
//! Adds a write_latex_static_model statement
|
//! Adds a write_latex_static_model statement
|
||||||
void write_latex_static_model();
|
void write_latex_static_model();
|
||||||
//! Adds a write_latex_original_model statement
|
//! Adds a write_latex_original_model statement
|
||||||
|
|
Loading…
Reference in New Issue