diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc index 7950c410eb49b2b8bade579047f57b9010a3dce7..1839f07ad004e475d5391e5937b0f002d58f2172 100644 --- a/preprocessor/ComputingTasks.cc +++ b/preprocessor/ComputingTasks.cc @@ -1705,11 +1705,13 @@ SubsamplesStatement::writeOutput(ostream &output, const string &basename) const SubsamplesEqualStatement::SubsamplesEqualStatement(const string &to_name1_arg, const string &to_name2_arg, const string &from_name1_arg, - const string &from_name2_arg) : + const string &from_name2_arg, + const SymbolTable &symbol_table_arg) : to_name1(to_name1_arg), to_name2(to_name2_arg), from_name1(from_name1_arg), - from_name2(from_name2_arg) + from_name2(from_name2_arg), + symbol_table(symbol_table_arg) { } @@ -1726,6 +1728,40 @@ SubsamplesEqualStatement::writeOutput(ostream &output, const string &basename) c << endl << "estimation_info.subsamples(subsamples_to_indx) = estimation_info.subsamples(subsamples_from_indx);" << endl; + + // Initialize associated subsample substructures in estimation_info + const SymbolType symb_type = symbol_table.getType(to_name1); + string lhs_field; + if (symb_type == eParameter) + lhs_field = "parameter"; + else if (symb_type == eExogenous || symb_type == eExogenousDet) + lhs_field = "structural_innovation"; + else + lhs_field = "measurement_error"; + + output << "eifind = get_new_or_existing_ei_index('" << lhs_field; + + if (!to_name2.empty()) + output << "_corr"; + output << "_prior_index', '" + << to_name1 << "', '"; + if (!to_name2.empty()) + output << to_name2; + output << "');" << endl; + + lhs_field = "estimation_info." + lhs_field; + if (!to_name2.empty()) + lhs_field += "_corr"; + output << lhs_field << "_prior_index(eifind) = {'" << to_name1; + if (!to_name2.empty()) + output << ":" << to_name2; + output << "'};" << endl; + + output << lhs_field << "(eifind).subsample_prior = estimation_info.empty_prior;" << endl + << lhs_field << "(eifind).subsample_prior(1:size(estimation_info.subsamples(subsamples_to_indx).range_index,2)) = estimation_info.empty_prior;" + << endl + << lhs_field << "(eifind).range_index = estimation_info.subsamples(subsamples_to_indx).range_index;" + << endl; } BasicPriorStatement::~BasicPriorStatement() @@ -1836,7 +1872,6 @@ BasicPriorStatement::writePriorOutput(ostream &output, string &lhs_field) const else { output << "subsamples_indx = get_existing_subsamples_indx('" << name << "','');" << endl - << lhs_field << ".range_index = estimation_info.subsamples(subsamples_indx).range_index;" << endl << "eisind = get_subsamples_range_indx(subsamples_indx, '" << subsample_name << "');" << endl; lhs_field += ".subsample_prior(eisind)"; } @@ -2013,7 +2048,6 @@ PriorEqualStatement::writeOutput(ostream &output, const string &basename) const else { output << "subsamples_to_indx = get_existing_subsamples_indx('" << to_name1 << "','" << to_name2 << "');" << endl - << lhs_field << ".range_index = estimation_info.subsamples(subsamples_to_indx).range_index;" << endl << "ei_to_ss_ind = get_subsamples_range_indx(subsamples_to_indx, '" << to_subsample_name << "');" << endl; lhs_field += ".subsample_prior(ei_to_ss_ind)"; } @@ -2085,7 +2119,6 @@ BasicOptionsStatement::writeOptionsOutput(ostream &output, string &lhs_field, co else { output << "subsamples_indx = get_existing_subsamples_indx('" << name << "','" << name2 << "');" << endl - << lhs_field << ".range_index = estimation_info.subsamples(subsamples_indx).range_index;" << endl << "eisind = get_subsamples_range_indx(subsamples_indx, '" << subsample_name << "');" << endl; lhs_field += ".subsample_options(eisind)"; } @@ -2255,7 +2288,6 @@ OptionsEqualStatement::writeOutput(ostream &output, const string &basename) cons else { output << "subsamples_to_indx = get_existing_subsamples_indx('" << to_name1 << "','" << to_name2 << "');" << endl - << lhs_field << ".range_index = estimation_info.subsamples(subsamples_to_indx).range_index;" << endl << "ei_to_ss_ind = get_subsamples_range_indx(subsamples_to_indx, '" << to_subsample_name << "');" << endl; lhs_field += ".subsample_options(ei_to_ss_ind)"; } diff --git a/preprocessor/ComputingTasks.hh b/preprocessor/ComputingTasks.hh index f3cfeb07cfe6517ea871e304e407dba6ffa674f6..3d7f5ad997902e48f77c374d64256d5bfb3fd990 100644 --- a/preprocessor/ComputingTasks.hh +++ b/preprocessor/ComputingTasks.hh @@ -605,11 +605,13 @@ private: const string to_name2; const string from_name1; const string from_name2; + const SymbolTable symbol_table; public: SubsamplesEqualStatement(const string &to_name1_arg, const string &to_name2_arg, const string &from_name1_arg, - const string &from_name2_arg); + const string &from_name2_arg, + const SymbolTable &symbol_table_arg); virtual void writeOutput(ostream &output, const string &basename) const; }; diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc index 4adbfdef822e1f43b3073d8d0791d47af63e4ffb..e956a68ab443687ad74bd7d7a368fd62216e8154 100644 --- a/preprocessor/ParsingDriver.cc +++ b/preprocessor/ParsingDriver.cc @@ -1242,7 +1242,8 @@ ParsingDriver::set_subsamples(string *name1, string *name2) if (!name2->empty()) check_symbol_existence(*name2); - mod_file->addStatement(new SubsamplesStatement(*name1, *name2, subsample_declaration_map, mod_file->symbol_table)); + mod_file->addStatement(new SubsamplesStatement(*name1, *name2, subsample_declaration_map, + mod_file->symbol_table)); subsample_declarations[make_pair(*name1, *name2)] = subsample_declaration_map; subsample_declaration_map.clear(); delete name1; @@ -1267,7 +1268,8 @@ ParsingDriver::copy_subsamples(string *to_name1, string *to_name2, string *from_ error(err + " does not have an associated subsample statement."); } - mod_file->addStatement(new SubsamplesEqualStatement(*to_name1, *to_name2, *from_name1, *from_name2)); + mod_file->addStatement(new SubsamplesEqualStatement(*to_name1, *to_name2, *from_name1, *from_name2, + mod_file->symbol_table)); subsample_declarations[make_pair(*to_name1, *to_name2)] = subsample_declarations[make_pair(*from_name1, *from_name2)];