Skip to content

Commit

Permalink
Merge pull request #457 from ut-issl/feature/remove-size_t-int-warnings
Browse files Browse the repository at this point in the history
Remove size_t related warnings
  • Loading branch information
200km authored Jul 18, 2023
2 parents 15826a7 + 4fff36d commit 6da3fda
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 60 deletions.
2 changes: 1 addition & 1 deletion src/components/real/mission/telescope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void Telescope::ObserveStars() {
Quaternion quaternion_i2b = attitude_->GetQuaternion_i2b();

star_list_in_sight.clear(); // Clear first
int count = 0; // Counter for while loop
size_t count = 0; // Counter for while loop

while (star_list_in_sight.size() < number_of_logged_stars_) {
libra::Vector<3> target_b = hipparcos_->GetStarDirection_b(count, quaternion_i2b);
Expand Down
2 changes: 1 addition & 1 deletion src/disturbances/air_drag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ AirDrag::AirDrag(const std::vector<Surface>& surfaces, const libra::Vector<3>& c
wall_temperature_K_(wall_temperature_K),
molecular_temperature_K_(molecular_temperature_K),
molecular_weight_g_mol_(molecular_weight_g_mol) {
int num = surfaces_.size();
size_t num = surfaces_.size();
ct_.assign(num, 1.0);
cn_.assign(num, 0.0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/disturbances/surface_force.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
SurfaceForce::SurfaceForce(const std::vector<Surface>& surfaces, const libra::Vector<3>& center_of_gravity_b_m, const bool is_calculation_enabled)
: Disturbance(is_calculation_enabled, true), surfaces_(surfaces), center_of_gravity_b_m_(center_of_gravity_b_m) {
// Initialize vectors
int num = surfaces_.size();
size_t num = surfaces_.size();
normal_coefficients_.assign(num, 0.0);
tangential_coefficients_.assign(num, 0.0);
cos_theta_.assign(num, 0.0);
Expand Down
4 changes: 2 additions & 2 deletions src/dynamics/thermal/initialize_temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ Temperature* InitTemperature(const std::string file_name, const double rk_prop_s
vector<vector<string>> node_str_list; // string vector of node property data
vector<vector<string>> heater_str_list; // string vector of heater property data
vector<vector<string>> heatload_str_list; // string vector of heatload property data
unsigned int node_num = 1;
unsigned int heater_num = 1;
size_t node_num = 1;
size_t heater_num = 1;

bool is_calc_enabled = mainIni.ReadEnable("THERMAL", "calculation");
if (is_calc_enabled == false) {
Expand Down
20 changes: 10 additions & 10 deletions src/environment/global/gnss_satellites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ double get_unixtime_from_timestamp_line(std::vector<string>& s) {
template <size_t N>
libra::Vector<N> GnssSat_coordinate::TrigonometricInterpolation(const vector<double>& time_vector, const vector<libra::Vector<N>>& values,
double time) const {
int n = time_vector.size();
size_t n = time_vector.size();
double w = libra::tau / (24.0 * 60.0 * 60.0) * 1.03; // coefficient of a day long
libra::Vector<N> res(0.0);

for (int i = 0; i < n; ++i) {
for (size_t i = 0; i < n; ++i) {
double t_k = 1.0;
for (int j = 0; j < n; ++j) {
for (size_t j = 0; j < n; ++j) {
if (i == j) continue;
t_k *= sin(w * (time - time_vector.at(j)) / 2.0) / sin(w * (time_vector.at(i) - time_vector.at(j)) / 2.0);
}
for (int j = 0; j < (int)N; ++j) {
for (size_t j = 0; j < (int)N; ++j) {
res(j) += t_k * values.at(i)(j);
}
}
Expand All @@ -103,13 +103,13 @@ libra::Vector<N> GnssSat_coordinate::TrigonometricInterpolation(const vector<dou
}

double GnssSat_coordinate::TrigonometricInterpolation(const vector<double>& time_vector, const vector<double>& values, double time) const {
int n = time_vector.size();
size_t n = time_vector.size();
double w = libra::tau / (24.0 * 60.0 * 60.0) * 1.03; // coefficient of a day long
double res = 0.0;

for (int i = 0; i < n; ++i) {
for (size_t i = 0; i < n; ++i) {
double t_k = 1.0;
for (int j = 0; j < n; ++j) {
for (size_t j = 0; j < n; ++j) {
if (i == j) continue;
t_k *= sin(w * (time - time_vector.at(j)) / 2.0) / sin(w * (time_vector.at(i) - time_vector.at(j)) / 2.0);
}
Expand Down Expand Up @@ -140,11 +140,11 @@ libra::Vector<N> GnssSat_coordinate::LagrangeInterpolation(const vector<double>&
}

double GnssSat_coordinate::LagrangeInterpolation(const vector<double>& time_vector, const vector<double>& values, double time) const {
int n = time_vector.size();
size_t n = time_vector.size();
double res = 0.0;
for (int i = 0; i < n; ++i) {
for (size_t i = 0; i < n; ++i) {
double l_i = 1.0;
for (int j = 0; j < n; ++j) {
for (size_t j = 0; j < n; ++j) {
if (i == j) continue;
l_i *= (time - time_vector.at(j)) / (time_vector.at(i) - time_vector.at(j));
}
Expand Down
4 changes: 2 additions & 2 deletions src/environment/global/hipparcos_catalogue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool HipparcosCatalogue::ReadContents(const std::string& file_name, const char d
return true;
}

libra::Vector<3> HipparcosCatalogue::GetStarDirection_i(int rank) const {
libra::Vector<3> HipparcosCatalogue::GetStarDirection_i(size_t rank) const {
libra::Vector<3> direction_i;
double ra_rad = GetRightAscension_deg(rank) * libra::deg_to_rad;
double de_rad = GetDeclination_deg(rank) * libra::deg_to_rad;
Expand All @@ -61,7 +61,7 @@ libra::Vector<3> HipparcosCatalogue::GetStarDirection_i(int rank) const {
return direction_i;
}

libra::Vector<3> HipparcosCatalogue::GetStarDirection_b(int rank, libra::Quaternion quaternion_i2b) const {
libra::Vector<3> HipparcosCatalogue::GetStarDirection_b(size_t rank, libra::Quaternion quaternion_i2b) const {
libra::Vector<3> direction_i;
libra::Vector<3> direction_b;

Expand Down
14 changes: 7 additions & 7 deletions src/environment/global/hipparcos_catalogue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,44 +52,44 @@ class HipparcosCatalogue : public ILoggable {
*@fn GetCatalogueSize
*@brief Return read catalogue size
*/
int GetCatalogueSize() const { return hipparcos_catalogue_.size(); }
size_t GetCatalogueSize() const { return hipparcos_catalogue_.size(); }
/**
*@fn GetHipparcosId
*@brief Return Hipparcos ID of a star
*@param [in] rank: Rank of star magnitude in read catalogue
*/
int GetHipparcosId(int rank) const { return hipparcos_catalogue_[rank].hipparcos_id; }
int GetHipparcosId(size_t rank) const { return hipparcos_catalogue_[rank].hipparcos_id; }
/**
*@fn GetVisibleMagnitude
*@brief Return magnitude in visible wave length of a star
*@param [in] rank: Rank of star magnitude in read catalogue
*/
double GetVisibleMagnitude(int rank) const { return hipparcos_catalogue_[rank].visible_magnitude; }
double GetVisibleMagnitude(size_t rank) const { return hipparcos_catalogue_[rank].visible_magnitude; }
/**
*@fn GetRightAscension_deg
*@brief Return right ascension of a star
*@param [in] rank: Rank of star magnitude in read catalogue
*/
double GetRightAscension_deg(int rank) const { return hipparcos_catalogue_[rank].right_ascension_deg; }
double GetRightAscension_deg(size_t rank) const { return hipparcos_catalogue_[rank].right_ascension_deg; }
/**
*@fn GetDeclination_deg
*@brief Return declination of a star
*@param [in] rank: Rank of star magnitude in read catalogue
*/
double GetDeclination_deg(int rank) const { return hipparcos_catalogue_[rank].declination_deg; }
double GetDeclination_deg(size_t rank) const { return hipparcos_catalogue_[rank].declination_deg; }
/**
*@fn GetStarDir_i
*@brief Return direction vector of a star in the inertial frame
*@param [in] rank: Rank of star magnitude in read catalogue
*/
libra::Vector<3> GetStarDirection_i(int rank) const;
libra::Vector<3> GetStarDirection_i(size_t rank) const;
/**
*@fn GetStarDir_b
*@brief Return direction vector of a star in the body-fixed frame
*@param [in] rank: Rank of star magnitude in read catalogue
*@param [in] quaternion_i2b: Quaternion from the inertial frame to the body-fixed frame
*/
libra::Vector<3> GetStarDirection_b(int rank, libra::Quaternion quaternion_i2b) const;
libra::Vector<3> GetStarDirection_b(size_t rank, libra::Quaternion quaternion_i2b) const;

// Override ILoggable
/**
Expand Down
4 changes: 2 additions & 2 deletions src/library/external/nrlmsise00/wrapper_nrlmsise00.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ double CalcNRLMSISE00(double decyear, double latrad, double lonrad, double alt,

size_t i;
int date[6];
int idx = 0;
size_t idx = 0;

/* input values */
for (i = 0; i < 24; i++) {
Expand Down Expand Up @@ -236,7 +236,7 @@ double CalcNRLMSISE00(double decyear, double latrad, double lonrad, double alt,
/* ------------------------------------------------------------------- */
/* -----------------------ReadSpaceWeatherTable----------------------- */
/* ------------------------------------------------------------------- */
int GetSpaceWeatherTable_(double decyear, double endsec, const string& filename, vector<nrlmsise_table>& table) {
size_t GetSpaceWeatherTable_(double decyear, double endsec, const string& filename, vector<nrlmsise_table>& table) {
ifstream ifs(filename);

if (!ifs.is_open()) {
Expand Down
2 changes: 1 addition & 1 deletion src/library/external/nrlmsise00/wrapper_nrlmsise00.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ double CalcNRLMSISE00(double decyear, double latrad, double lonrad, double alt,
* @param [out] table: Space weather table
* @return Size of table
*/
int GetSpaceWeatherTable_(double decyear, double endsec, const std::string& filename, std::vector<nrlmsise_table>& table);
size_t GetSpaceWeatherTable_(double decyear, double endsec, const std::string& filename, std::vector<nrlmsise_table>& table);

/* ------------------------------------------------------------------- */
/* ----------------------- COMPILATION TWEAKS ------------------------ */
Expand Down
4 changes: 2 additions & 2 deletions src/library/initialize/initialize_file_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ std::vector<std::string> IniAccess::Split(const std::string& input, const char d
return result;
}

void IniAccess::ReadCsvDouble(std::vector<std::vector<double>>& output_value, const int node_num) {
void IniAccess::ReadCsvDouble(std::vector<std::vector<double>>& output_value, const size_t node_num) {
std::ifstream ifs(file_path_char_);
if (!ifs.is_open()) {
std::cerr << "file open error. filename = " << file_path_char_ << std::endl;
Expand Down Expand Up @@ -226,7 +226,7 @@ void IniAccess::ReadCsvDoubleWithHeader(std::vector<std::vector<double>>& output
}
}

void IniAccess::ReadCsvString(std::vector<std::vector<std::string>>& output_value, const int node_num) {
void IniAccess::ReadCsvString(std::vector<std::vector<std::string>>& output_value, const size_t node_num) {
std::ifstream ifs(file_path_char_);
if (!ifs.is_open()) {
std::cerr << "file open error. filename = " << file_path_char_ << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions src/library/initialize/initialize_file_access.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class IniAccess {
* @param[out] output_value: Read double matrix value
* @param[in] node_num: Number of node. When reading n * m matrix, please substitute bigger number.
*/
void ReadCsvDouble(std::vector<std::vector<double>>& output_value, const int node_num);
void ReadCsvDouble(std::vector<std::vector<double>>& output_value, const size_t node_num);
/**
* @fn ReadCsvDoubleWithHeader
* @brief Read matrix value in CSV file with header
Expand All @@ -155,7 +155,7 @@ class IniAccess {
* @param[out] output_value: Read matrix of string
* @param[in] node_num: Number of node. When reading n * m matrix, please substitute bigger number.
*/
void ReadCsvString(std::vector<std::vector<std::string>>& output_value, const int node_num);
void ReadCsvString(std::vector<std::vector<std::string>>& output_value, const size_t node_num);

private:
static const size_t kMaxCharLength = 1024;
Expand Down
4 changes: 2 additions & 2 deletions src/library/math/matrix_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Matrix<N, N> CalcInverseMatrix(const Matrix<N, N>& matrix);
* @return Result of LU decomposed matrix
*/
template <std::size_t N>
Matrix<N, N>& LuDecomposition(Matrix<N, N>& matrix, unsigned int index[]);
Matrix<N, N>& LuDecomposition(Matrix<N, N>& matrix, size_t index[]);

/**
* @fn SolveLinearSystemWithLu
Expand All @@ -50,7 +50,7 @@ Matrix<N, N>& LuDecomposition(Matrix<N, N>& matrix, unsigned int index[]);
* @return Result vector
*/
template <std::size_t N>
Vector<N>& SolveLinearSystemWithLu(const Matrix<N, N>& matrix, const unsigned int index[], Vector<N>& vector);
Vector<N>& SolveLinearSystemWithLu(const Matrix<N, N>& matrix, const size_t index[], Vector<N>& vector);

} // namespace libra

Expand Down
10 changes: 5 additions & 5 deletions src/library/math/matrix_vector_template_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Vector<R, TC> operator*(const Matrix<R, C, TM>& matrix, const Vector<C, TC>& vec
template <std::size_t N>
Matrix<N, N> CalcInverseMatrix(const Matrix<N, N>& matrix) {
Matrix<N, N> temp(matrix);
unsigned int index[N];
size_t index[N];
LuDecomposition(temp, index);

Matrix<N, N> inverse;
Expand All @@ -41,7 +41,7 @@ Matrix<N, N> CalcInverseMatrix(const Matrix<N, N>& matrix) {
}

template <std::size_t N>
Matrix<N, N>& LuDecomposition(Matrix<N, N>& a, unsigned int index[]) {
Matrix<N, N>& LuDecomposition(Matrix<N, N>& a, size_t index[]) {
double coef[N];
for (size_t i = 0; i < N; ++i) {
double biggest = 0.0;
Expand Down Expand Up @@ -109,12 +109,12 @@ Matrix<N, N>& LuDecomposition(Matrix<N, N>& a, unsigned int index[]) {
}

template <std::size_t N>
Vector<N>& SolveLinearSystemWithLu(const Matrix<N, N>& a, const unsigned int index[], Vector<N>& b) {
Vector<N>& SolveLinearSystemWithLu(const Matrix<N, N>& a, const size_t index[], Vector<N>& b) {
double sum;
bool non_zero = false;
unsigned int mark = 0;
size_t mark = 0;
for (size_t i = 0; i < N; ++i) {
unsigned int ip = index[i];
size_t ip = index[i];
sum = b[ip];
b[ip] = b[i];
if (non_zero) {
Expand Down
2 changes: 1 addition & 1 deletion src/library/math/ordinary_differential_equation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class OrdinaryDifferentialEquation {
* @brief Return element of current state vector
* @param [in] n: Target element number
*/
inline double operator[](int n) const { return state_[n]; }
inline double operator[](size_t n) const { return state_[n]; }

protected:
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ void OrdinaryDifferentialEquation<N>::Update() {
// 4th order Runge-Kutta method
Vector<N> k1(derivative_);
k1 *= step_width_s_;
Vector<N> k2(state_.GetLength());
Vector<N> k2((double)state_.GetLength());
DerivativeFunction(independent_variable_ + 0.5 * step_width_s_, state_ + 0.5 * k1, k2);
k2 *= step_width_s_;
Vector<N> k3(state_.GetLength());
Vector<N> k3((double)state_.GetLength());
DerivativeFunction(independent_variable_ + 0.5 * step_width_s_, state_ + 0.5 * k2, k3);
k3 *= step_width_s_;
Vector<N> k4(state_.GetLength());
Vector<N> k4((double)state_.GetLength());
DerivativeFunction(independent_variable_ + step_width_s_, state_ + k3, k4);
k4 *= step_width_s_;

Expand Down
10 changes: 5 additions & 5 deletions src/simulation/multiple_spacecraft/relative_information.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ void RelativeInformation::Update() {
}
}

void RelativeInformation::RegisterDynamicsInfo(const int spacecraft_id, const Dynamics* dynamics) {
void RelativeInformation::RegisterDynamicsInfo(const size_t spacecraft_id, const Dynamics* dynamics) {
dynamics_database_.emplace(spacecraft_id, dynamics);
ResizeLists();
}

void RelativeInformation::RemoveDynamicsInfo(const int spacecraft_id) {
void RelativeInformation::RemoveDynamicsInfo(const size_t spacecraft_id) {
dynamics_database_.erase(spacecraft_id);
ResizeLists();
}
Expand Down Expand Up @@ -111,7 +111,7 @@ std::string RelativeInformation::GetLogValue() const {

void RelativeInformation::LogSetup(Logger& logger) { logger.AddLogList(this); }

libra::Quaternion RelativeInformation::CalcRelativeAttitudeQuaternion(const int target_spacecraft_id, const int reference_spacecraft_id) {
libra::Quaternion RelativeInformation::CalcRelativeAttitudeQuaternion(const size_t target_spacecraft_id, const size_t reference_spacecraft_id) {
// Observer SC Body frame(obs_sat) -> ECI frame(i)
libra::Quaternion q_reference_i2b = dynamics_database_.at(reference_spacecraft_id)->GetAttitude().GetQuaternion_i2b();
libra::Quaternion q_reference_b2i = q_reference_i2b.Conjugate();
Expand All @@ -122,7 +122,7 @@ libra::Quaternion RelativeInformation::CalcRelativeAttitudeQuaternion(const int
return q_target_i2b * q_reference_b2i;
}

libra::Vector<3> RelativeInformation::CalcRelativePosition_rtn_m(const int target_spacecraft_id, const int reference_spacecraft_id) {
libra::Vector<3> RelativeInformation::CalcRelativePosition_rtn_m(const size_t target_spacecraft_id, const size_t reference_spacecraft_id) {
libra::Vector<3> target_sat_pos_i = dynamics_database_.at(target_spacecraft_id)->GetOrbit().GetPosition_i_m();
libra::Vector<3> reference_sat_pos_i = dynamics_database_.at(reference_spacecraft_id)->GetOrbit().GetPosition_i_m();
libra::Vector<3> relative_pos_i = target_sat_pos_i - reference_sat_pos_i;
Expand All @@ -134,7 +134,7 @@ libra::Vector<3> RelativeInformation::CalcRelativePosition_rtn_m(const int targe
return relative_pos_rtn;
}

libra::Vector<3> RelativeInformation::CalcRelativeVelocity_rtn_m_s(const int target_spacecraft_id, const int reference_spacecraft_id) {
libra::Vector<3> RelativeInformation::CalcRelativeVelocity_rtn_m_s(const size_t target_spacecraft_id, const size_t reference_spacecraft_id) {
libra::Vector<3> target_sat_pos_i = dynamics_database_.at(target_spacecraft_id)->GetOrbit().GetPosition_i_m();
libra::Vector<3> reference_sat_pos_i = dynamics_database_.at(reference_spacecraft_id)->GetOrbit().GetPosition_i_m();
libra::Vector<3> relative_pos_i = target_sat_pos_i - reference_sat_pos_i;
Expand Down
Loading

0 comments on commit 6da3fda

Please sign in to comment.