Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea-Havron-NOAA committed Aug 2, 2024
1 parent 47a9c67 commit f08cdbf
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 35 deletions.
2 changes: 1 addition & 1 deletion inst/include/common/information.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class Information {
INFO_LOG << "Checking for available density components data objects."
<< std::endl;
//set data objects
if(d->input_type == "data" & d->observed_data_id_m != -999){
if((d->input_type == "data") & (d->observed_data_id_m != -999)){
uint32_t observed_data_id = static_cast<uint32_t>(d->observed_data_id_m);
data_iterator it = this->data_objects.find(observed_data_id);
INFO_LOG << "Input data id = " << observed_data_id << "." << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct DensityComponentBase : public fims_model_object::FIMSObject<Type> {
// Assigning each one its own ID is a way to keep track of
// all the instances of the DensityComponentBase class.
static uint32_t id_g; /**< global unique identifier for distribution modules */
size_t observed_data_id_m = -999; /*!< id of observed data component*/
uint32_t observed_data_id_m = -999; /*!< id of observed data component*/
std::shared_ptr<fims_data_object::DataObject<Type>>
observed_values; /**< observed data*/
fims::Vector<Type > x; /**< input value of distribution function for proirs or random effects*/
Expand Down
14 changes: 5 additions & 9 deletions inst/include/distributions/functors/multinomial_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,16 @@ namespace fims_distributions

#ifdef TMB_MODEL
for (size_t j = 0; j < dims[1]; j++){
if (this->observed_values->at(i, j) !=
if (this->observed_values->at(i, j) ==
this->observed_values->na_value) {
size_t idx = (i * dims[1]) + j;
} else {
containsNA = true;
break;
}
}
if(!containsNA){
for (size_t j = 0; j < dims[1]; j++){
size_t idx = (i * dims[1]) + j;
x_vector[j] = this->observed_values->at(i, j);
prob_vector[j] = this->expected_values[idx];
}
size_t idx = (i * dims[1]) + j;
x_vector[j] = this->observed_values->at(i, j);
prob_vector[j] = this->expected_values[idx];

}

this->lpdf_vec[i] = dmultinom((vector<Type>)x_vector, (vector<Type>)prob_vector, true);
Expand Down
2 changes: 1 addition & 1 deletion inst/include/interface/rcpp/rcpp_objects/rcpp_fleet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class FleetInterface : public FleetInterfaceBase {
}

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

if (this->log_Fmort[i].estimated_m) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class ParameterVector{
* @param value The value to be assigned
*/
void fill_min(double value){
for(size_t i = 0; i < this->storage_m.size(); i++){
for(int i = 0; i < this->storage_m.size(); i++){
Parameter p = Rcpp::as<Parameter>(this->storage_m[i]);
p.min_m = value;
this->storage_m[i] = Rcpp::wrap(p);
Expand All @@ -225,7 +225,7 @@ class ParameterVector{
* @param value The value to be assigned
*/
void fill_max(double value){
for(size_t i = 0; i < this->storage_m.size(); i++){
for(int i = 0; i < this->storage_m.size(); i++){
Parameter p = Rcpp::as<Parameter>(this->storage_m[i]);
p.max_m = value;
this->storage_m[i] = Rcpp::wrap(p);
Expand Down
4 changes: 2 additions & 2 deletions inst/include/interface/rcpp/rcpp_objects/rcpp_population.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ 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 (int i = 0; i < log_M.size(); i++) {
for (size_t i = 0; i < log_M.size(); i++) {
population->log_M[i] = this->log_M[i].value_m;
if (this->log_M[i].estimated_m) {
info->RegisterParameter(population->log_M[i]);
}
}
info->variable_map[this->log_M.id_m] = &(population)->log_M;

for (int i = 0; i < log_init_naa.size(); i++) {
for (size_t i = 0; i < log_init_naa.size(); i++) {
population->log_init_naa[i] = this->log_init_naa[i].value_m;
if (this->log_init_naa[i].estimated_m) {
info->RegisterParameter(population->log_init_naa[i]);
Expand Down
38 changes: 19 additions & 19 deletions inst/include/interface/rcpp/rcpp_objects/rcpp_tmb_distribution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class DnormDistributionsInterface : public DistributionsInterfaceBase {
virtual void set_distribution_links(std::string input_type, Rcpp::IntegerVector ids){
this->input_type_m = input_type;
this->key_m.resize(ids.size());
for(size_t i; i<ids.size(); i++){
for(int i; i<ids.size(); i++){
this->key_m[i] = ids[i];
}
}
Expand All @@ -130,13 +130,13 @@ class DnormDistributionsInterface : public DistributionsInterfaceBase {
dnorm.x.resize(this->x.size());
dnorm.expected_values.resize(this->expected_values.size());
dnorm.log_sd.resize(this->log_sd.size());
for(int i=0; i<x.size(); i++){
for(size_t i=0; i<x.size(); i++){
dnorm.x[i] = this->x[i].value_m;
}
for(int i=0; i<expected_values.size(); i++){
for(size_t i=0; i<expected_values.size(); i++){
dnorm.expected_values[i] = this->expected_values[i].value_m;
}
for(int i=0; i<log_sd.size(); i++){
for(size_t i=0; i<log_sd.size(); i++){
dnorm.log_sd[i] = this->log_sd[i].value_m;
}
return dnorm.evaluate();
Expand All @@ -161,16 +161,16 @@ class DnormDistributionsInterface : public DistributionsInterfaceBase {

distribution->id = this->id_m;
distribution->x.resize(this->x.size());
for(int i=0; i<this->x.size(); i++){
for(size_t i=0; i<this->x.size(); i++){
distribution->x[i] = this->x[i].value_m;
}
// set relative info
distribution->expected_values.resize(this->expected_values.size());
for(int i=0; i<this->expected_values.size(); i++){
for(size_t i=0; i<this->expected_values.size(); i++){
distribution->expected_values[i] = this->expected_values[i].value_m;
}
distribution->log_sd.resize(this->log_sd.size());
for(int i=0; i<this->log_sd.size(); i++){
for(size_t i=0; i<this->log_sd.size(); i++){
distribution->log_sd[i] = this->log_sd[i].value_m;
}

Expand Down Expand Up @@ -235,7 +235,7 @@ class DlnormDistributionsInterface : public DistributionsInterfaceBase {
virtual void set_distribution_links(std::string input_type, Rcpp::IntegerVector ids){
this->input_type_m = input_type;
this->key_m.resize(ids.size());
for(size_t i; i<ids.size(); i++){
for(int i; i<ids.size(); i++){
this->key_m[i] = ids[i];
}
}
Expand All @@ -253,13 +253,13 @@ class DlnormDistributionsInterface : public DistributionsInterfaceBase {
dlnorm.x.resize(this->x.size());
dlnorm.expected_values.resize(this->expected_values.size());
dlnorm.log_logsd.resize(this->log_logsd.size());
for(int i=0; i<x.size(); i++){
for(size_t i=0; i<x.size(); i++){
dlnorm.x[i] = this->x[i].value_m;
}
for(int i=0; i<expected_values.size(); i++){
for(size_t i=0; i<expected_values.size(); i++){
dlnorm.expected_values[i] = this->expected_values[i].value_m;
}
for(int i=0; i<log_logsd.size(); i++){
for(size_t i=0; i<log_logsd.size(); i++){
dlnorm.log_logsd[i] = this->log_logsd[i].value_m;
}
return dlnorm.evaluate();
Expand All @@ -281,16 +281,16 @@ class DlnormDistributionsInterface : public DistributionsInterfaceBase {
interface_observed_data_id_m;
distribution->input_type = this->input_type;
distribution->x.resize(this->x.size());
for(int i=0; i<this->x.size(); i++){
for(size_t i=0; i<this->x.size(); i++){
distribution->x[i] = this->x[i].value_m;
}
// set relative info
distribution->expected_values.resize(this->expected_values.size());
for(int i=0; i<this->expected_values.size(); i++){
for(size_t i=0; i<this->expected_values.size(); i++){
distribution->expected_values[i] = this->expected_values[i].value_m;
}
distribution->log_logsd.resize(this->log_logsd.size());
for(int i=0; i<this->log_logsd.size(); i++){
for(size_t i=0; i<this->log_logsd.size(); i++){
distribution->log_logsd[i] = this->log_logsd[i].value_m;
}

Expand Down Expand Up @@ -354,7 +354,7 @@ class DmultinomDistributionsInterface : public DistributionsInterfaceBase {
virtual void set_distribution_links(std::string input_type, Rcpp::IntegerVector ids){
this->input_type_m = input_type;
this->key_m.resize(ids.size());
for(size_t i; i<ids.size(); i++){
for(int i; i<ids.size(); i++){
this->key_m[i] = ids[i];
}
}
Expand All @@ -371,10 +371,10 @@ class DmultinomDistributionsInterface : public DistributionsInterfaceBase {
// Declare TMBVector in this scope
dmultinom.x.resize(this->x.size());
dmultinom.expected_values.resize(this->expected_values.size());
for(int i=0; i<x.size(); i++){
for(size_t i=0; i<x.size(); i++){
dmultinom.x[i] = this->x[i].value_m;
}
for(int i=0; i<expected_values.size(); i++){
for(size_t i=0; i<expected_values.size(); i++){
dmultinom.expected_values[i] = this->expected_values[i].value_m;
}
dmultinom.dims.resize(2);
Expand All @@ -397,12 +397,12 @@ class DmultinomDistributionsInterface : public DistributionsInterfaceBase {
distribution->observed_data_id_m =
interface_observed_data_id_m;
distribution->x.resize(this->x.size());
for(int i=0; i<this->x.size(); i++){
for(size_t i=0; i<this->x.size(); i++){
distribution->x[i] = this->x[i].value_m;
}
// set relative info
distribution->expected_values.resize(this->expected_values.size());
for(int i=0; i<this->expected_values.size(); i++){
for(size_t i=0; i<this->expected_values.size(); i++){
distribution->expected_values[i] = this->expected_values[i].value_m;
}
distribution->dims.resize(2);
Expand Down

0 comments on commit f08cdbf

Please sign in to comment.