Removing -Wshorten-64-to-32 warnings from examples (part 1)

Change-Id: I3cdacc8306c1d1a07420d7171e18726a5bef0012
diff --git a/examples/bal_problem.cc b/examples/bal_problem.cc
index c784116..182a288 100644
--- a/examples/bal_problem.cc
+++ b/examples/bal_problem.cc
@@ -62,8 +62,7 @@
 }
 
 double Median(std::vector<double>* data) {
-  int n = data->size();
-  auto mid_point = data->begin() + n / 2;
+  auto mid_point = data->begin() + data->size() / 2;
   std::nth_element(data->begin(), mid_point, data->end());
   return *mid_point;
 }
diff --git a/examples/ellipse_approximation.cc b/examples/ellipse_approximation.cc
index c549ffb..a0b0e71 100644
--- a/examples/ellipse_approximation.cc
+++ b/examples/ellipse_approximation.cc
@@ -405,9 +405,9 @@
   // Each data point has an associated preimage position on the line segment
   // contour. For each data point we initialize the preimage positions to
   // the index of the closest control point.
-  const int num_observations = kY.rows();
+  const int64_t num_observations = kY.rows();
   VectorXd t(num_observations);
-  for (int i = 0; i < num_observations; ++i) {
+  for (int64_t i = 0; i < num_observations; ++i) {
     (X.rowwise() - kY.row(i)).rowwise().squaredNorm().minCoeff(&t[i]);
   }
 
diff --git a/examples/fields_of_experts.cc b/examples/fields_of_experts.cc
index 01fa17a..c2f5d52 100644
--- a/examples/fields_of_experts.cc
+++ b/examples/fields_of_experts.cc
@@ -43,7 +43,7 @@
 FieldsOfExpertsCost::FieldsOfExpertsCost(const std::vector<double>& filter)
     : filter_(filter) {
   set_num_residuals(1);
-  for (int i = 0; i < filter_.size(); ++i) {
+  for (int64_t i = 0; i < filter_.size(); ++i) {
     mutable_parameter_block_sizes()->push_back(1);
   }
 }
@@ -53,14 +53,14 @@
 bool FieldsOfExpertsCost::Evaluate(double const* const* parameters,
                                    double* residuals,
                                    double** jacobians) const {
-  int num_variables = filter_.size();
+  const int64_t num_variables = filter_.size();
   residuals[0] = 0;
-  for (int i = 0; i < num_variables; ++i) {
+  for (int64_t i = 0; i < num_variables; ++i) {
     residuals[0] += filter_[i] * parameters[i][0];
   }
 
   if (jacobians != nullptr) {
-    for (int i = 0; i < num_variables; ++i) {
+    for (int64_t i = 0; i < num_variables; ++i) {
       if (jacobians[i] != nullptr) {
         jacobians[i][0] = filter_[i];
       }
diff --git a/examples/libmv_homography.cc b/examples/libmv_homography.cc
index 7bfcd8b..f3f70f4 100644
--- a/examples/libmv_homography.cc
+++ b/examples/libmv_homography.cc
@@ -203,11 +203,11 @@
   assert(x1.rows() == x2.rows());
   assert(x1.cols() == x2.cols());
 
-  int n = x1.cols();
+  const int64_t n = x1.cols();
   MatX8 L = Mat::Zero(n * 3, 8);
   Mat b = Mat::Zero(n * 3, 1);
-  for (int i = 0; i < n; ++i) {
-    int j = 3 * i;
+  for (int64_t i = 0; i < n; ++i) {
+    int64_t j = 3 * i;
     L(j, 0) = x1(0, i);              // a
     L(j, 1) = x1(1, i);              // b
     L(j, 2) = 1.0;                   // c