Skip to content

Commit ac76034

Browse files
committed
Make number conversions explicit
1 parent d35973d commit ac76034

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

examples/data_distribution/scatter3/scatter3_1.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ std::tuple<std::vector<double>, std::vector<double>, std::vector<double>>
1919
generate_data() {
2020
using namespace matplot;
2121
int n = 16;
22-
auto r = iota(-n, 2., n);
22+
auto r = iota(static_cast<double>(-n), 2., static_cast<double>(n));
2323
auto theta = transform(r, [n](double x) { return x / n * pi; });
2424
auto phi = transform(r, [n](double x) { return x / n * pi / 2.; });
2525
auto sinphi = transform(phi, [](double x) { return sin(x); });
2626
auto cosphi = transform(phi, [](double x) { return cos(x); });
2727
cosphi.front() = 0;
2828
cosphi.back() = 0;
29-
auto sintheta = transform(theta, [n](double x) { return sin(x); });
29+
auto sintheta = transform(theta, [](double x) { return sin(x); });
3030
sintheta.front() = 0;
3131
sintheta.back() = 0;
32-
auto costheta = transform(theta, [n](double x) { return cos(x); });
32+
auto costheta = transform(theta, [](double x) { return cos(x); });
3333
std::vector<std::vector<double>> X(17, std::vector<double>(17, 0.));
3434
std::vector<std::vector<double>> Y(17, std::vector<double>(17, 0.));
3535
std::vector<std::vector<double>> Z(17, std::vector<double>(17, 0.));
36-
for (size_t i = 0; i < n + 1; ++i) {
37-
for (size_t j = 0; j < n + 1; ++j) {
36+
for (int i = 0; i < n + 1; ++i) {
37+
for (int j = 0; j < n + 1; ++j) {
3838
X[i][j] = cosphi[i] * costheta[j];
3939
Y[i][j] = cosphi[i] * sintheta[j];
4040
Z[i][j] = sinphi[i];

examples/data_distribution/scatter3/scatter3_2.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ generate_data() {
3838
std::vector<std::vector<double>> X(17, std::vector<double>(17, 0.));
3939
std::vector<std::vector<double>> Y(17, std::vector<double>(17, 0.));
4040
std::vector<std::vector<double>> Z(17, std::vector<double>(17, 0.));
41-
for (size_t i = 0; i < n + 1; ++i) {
42-
for (size_t j = 0; j < n + 1; ++j) {
41+
for (int i = 0; i < n + 1; ++i) {
42+
for (int j = 0; j < n + 1; ++j) {
4343
X[i][j] = cosphi[i] * costheta[j];
4444
Y[i][j] = cosphi[i] * sintheta[j];
4545
Z[i][j] = sinphi[i];

examples/data_distribution/scatter3/scatter3_3.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ generate_data() {
4343
std::vector<std::vector<double>> X(17, std::vector<double>(17, 0.));
4444
std::vector<std::vector<double>> Y(17, std::vector<double>(17, 0.));
4545
std::vector<std::vector<double>> Z(17, std::vector<double>(17, 0.));
46-
for (size_t i = 0; i < n + 1; ++i) {
47-
for (size_t j = 0; j < n + 1; ++j) {
46+
for (int i = 0; i < n + 1; ++i) {
47+
for (int j = 0; j < n + 1; ++j) {
4848
X[i][j] = cosphi[i] * costheta[j];
4949
Y[i][j] = cosphi[i] * sintheta[j];
5050
Z[i][j] = sinphi[i];

examples/data_distribution/scatter3/scatter3_6.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ generate_data() {
4242
std::vector<std::vector<double>> X(17, std::vector<double>(17, 0.));
4343
std::vector<std::vector<double>> Y(17, std::vector<double>(17, 0.));
4444
std::vector<std::vector<double>> Z(17, std::vector<double>(17, 0.));
45-
for (size_t i = 0; i < n + 1; ++i) {
46-
for (size_t j = 0; j < n + 1; ++j) {
45+
for (int i = 0; i < n + 1; ++i) {
46+
for (int j = 0; j < n + 1; ++j) {
4747
X[i][j] = cosphi[i] * costheta[j];
4848
Y[i][j] = cosphi[i] * sintheta[j];
4949
Z[i][j] = sinphi[i];

examples/geography/geoplot/geoplot_6.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class eurotrip_solver {
88
public:
99
eurotrip_solver(const vector<double> &lat, const vector<double> &lon,
1010
const vector<string> &names, axes_handle ax);
11-
void run(int iterations = 100);
11+
void run(size_t iterations = 100);
1212

1313
private:
1414
void setup_starting_point(size_t iteration);
@@ -40,7 +40,7 @@ eurotrip_solver::eurotrip_solver(const vector<double> &lat,
4040
const vector<string> &names, axes_handle ax)
4141
: lat_(lat), lon_(lon), names_(names), ax_(ax) {}
4242

43-
void eurotrip_solver::run(int iterations) {
43+
void eurotrip_solver::run(size_t iterations) {
4444
for (size_t i = 0; i < iterations; ++i) {
4545
setup_starting_point(i);
4646
iteration();

examples/geography/geoplot/geoplot_7.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class americas_trip_solver {
88
public:
99
americas_trip_solver(const vector<double> &lat, const vector<double> &lon,
1010
const vector<string> &names, axes_handle ax);
11-
void run(int iterations = 100);
11+
void run(size_t iterations = 100);
1212

1313
private:
1414
void setup_axes();
@@ -45,7 +45,7 @@ americas_trip_solver::americas_trip_solver(const vector<double> &lat,
4545
setup_axes();
4646
}
4747

48-
void americas_trip_solver::run(int iterations) {
48+
void americas_trip_solver::run(size_t iterations) {
4949
for (size_t i = 0; i < iterations; ++i) {
5050
setup_starting_point(i);
5151
iteration();

0 commit comments

Comments
 (0)