Lazily initialize the bounds arrays in ParameterBlock.

Problems that do not use bounds do not have to pay the
price of storing bounds constraints.

Also replace the raw pointer access to the upper and
lower bounds arrays with accessors which hides the
lazy initialization from the user.

Change-Id: I0325a35de9c29f853559f891e32e7c777686e537
diff --git a/internal/ceres/parameter_block_test.cc b/internal/ceres/parameter_block_test.cc
index a76c408..5a2db3c 100644
--- a/internal/ceres/parameter_block_test.cc
+++ b/internal/ceres/parameter_block_test.cc
@@ -172,26 +172,29 @@
 TEST(ParameterBlock, DefaultBounds) {
   double x[2];
   ParameterBlock parameter_block(x, 2, -1, NULL);
-  const double* upper_bounds = parameter_block.upper_bounds();
-  EXPECT_EQ(upper_bounds[0], std::numeric_limits<double>::max());
-  EXPECT_EQ(upper_bounds[1], std::numeric_limits<double>::max());
-  const double* lower_bounds = parameter_block.lower_bounds();
-  EXPECT_EQ(lower_bounds[0], -std::numeric_limits<double>::max());
-  EXPECT_EQ(lower_bounds[1], -std::numeric_limits<double>::max());
+  EXPECT_EQ(parameter_block.UpperBoundForParameter(0),
+            std::numeric_limits<double>::max());
+  EXPECT_EQ(parameter_block.UpperBoundForParameter(1),
+            std::numeric_limits<double>::max());
+  EXPECT_EQ(parameter_block.LowerBoundForParameter(0),
+            -std::numeric_limits<double>::max());
+  EXPECT_EQ(parameter_block.LowerBoundForParameter(1),
+            -std::numeric_limits<double>::max());
 }
 
 TEST(ParameterBlock, SetBounds) {
   double x[2];
   ParameterBlock parameter_block(x, 2, -1, NULL);
-  parameter_block.SetUpperBound(1, 1);
   parameter_block.SetLowerBound(0, 1);
+  parameter_block.SetUpperBound(1, 1);
 
-  const double* upper_bounds = parameter_block.upper_bounds();
-  EXPECT_EQ(upper_bounds[0], std::numeric_limits<double>::max());
-  EXPECT_EQ(upper_bounds[1], 1.0);
-  const double* lower_bounds = parameter_block.lower_bounds();
-  EXPECT_EQ(lower_bounds[0], 1.0);
-  EXPECT_EQ(lower_bounds[1], -std::numeric_limits<double>::max());
+  EXPECT_EQ(parameter_block.LowerBoundForParameter(0), 1.0);
+  EXPECT_EQ(parameter_block.LowerBoundForParameter(1),
+            -std::numeric_limits<double>::max());
+
+  EXPECT_EQ(parameter_block.UpperBoundForParameter(0),
+            std::numeric_limits<double>::max());
+  EXPECT_EQ(parameter_block.UpperBoundForParameter(1), 1.0);
 }
 
 TEST(ParameterBlock, PlusWithBoundsConstraints) {