Skip to content

Commit

Permalink
fixed int compare error
Browse files Browse the repository at this point in the history
  • Loading branch information
msupernaw committed Nov 18, 2024
1 parent ba55ce3 commit 62b9c9b
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 68 deletions.
6 changes: 3 additions & 3 deletions inst/include/interface/rcpp/rcpp_objects/rcpp_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class AgeCompDataInterface : public DataInterfaceBase {
ss << " \"rank\": " << 2 << ",\n";
ss << " \"dimensions\": [" << this->ymax << "," << this->amax << "],\n";
ss << " \"values\": [";
for (size_t i = 0; i < age_comp_data.size() - 1; i++) {
for (R_xlen_t i = 0; i < age_comp_data.size() - 1; i++) {
ss << age_comp_data[i] << ", ";
}
ss << age_comp_data[age_comp_data.size() - 1] << "]\n";
Expand Down Expand Up @@ -183,7 +183,7 @@ class LengthCompDataInterface : public DataInterfaceBase {
ss << " \"rank\": " << 2 << ",\n";
ss << " \"dimensions\": [" << this->ymax << "," << this->lmax << "],\n";
ss << " \"values\": [";
for (size_t i = 0; i < length_comp_data.size() - 1; i++) {
for (R_xlen_t i = 0; i < length_comp_data.size() - 1; i++) {
ss << length_comp_data[i] << ", ";
}
ss << length_comp_data[length_comp_data.size() - 1] << "]\n";
Expand Down Expand Up @@ -268,7 +268,7 @@ class IndexDataInterface : public DataInterfaceBase {
ss << " \"rank\": " << 1 << ",\n";
ss << " \"dimensions\": [" << this->ymax << "],\n";
ss << " \"values\": [";
for (size_t i = 0; i < index_data.size() - 1; i++) {
for (R_xlen_t i = 0; i < index_data.size() - 1; i++) {
ss << index_data[i] << ", ";
}
ss << index_data[index_data.size() - 1] << "]\n";
Expand Down
34 changes: 17 additions & 17 deletions inst/include/interface/rcpp/rcpp_objects/rcpp_fleet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ class FleetInterface : public FleetInterfaceBase {
std::dynamic_pointer_cast<fims_popdy::Fleet<double> >(it->second);


for (size_t i = 0; i < this->log_Fmort.size(); i++) {
for (R_xlen_t i = 0; i < this->log_Fmort.size(); i++) {
if (this->log_Fmort[i].estimated_m) {
this->log_Fmort[i].final_value_m = fleet->log_Fmort[i];
} else {
this->log_Fmort[i].final_value_m = this->log_Fmort[i].initial_value_m;
}
}

for (size_t i = 0; i < this->log_q.size(); i++) {
for (R_xlen_t i = 0; i < this->log_q.size(); i++) {
if (this->log_q[i].estimated_m) {
this->log_q[i].final_value_m = fleet->log_q[i];
} else {
Expand All @@ -198,32 +198,32 @@ class FleetInterface : public FleetInterfaceBase {
}

this->derived_cnaa = Rcpp::NumericVector(fleet->catch_numbers_at_age.size());
for (size_t i = 0; i < this->derived_cnaa.size(); i++) {
for (R_xlen_t i = 0; i < this->derived_cnaa.size(); i++) {
this->derived_cnaa[i] = fleet->catch_numbers_at_age[i];
}

this->derived_cnal = Rcpp::NumericVector(fleet->catch_numbers_at_length.size());
for (size_t i = 0; i < this->derived_cnal.size(); i++) {
for (R_xlen_t i = 0; i < this->derived_cnal.size(); i++) {
this->derived_cnal[i] = fleet->catch_numbers_at_length[i];
}

this->derived_cwaa = Rcpp::NumericVector(fleet->catch_weight_at_age.size());
for (size_t i = 0; i < this->derived_cwaa.size(); i++) {
for (R_xlen_t i = 0; i < this->derived_cwaa.size(); i++) {
this->derived_cwaa[i] = fleet->catch_weight_at_age[i];
}

this->derived_age_composition = Rcpp::NumericVector(fleet->proportion_catch_numbers_at_age.size());
for (size_t i = 0; i < this->derived_age_composition.size(); i++) {
for (R_xlen_t i = 0; i < this->derived_age_composition.size(); i++) {
this->derived_age_composition[i] = fleet->proportion_catch_numbers_at_age[i];
}

this->derived_length_composition = Rcpp::NumericVector(fleet->proportion_catch_numbers_at_length.size());
for (size_t i = 0; i < this->derived_length_composition.size(); i++) {
for (R_xlen_t i = 0; i < this->derived_length_composition.size(); i++) {
this->derived_length_composition[i] = fleet->proportion_catch_numbers_at_length[i];
}

this->derived_index = Rcpp::NumericVector(fleet->expected_index.size());
for (size_t i = 0; i < this->derived_index.size(); i++) {
for (R_xlen_t i = 0; i < this->derived_index.size(); i++) {
this->derived_index[i] = fleet->expected_index[i];
}

Expand Down Expand Up @@ -263,7 +263,7 @@ class FleetInterface : public FleetInterfaceBase {
if (this->derived_cnaa.size() == 0) {
ss << "]\n";
} else {
for (size_t i = 0; i < this->derived_cnaa.size() - 1; i++) {
for (R_xlen_t i = 0; i < this->derived_cnaa.size() - 1; i++) {
ss << this->derived_cnaa[i] << ", ";
}
ss << this->derived_cnaa[this->derived_cnaa.size() - 1] << "]\n";
Expand All @@ -276,7 +276,7 @@ class FleetInterface : public FleetInterfaceBase {
if (this->derived_cnal.size() == 0) {
ss << "]\n";
} else {
for (size_t i = 0; i < this->derived_cnal.size() - 1; i++) {
for (R_xlen_t i = 0; i < this->derived_cnal.size() - 1; i++) {
ss << this->derived_cnal[i] << ", ";
}
ss << this->derived_cnal[this->derived_cnal.size() - 1] << "]\n";
Expand All @@ -289,7 +289,7 @@ class FleetInterface : public FleetInterfaceBase {
if (this->derived_cwaa.size() == 0) {
ss << "]\n";
} else {
for (size_t i = 0; i < this->derived_cwaa.size() - 1; i++) {
for (R_xlen_t i = 0; i < this->derived_cwaa.size() - 1; i++) {
ss << this->derived_cwaa[i] << ", ";
}
ss << this->derived_cwaa[this->derived_cwaa.size() - 1] << "]\n";
Expand All @@ -303,7 +303,7 @@ class FleetInterface : public FleetInterfaceBase {
if (this->derived_age_composition.size() == 0) {
ss << "]\n";
} else {
for (size_t i = 0; i < this->derived_age_composition.size() - 1; i++) {
for (R_xlen_t i = 0; i < this->derived_age_composition.size() - 1; i++) {
ss << this->derived_age_composition[i] << ", ";
}
ss << this->derived_age_composition[this->derived_age_composition.size() - 1] << "]\n";
Expand All @@ -316,7 +316,7 @@ class FleetInterface : public FleetInterfaceBase {
if (this->derived_length_composition.size() == 0) {
ss << "]\n";
} else {
for (size_t i = 0; i < this->derived_length_composition.size() - 1; i++) {
for (R_xlen_t i = 0; i < this->derived_length_composition.size() - 1; i++) {
ss << this->derived_length_composition[i] << ", ";
}
ss << this->derived_length_composition[this->derived_length_composition.size() - 1] << "]\n";
Expand All @@ -329,7 +329,7 @@ class FleetInterface : public FleetInterfaceBase {
if (this->derived_index.size() == 0) {
ss << "]\n";
} else {
for (size_t i = 0; i < this->derived_index.size() - 1; i++) {
for (R_xlen_t i = 0; i < this->derived_index.size() - 1; i++) {
ss << this->derived_index[i] << ", ";
}
ss << this->derived_index[this->derived_index.size() - 1] << "]\n";
Expand Down Expand Up @@ -366,7 +366,7 @@ class FleetInterface : public FleetInterfaceBase {
fleet->fleet_selectivity_id_m = interface_selectivity_id_m;

fleet->log_q.resize(this->log_q.size());
for (size_t i = 0; i < this->log_q.size(); i++) {
for (R_xlen_t i = 0; i < this->log_q.size(); i++) {
fleet->log_q[i] = this->log_q[i].initial_value_m;

if (this->log_q[i].estimated_m) {
Expand All @@ -381,7 +381,7 @@ class FleetInterface : public FleetInterfaceBase {


fleet->log_Fmort.resize(this->log_Fmort.size());
for (size_t i = 0; i < log_Fmort.size(); i++) {
for (R_xlen_t i = 0; i < log_Fmort.size(); i++) {
fleet->log_Fmort[i] = this->log_Fmort[i].initial_value_m;

if (this->log_Fmort[i].estimated_m) {
Expand All @@ -404,7 +404,7 @@ class FleetInterface : public FleetInterfaceBase {
if(this->nlengths > 0){
fleet->proportion_catch_numbers_at_length.resize(nyears * nlengths);
fleet->age_length_conversion_matrix.resize(nages * nlengths);
for (size_t i = 0; i < fleet->age_length_conversion_matrix.size(); i++){
for (R_xlen_t i = 0; i < fleet->age_length_conversion_matrix.size(); i++){
fleet->age_length_conversion_matrix[i] = this->age_length_conversion_matrix[i].initial_value_m;

if (this->age_length_conversion_matrix[i].estimated_m) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ class ParameterVector{
* @param pos return a Parameter at position "pos".
*/
SEXP at(R_xlen_t pos){
if (pos == 0 || pos > this->storage_m->size()) {
if (static_cast<size_t>(pos) == 0 ||
static_cast<size_t>(pos) > this->storage_m->size()) {
Rcpp::Rcout << "ParameterVector: Index out of range.\n";
FIMS_ERROR_LOG(fims::to_string(pos) + "!<" + fims::to_string(this->size()));
return NULL;
Expand Down
36 changes: 18 additions & 18 deletions inst/include/interface/rcpp/rcpp_objects/rcpp_population.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,17 @@ class PopulationInterface : public PopulationInterfaceBase {


this->estimated_log_M = Rcpp::NumericVector(this->log_M.size());
for (size_t i = 0; i < this->log_M.size(); i++) {
for (R_xlen_t i = 0; i < this->log_M.size(); i++) {
this->estimated_log_M[i] = this->log_M[i].initial_value_m;
}

this->estimated_log_init_naa = Rcpp::NumericVector(this->log_init_naa.size());
for (size_t i = 0; i < this->log_init_naa.size(); i++) {
for (R_xlen_t i = 0; i < this->log_init_naa.size(); i++) {
this->estimated_log_init_naa[i] = this->log_init_naa[i].initial_value_m;
}

this->estimated_proportion_female = Rcpp::NumericVector(this->proportion_female.size());
for (size_t i = 0; i < this->proportion_female.size(); i++) {
for (R_xlen_t i = 0; i < this->proportion_female.size(); i++) {
this->estimated_proportion_female[i] = this->proportion_female[i];
}

Expand All @@ -163,19 +163,19 @@ class PopulationInterface : public PopulationInterfaceBase {
} else {

if (this->estimated_log_M) {
for (size_t i = 0; i < this->log_M.size(); i++) {
for (R_xlen_t i = 0; i < this->log_M.size(); i++) {
this->estimated_log_M[i] = pop->log_M[i];
}
}

if (this->estimated_log_init_naa) {
for (size_t i = 0; i < this->log_init_naa.size(); i++) {
for (R_xlen_t i = 0; i < this->log_init_naa.size(); i++) {
this->estimated_log_init_naa[i] = pop->log_init_naa[i];
}
}

if (this->estimate_prop_female) {
for (size_t i = 0; i < this->proportion_female.size(); i++) {
for (R_xlen_t i = 0; i < this->proportion_female.size(); i++) {
this->estimated_proportion_female[i] = pop->proportion_female[i];
}
}
Expand All @@ -186,22 +186,22 @@ class PopulationInterface : public PopulationInterfaceBase {
this->derived_recruitment = Rcpp::NumericVector(pop->expected_recruitment.size());

//set naa from Information/
for (size_t i = 0; i < this->derived_naa.size(); i++) {
for (R_xlen_t i = 0; i < this->derived_naa.size(); i++) {
this->derived_naa[i] = pop->numbers_at_age[i];
}

//set ssb from Information/
for (size_t i = 0; i < this->derived_ssb.size(); i++) {
for (R_xlen_t i = 0; i < this->derived_ssb.size(); i++) {
this->derived_ssb[i] = pop->spawning_biomass[i];
}

//set biomass from Information
for (size_t i = 0; i < this->derived_biomass.size(); i++) {
for (R_xlen_t i = 0; i < this->derived_biomass.size(); i++) {
this->derived_biomass[i] = pop->biomass[i];
}

//set recruitment from Information/
for (size_t i = 0; i < this->derived_recruitment.size(); i++) {
for (R_xlen_t i = 0; i < this->derived_recruitment.size(); i++) {
this->derived_recruitment[i] = pop->expected_recruitment[i];
}

Expand Down Expand Up @@ -250,7 +250,7 @@ class PopulationInterface : public PopulationInterfaceBase {
if (this->derived_ssb.size() == 0) {
ss << "]\n";
} else {
for (size_t i = 0; i < this->derived_ssb.size() - 1; i++) {
for (R_xlen_t i = 0; i < this->derived_ssb.size() - 1; i++) {
ss << this->derived_ssb[i] << ", ";
}
ss << this->derived_ssb[this->derived_ssb.size() - 1] << "]\n";
Expand All @@ -263,7 +263,7 @@ class PopulationInterface : public PopulationInterfaceBase {
if (this->derived_naa.size() == 0) {
ss << "]\n";
} else {
for (size_t i = 0; i < this->derived_naa.size() - 1; i++) {
for (R_xlen_t i = 0; i < this->derived_naa.size() - 1; i++) {
ss << this->derived_naa[i] << ", ";
}
ss << this->derived_naa[this->derived_naa.size() - 1] << "]\n";
Expand All @@ -276,7 +276,7 @@ class PopulationInterface : public PopulationInterfaceBase {
if (this->derived_biomass.size() == 0) {
ss << "]\n";
} else {
for (size_t i = 0; i < this->derived_biomass.size() - 1; i++) {
for (R_xlen_t i = 0; i < this->derived_biomass.size() - 1; i++) {
ss << this->derived_biomass[i] << ", ";
}
ss << this->derived_biomass[this->derived_biomass.size() - 1] << "]\n";
Expand All @@ -289,7 +289,7 @@ class PopulationInterface : public PopulationInterfaceBase {
if (this->derived_recruitment.size() == 0) {
ss << "]\n";
} else {
for (size_t i = 0; i < this->derived_recruitment.size() - 1; i++) {
for (R_xlen_t i = 0; i < this->derived_recruitment.size() - 1; i++) {
ss << this->derived_recruitment[i] << ", ";
}
ss << this->derived_recruitment[this->derived_recruitment.size() - 1] << "]\n";
Expand Down Expand Up @@ -329,7 +329,7 @@ class PopulationInterface : public PopulationInterfaceBase {
population->maturity_id = this->maturity_id;
population->log_M.resize(this->log_M.size());
population->log_init_naa.resize(this->log_init_naa.size());
for (size_t i = 0; i < log_M.size(); i++) {
for (R_xlen_t i = 0; i < log_M.size(); i++) {
population->log_M[i] = this->log_M[i].initial_value_m;
if (this->log_M[i].estimated_m) {
info->RegisterParameterName("log_M");
Expand All @@ -338,18 +338,18 @@ class PopulationInterface : public PopulationInterfaceBase {
}
info->variable_map[this->log_M.id_m] = &(population)->log_M;

for (size_t i = 0; i < log_init_naa.size(); i++) {
for (R_xlen_t i = 0; i < log_init_naa.size(); i++) {
population->log_init_naa[i] = this->log_init_naa[i].initial_value_m;
if (this->log_init_naa[i].estimated_m) {
info->RegisterParameterName("log_init_naa");
info->RegisterParameter(population->log_init_naa[i]);
}
}
info->variable_map[this->log_init_naa.id_m] = &(population)->log_init_naa;
for (int i = 0; i < ages.size(); i++) {
for (R_xlen_t i = 0; i < ages.size(); i++) {
population->ages[i] = this->ages[i];
}
for (int i = 0; i < proportion_female.size(); i++) {
for (R_xlen_t i = 0; i < proportion_female.size(); i++) {
population->proportion_female[i] = this->proportion_female[i];
if (estimate_prop_female) {
info->RegisterParameter(population->proportion_female[i]);
Expand Down
12 changes: 6 additions & 6 deletions inst/include/interface/rcpp/rcpp_objects/rcpp_recruitment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,23 @@ class BevertonHoltRecruitmentInterface : public RecruitmentInterfaceBase {
std::shared_ptr<fims_popdy::SRBevertonHolt<double> > recr =
std::dynamic_pointer_cast<fims_popdy::SRBevertonHolt<double> >(it->second);

for (size_t i = 0; i < this->logit_steep.size(); i++) {
for (R_xlen_t i = 0; i < this->logit_steep.size(); i++) {
if (this->logit_steep[i].estimated_m) {
this->logit_steep[i].final_value_m = recr->logit_steep[i];
} else {
this->logit_steep[i].final_value_m = this->logit_steep[i].initial_value_m;
}
}

for (size_t i = 0; i < log_rzero.size(); i++) {
for (R_xlen_t i = 0; i < log_rzero.size(); i++) {
if (log_rzero[i].estimated_m) {
this->log_rzero[i].final_value_m = recr->log_rzero[i];
} else {
this->log_rzero[i].final_value_m = this->log_rzero[i].initial_value_m;
}
}

for (size_t i = 0; i < this->estimated_log_devs.size(); i++) {
for (R_xlen_t i = 0; i < this->estimated_log_devs.size(); i++) {
if (this->log_devs[i].estimated_m) {
this->log_devs[i].final_value_m = recr->log_recruit_devs[i];
} else {
Expand Down Expand Up @@ -198,7 +198,7 @@ class BevertonHoltRecruitmentInterface : public RecruitmentInterfaceBase {
recruitment->id = this->id;
//set logit_steep
recruitment->logit_steep.resize(this->logit_steep.size());
for (size_t i = 0; i < this->logit_steep.size(); i++) {
for (R_xlen_t i = 0; i < this->logit_steep.size(); i++) {

recruitment->logit_steep[i] = this->logit_steep[i].initial_value_m;

Expand All @@ -218,7 +218,7 @@ class BevertonHoltRecruitmentInterface : public RecruitmentInterfaceBase {

//set log_rzero
recruitment->log_rzero.resize(this->log_rzero.size());
for (size_t i = 0; i < this->log_rzero.size(); i++) {
for (R_xlen_t i = 0; i < this->log_rzero.size(); i++) {

recruitment->log_rzero[i] = this->log_rzero[i].initial_value_m;

Expand All @@ -236,7 +236,7 @@ class BevertonHoltRecruitmentInterface : public RecruitmentInterfaceBase {

//set log_recruit_devs
recruitment->log_recruit_devs.resize(this->log_devs.size());
for (size_t i = 0; i < this->log_devs.size(); i++) {
for (R_xlen_t i = 0; i < this->log_devs.size(); i++) {
recruitment->log_recruit_devs[i] = this->log_devs[i].initial_value_m;
if (this->log_devs[i].estimated_m) {
info->RegisterParameter(recruitment->log_recruit_devs[i]);
Expand Down
Loading

0 comments on commit 62b9c9b

Please sign in to comment.