Skip to content

Commit

Permalink
Quiet coversion warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnoel committed Jan 17, 2024
1 parent e721872 commit 9c8048e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/linad99/cmpdif4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void DF_FILE::save_dvar_vector_value(const dvar_vector& v)
//int num_rec;
int min=v.indexmin();
int max=v.indexmax();
fwrite((double*)v.va + min, sizeof(double) * (max - min + 1));
fwrite((double*)v.va + min, sizeof(double) * static_cast<size_t>(max - min + 1));
}

/**
Expand All @@ -124,7 +124,7 @@ void DF_FILE::save_dvector_value(const dvector& v)
{
int min = v.indexmin();
int max = v.indexmax();
fwrite(v.get_v() + min, sizeof(double) * (max - min + 1));
fwrite(v.get_v() + min, sizeof(double) * static_cast<size_t>(max - min + 1));
}

/**
Expand All @@ -139,7 +139,7 @@ void DF_FILE::save_ivector_value(const ivector& v)
constexpr size_t sizeofint = sizeof(int);
int min=v.indexmin();
int max=v.indexmax();
fwrite(v.get_v() + min, sizeofint * (max - min + 1));
fwrite(v.get_v() + min, sizeofint * static_cast<size_t>(max - min + 1));
}

/**
Expand All @@ -160,7 +160,7 @@ dvector DF_FILE::restore_dvector_value(const dvector_position& tmp)
int min = tmp.indexmin();
int max = tmp.indexmax();
dvector temp_vec(min, max);
fread(temp_vec.get_v() + min, sizeof(double) * (max - min + 1));
fread(temp_vec.get_v() + min, sizeof(double) * static_cast<size_t>(max - min + 1));

return temp_vec;
}
Expand All @@ -182,7 +182,7 @@ ivector DF_FILE::restore_ivector_value(const ivector_position& tmp)
int min = tmp.indexmin();
int max = tmp.indexmax();
ivector temp_vec(min, max);
fread(temp_vec.get_v() + min, sizeofint * (max - min + 1));
fread(temp_vec.get_v() + min, sizeofint * static_cast<size_t>(max - min + 1));
return temp_vec;
// Back up the stream again for the next function
}
Expand All @@ -202,7 +202,7 @@ dvector DF_FILE::restore_dvar_vector_value(const dvar_vector_position& tmp)
int min = tmp.indexmin();
int max = tmp.indexmax();
dvector temp_vec(min, max);
fread(temp_vec.get_v() + min, sizeof(double) * (max - min + 1));
fread(temp_vec.get_v() + min, sizeof(double) * static_cast<size_t>(max - min + 1));
return temp_vec;
}
/**
Expand Down
2 changes: 1 addition & 1 deletion src/linad99/cmpdif5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ void DF_FILE::save_dvar_matrix_position(const dvar_matrix& m)

int min=m.rowmin();
int max=m.rowmax();
int size = max - min + 1;
size_t size = static_cast<size_t>(max - min + 1);

constexpr size_t wsize1 = sizeof(void*);
fwrite(&tmp.ptr.elem(min), wsize1 * size);
Expand Down
6 changes: 3 additions & 3 deletions src/linad99/cmpdif6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void DF_FILE::save_dmatrix_position(const dmatrix& m)

int min=m.rowmin();
int max=m.rowmax();
size_t size = max - min + 1;
size_t size = static_cast<size_t>(max - min + 1);

constexpr size_t wsize1=sizeof(void*);
fwrite(&tmp.ptr.elem(min), wsize1 * size);
Expand Down Expand Up @@ -116,7 +116,7 @@ dvar_matrix_position DF_FILE::restore_dvar_matrix_position()
fread(&min, wsize);
dvar_matrix_position tmp(min,max);

int size = max - min + 1;
size_t size = static_cast<size_t>(max - min + 1);

fread(tmp.ub.get_v() + min, wsize * size);
fread(tmp.lb.get_v() + min, wsize * size);
Expand Down Expand Up @@ -147,7 +147,7 @@ dmatrix_position DF_FILE::restore_dmatrix_position()

dmatrix_position tmp(min,max);
// cout << "tmp.ptr= " << tmp.ptr ;
int size = max - min + 1;
size_t size = static_cast<size_t>(max - min + 1);
fread(tmp.ub.get_v() + min, wsize * size);
fread(tmp.lb.get_v() + min, wsize * size);

Expand Down
7 changes: 4 additions & 3 deletions src/linad99/conjprod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void fmmc::fmin(const double& fret, const dvector& _p, const dvector& _gg)
#endif
dvector& p = (dvector&)_p;
dvector& gg = (dvector&)_gg;
int n=p.size();
int n = static_cast<int>(p.size());
dvector& xi=*(this->xi);
dvector& h=*(this->h);
dvector& g=*(this->g);
Expand Down Expand Up @@ -847,8 +847,9 @@ void do_extrapolate(const double& _left_bracket,
void bracket_report([[maybe_unused]] const dvector& theta, [[maybe_unused]] const double& left_bracket,
[[maybe_unused]] double& right_bracket, const dvector& d)
{
dvector g(1,d.size());
dvector u(1,d.size());
int size = static_cast<int>(d.size());
dvector g(1, size);
dvector u(1, size);
ivector ii(1,3);
int one=1;
ii.fill_seqadd(one,one);
Expand Down

0 comments on commit 9c8048e

Please sign in to comment.