ITERATIVE_SCHUR works with no f-blocks.

When the Schur complement is of size zero,
i.e. none of the parameter blocks interact
with each other, the ITERATIVE_SCHUR linear
solver crashes due to some checks that are
triggered in the SCHUR_JACOBI preconditioner.

This patch adds logic to detect this condition
and to deal with it and adds tests that verify
the fix.

Thanks to Soohyun Bae for reporting this bug.

Change-Id: If29ddf32463cbb1960414fff0e29bbf0d2ee7989
diff --git a/internal/ceres/iterative_schur_complement_solver_test.cc b/internal/ceres/iterative_schur_complement_solver_test.cc
index 86e7825..db45741 100644
--- a/internal/ceres/iterative_schur_complement_solver_test.cc
+++ b/internal/ceres/iterative_schur_complement_solver_test.cc
@@ -58,9 +58,9 @@
 
 class IterativeSchurComplementSolverTest : public ::testing::Test {
  protected :
-  virtual void SetUp() {
+  void SetUpProblem(int problem_id) {
     scoped_ptr<LinearLeastSquaresProblem> problem(
-        CreateLinearLeastSquaresProblemFromId(2));
+        CreateLinearLeastSquaresProblemFromId(problem_id));
 
     CHECK_NOTNULL(problem.get());
     A_.reset(down_cast<BlockSparseMatrix*>(problem->A.release()));
@@ -90,7 +90,9 @@
     qr->Solve(&dense_A, b_.get(), per_solve_options, reference_solution.data());
 
     options.elimination_groups.push_back(num_eliminate_blocks_);
+    options.elimination_groups.push_back(0);
     options.max_num_iterations = num_cols_;
+    options.preconditioner_type = SCHUR_JACOBI;
     IterativeSchurComplementSolver isc(options);
 
     Vector isc_sol(num_cols_);
@@ -114,7 +116,14 @@
   scoped_array<double> D_;
 };
 
-TEST_F(IterativeSchurComplementSolverTest, SolverTest) {
+TEST_F(IterativeSchurComplementSolverTest, NormalProblem) {
+  SetUpProblem(2);
+  EXPECT_TRUE(TestSolver(NULL));
+  EXPECT_TRUE(TestSolver(D_.get()));
+}
+
+TEST_F(IterativeSchurComplementSolverTest, ProblemWithNoFBlocks) {
+  SetUpProblem(3);
   EXPECT_TRUE(TestSolver(NULL));
   EXPECT_TRUE(TestSolver(D_.get()));
 }