Delete Incomplete LQ Factorization.

This code never got expanded into a full preconditioner. No point
keeping dead code around.

Change-Id: I45badcd9e5f7eb39e8d288a96c65a02f325d76bd
diff --git a/internal/ceres/CMakeLists.txt b/internal/ceres/CMakeLists.txt
index 1472e65..f9bb9d0 100644
--- a/internal/ceres/CMakeLists.txt
+++ b/internal/ceres/CMakeLists.txt
@@ -67,7 +67,6 @@
     gradient_problem.cc
     gradient_problem_solver.cc
     implicit_schur_complement.cc
-    incomplete_lq_factorization.cc
     iterative_schur_complement_solver.cc
     levenberg_marquardt_strategy.cc
     lapack.cc
@@ -261,7 +260,6 @@
   CERES_TEST(graph)
   CERES_TEST(graph_algorithms)
   CERES_TEST(implicit_schur_complement)
-  CERES_TEST(incomplete_lq_factorization)
   CERES_TEST(iterative_schur_complement_solver)
   CERES_TEST(jet)
   CERES_TEST(levenberg_marquardt_strategy)
diff --git a/internal/ceres/incomplete_lq_factorization.cc b/internal/ceres/incomplete_lq_factorization.cc
deleted file mode 100644
index 6ba38ec..0000000
--- a/internal/ceres/incomplete_lq_factorization.cc
+++ /dev/null
@@ -1,239 +0,0 @@
-// Ceres Solver - A fast non-linear least squares minimizer
-// Copyright 2013 Google Inc. All rights reserved.
-// http://code.google.com/p/ceres-solver/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
-//   this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright notice,
-//   this list of conditions and the following disclaimer in the documentation
-//   and/or other materials provided with the distribution.
-// * Neither the name of Google Inc. nor the names of its contributors may be
-//   used to endorse or promote products derived from this software without
-//   specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: sameeragarwal@google.com (Sameer Agarwal)
-
-#include "ceres/incomplete_lq_factorization.h"
-
-#include <vector>
-#include <utility>
-#include <cmath>
-#include "ceres/compressed_row_sparse_matrix.h"
-#include "ceres/internal/eigen.h"
-#include "ceres/internal/port.h"
-#include "glog/logging.h"
-
-namespace ceres {
-namespace internal {
-
-// Normalize a row and return it's norm.
-inline double NormalizeRow(const int row, CompressedRowSparseMatrix* matrix) {
-  const int row_begin =  matrix->rows()[row];
-  const int row_end = matrix->rows()[row + 1];
-
-  double* values = matrix->mutable_values();
-  double norm = 0.0;
-  for (int i =  row_begin; i < row_end; ++i) {
-    norm += values[i] * values[i];
-  }
-
-  norm = sqrt(norm);
-  const double inverse_norm = 1.0 / norm;
-  for (int i = row_begin; i < row_end; ++i) {
-    values[i] *= inverse_norm;
-  }
-
-  return norm;
-}
-
-// Compute a(row_a,:) * b(row_b, :)'
-inline double RowDotProduct(const CompressedRowSparseMatrix& a,
-                            const int row_a,
-                            const CompressedRowSparseMatrix& b,
-                            const int row_b) {
-  const int* a_rows = a.rows();
-  const int* a_cols = a.cols();
-  const double* a_values = a.values();
-
-  const int* b_rows = b.rows();
-  const int* b_cols = b.cols();
-  const double* b_values = b.values();
-
-  const int row_a_end = a_rows[row_a + 1];
-  const int row_b_end = b_rows[row_b + 1];
-
-  int idx_a = a_rows[row_a];
-  int idx_b = b_rows[row_b];
-  double dot_product = 0.0;
-  while (idx_a < row_a_end && idx_b < row_b_end) {
-    if (a_cols[idx_a] == b_cols[idx_b]) {
-      dot_product += a_values[idx_a++] * b_values[idx_b++];
-    }
-
-    while (a_cols[idx_a] < b_cols[idx_b] && idx_a < row_a_end) {
-      ++idx_a;
-    }
-
-    while (a_cols[idx_a] > b_cols[idx_b] && idx_b < row_b_end) {
-      ++idx_b;
-    }
-  }
-
-  return dot_product;
-}
-
-struct SecondGreaterThan {
- public:
-  bool operator()(const pair<int, double>& lhs,
-                  const pair<int, double>& rhs) const {
-    return (fabs(lhs.second) > fabs(rhs.second));
-  }
-};
-
-// In the row vector dense_row(0:num_cols), drop values smaller than
-// the max_value * drop_tolerance. Of the remaining non-zero values,
-// choose at most level_of_fill values and then add the resulting row
-// vector to matrix.
-
-void DropEntriesAndAddRow(const Vector& dense_row,
-                          const int num_entries,
-                          const int level_of_fill,
-                          const double drop_tolerance,
-                          vector<pair<int, double> >* scratch,
-                          CompressedRowSparseMatrix* matrix) {
-  int* rows = matrix->mutable_rows();
-  int* cols = matrix->mutable_cols();
-  double* values = matrix->mutable_values();
-  int num_nonzeros = rows[matrix->num_rows()];
-
-  if (num_entries == 0) {
-    matrix->set_num_rows(matrix->num_rows() + 1);
-    rows[matrix->num_rows()] = num_nonzeros;
-    return;
-  }
-
-  const double max_value = dense_row.head(num_entries).cwiseAbs().maxCoeff();
-  const double threshold = drop_tolerance * max_value;
-
-  int scratch_count = 0;
-  for (int i = 0; i < num_entries; ++i) {
-    if (fabs(dense_row[i]) > threshold) {
-      pair<int, double>& entry = (*scratch)[scratch_count];
-      entry.first = i;
-      entry.second = dense_row[i];
-      ++scratch_count;
-    }
-  }
-
-  if (scratch_count > level_of_fill) {
-    nth_element(scratch->begin(),
-                scratch->begin() + level_of_fill,
-                scratch->begin() + scratch_count,
-                SecondGreaterThan());
-    scratch_count = level_of_fill;
-    sort(scratch->begin(), scratch->begin() + scratch_count);
-  }
-
-  for (int i = 0; i < scratch_count; ++i) {
-    const pair<int, double>& entry = (*scratch)[i];
-    cols[num_nonzeros] = entry.first;
-    values[num_nonzeros] = entry.second;
-    ++num_nonzeros;
-  }
-
-  matrix->set_num_rows(matrix->num_rows() + 1);
-  rows[matrix->num_rows()] = num_nonzeros;
-}
-
-// Saad's Incomplete LQ factorization algorithm.
-CompressedRowSparseMatrix* IncompleteLQFactorization(
-    const CompressedRowSparseMatrix& matrix,
-    const int l_level_of_fill,
-    const double l_drop_tolerance,
-    const int q_level_of_fill,
-    const double q_drop_tolerance) {
-  const int num_rows = matrix.num_rows();
-  const int num_cols = matrix.num_cols();
-  const int* rows = matrix.rows();
-  const int* cols = matrix.cols();
-  const double* values = matrix.values();
-
-  CompressedRowSparseMatrix* l =
-      new CompressedRowSparseMatrix(num_rows,
-                                    num_rows,
-                                    l_level_of_fill * num_rows);
-  l->set_num_rows(0);
-
-  CompressedRowSparseMatrix q(num_rows, num_cols, q_level_of_fill * num_rows);
-  q.set_num_rows(0);
-
-  int* l_rows = l->mutable_rows();
-  int* l_cols = l->mutable_cols();
-  double* l_values = l->mutable_values();
-
-  int* q_rows = q.mutable_rows();
-  int* q_cols = q.mutable_cols();
-  double* q_values = q.mutable_values();
-
-  Vector l_i(num_rows);
-  Vector q_i(num_cols);
-  vector<pair<int, double> > scratch(num_cols);
-  for (int i = 0; i < num_rows; ++i) {
-    // l_i = q * matrix(i,:)');
-    l_i.setZero();
-    for (int j = 0; j < i; ++j) {
-      l_i(j) = RowDotProduct(matrix, i, q, j);
-    }
-    DropEntriesAndAddRow(l_i,
-                         i,
-                         l_level_of_fill,
-                         l_drop_tolerance,
-                         &scratch,
-                         l);
-
-    // q_i = matrix(i,:) - q(0:i-1,:) * l_i);
-    q_i.setZero();
-    for (int idx = rows[i]; idx < rows[i + 1]; ++idx) {
-      q_i(cols[idx]) = values[idx];
-    }
-
-    for (int j = l_rows[i]; j < l_rows[i + 1]; ++j) {
-      const int r = l_cols[j];
-      const double lij = l_values[j];
-      for (int idx = q_rows[r]; idx < q_rows[r + 1]; ++idx) {
-        q_i(q_cols[idx]) -= lij * q_values[idx];
-      }
-    }
-    DropEntriesAndAddRow(q_i,
-                         num_cols,
-                         q_level_of_fill,
-                         q_drop_tolerance,
-                         &scratch,
-                         &q);
-
-    // lii = |qi|
-    l_cols[l->num_nonzeros()] = i;
-    l_values[l->num_nonzeros()] = NormalizeRow(i, &q);
-    l_rows[l->num_rows()] += 1;
-  }
-
-  return l;
-}
-
-}  // namespace internal
-}  // namespace ceres
diff --git a/internal/ceres/incomplete_lq_factorization.h b/internal/ceres/incomplete_lq_factorization.h
deleted file mode 100644
index e678463..0000000
--- a/internal/ceres/incomplete_lq_factorization.h
+++ /dev/null
@@ -1,90 +0,0 @@
-// Ceres Solver - A fast non-linear least squares minimizer
-// Copyright 2013 Google Inc. All rights reserved.
-// http://code.google.com/p/ceres-solver/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
-//   this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright notice,
-//   this list of conditions and the following disclaimer in the documentation
-//   and/or other materials provided with the distribution.
-// * Neither the name of Google Inc. nor the names of its contributors may be
-//   used to endorse or promote products derived from this software without
-//   specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: sameeragarwal@google.com (Sameer Agarwal)
-
-#ifndef CERES_INTERNAL_INCOMPLETE_LQ_FACTORIZATION_H_
-#define CERES_INTERNAL_INCOMPLETE_LQ_FACTORIZATION_H_
-
-#include <vector>
-#include <utility>
-#include "ceres/compressed_row_sparse_matrix.h"
-
-namespace ceres {
-namespace internal {
-
-// Incomplete LQ factorization as described in
-//
-// Preconditioning techniques for indefinite and nonsymmetric linear
-// systems. Yousef Saad, Preprint RIACS-ILQ-TR, RIACS, NASA Ames
-// Research Center, Moffett Field, CA, 1987.
-//
-// An incomplete LQ factorization of a matrix A is a decomposition
-//
-//   A = LQ + E
-//
-// Where L is a lower triangular matrix, and Q is a near orthonormal
-// matrix. The extent of orthonormality depends on E. E is the "drop"
-// matrix. Each row of L has a maximum of l_level_of_fill entries, and
-// all non-zero entries are within l_drop_tolerance of the largest
-// entry. Each row of Q has a maximum of q_level_of_fill entries and
-// all non-zero entries are within q_drop_tolerance of the largest
-// entry.
-//
-// E is the error of the incomplete factorization.
-//
-// The purpose of incomplete factorizations is preconditioning and
-// there one only needs the L matrix, therefore this function just
-// returns L.
-//
-// Caller owns the result.
-CompressedRowSparseMatrix* IncompleteLQFactorization(
-    const CompressedRowSparseMatrix& matrix,
-    const int l_level_of_fill,
-    const double l_drop_tolerance,
-    const int q_level_of_fill,
-    const double q_drop_tolerance);
-
-// In the row vector dense_row(0:num_cols), drop values smaller than
-// the max_value * drop_tolerance. Of the remaining non-zero values,
-// choose at most level_of_fill values and then add the resulting row
-// vector to matrix.
-//
-// scratch is used to prevent allocations inside this function. It is
-// assumed that scratch is of size matrix->num_cols().
-void DropEntriesAndAddRow(const Vector& dense_row,
-                          const int num_entries,
-                          const int level_of_fill,
-                          const double drop_tolerance,
-                          vector<pair<int, double> >* scratch,
-                          CompressedRowSparseMatrix* matrix);
-
-}  // namespace internal
-}  // namespace ceres
-
-#endif  // CERES_INTERNAL_INCOMPLETE_LQ_FACTORIZATION_H_
diff --git a/internal/ceres/incomplete_lq_factorization_test.cc b/internal/ceres/incomplete_lq_factorization_test.cc
deleted file mode 100644
index 1ed181f..0000000
--- a/internal/ceres/incomplete_lq_factorization_test.cc
+++ /dev/null
@@ -1,198 +0,0 @@
-// Ceres Solver - A fast non-linear least squares minimizer
-// Copyright 2013 Google Inc. All rights reserved.
-// http://code.google.com/p/ceres-solver/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
-//   this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright notice,
-//   this list of conditions and the following disclaimer in the documentation
-//   and/or other materials provided with the distribution.
-// * Neither the name of Google Inc. nor the names of its contributors may be
-//   used to endorse or promote products derived from this software without
-//   specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: sameeragarwal@google.com (Sameer Agarwal)
-
-#include "ceres/incomplete_lq_factorization.h"
-
-#include "Eigen/Dense"
-#include "ceres/compressed_row_sparse_matrix.h"
-#include "ceres/internal/scoped_ptr.h"
-#include "glog/logging.h"
-#include "gtest/gtest.h"
-
-namespace ceres {
-namespace internal {
-
-void ExpectMatricesAreEqual(const CompressedRowSparseMatrix& expected,
-                            const CompressedRowSparseMatrix& actual,
-                            const double tolerance) {
-  EXPECT_EQ(expected.num_rows(), actual.num_rows());
-  EXPECT_EQ(expected.num_cols(), actual.num_cols());
-  for (int i = 0; i < expected.num_rows(); ++i) {
-    EXPECT_EQ(expected.rows()[i], actual.rows()[i]);
-  }
-
-  for (int i = 0; i < actual.num_nonzeros(); ++i) {
-    EXPECT_EQ(expected.cols()[i], actual.cols()[i]);
-    EXPECT_NEAR(expected.values()[i], actual.values()[i], tolerance);
-  }
-}
-
-TEST(IncompleteQRFactorization, OneByOneMatrix) {
-  CompressedRowSparseMatrix matrix(1, 1, 1);
-  matrix.mutable_rows()[0] = 0;
-  matrix.mutable_rows()[1] = 1;
-  matrix.mutable_cols()[0] = 0;
-  matrix.mutable_values()[0] = 2;
-
-  scoped_ptr<CompressedRowSparseMatrix> l(
-      IncompleteLQFactorization(matrix, 1, 0.0, 1, 0.0));
-  ExpectMatricesAreEqual(matrix, *l, 1e-16);
-}
-
-TEST(IncompleteLQFactorization, CompleteFactorization) {
-  double dense_matrix[] = {
-    0.00000,  0.00000,  0.20522,  0.00000,  0.49077,  0.92835,  0.00000,  0.83825,  0.00000,  0.00000,  // NOLINT
-    0.00000,  0.00000,  0.00000,  0.62491,  0.38144,  0.00000,  0.79394,  0.79178,  0.00000,  0.44382,  // NOLINT
-    0.00000,  0.00000,  0.00000,  0.61517,  0.55941,  0.00000,  0.00000,  0.00000,  0.00000,  0.60664,  // NOLINT
-    0.00000,  0.00000,  0.00000,  0.00000,  0.45031,  0.00000,  0.64132,  0.00000,  0.38832,  0.00000,  // NOLINT
-    0.00000,  0.00000,  0.00000,  0.00000,  0.00000,  0.57121,  0.00000,  0.01375,  0.70640,  0.00000,  // NOLINT
-    0.00000,  0.00000,  0.07451,  0.00000,  0.00000,  0.00000,  0.00000,  0.00000,  0.00000,  0.00000,  // NOLINT
-    0.68095,  0.00000,  0.00000,  0.95473,  0.00000,  0.00000,  0.00000,  0.00000,  0.00000,  0.00000,  // NOLINT
-    0.00000,  0.00000,  0.00000,  0.00000,  0.59374,  0.00000,  0.00000,  0.00000,  0.49139,  0.00000,  // NOLINT
-    0.91276,  0.96641,  0.00000,  0.00000,  0.00000,  0.00000,  0.00000,  0.00000,  0.00000,  0.91797,  // NOLINT
-    0.96828,  0.00000,  0.00000,  0.72583,  0.00000,  0.00000,  0.81459,  0.00000,  0.04560,  0.00000   // NOLINT
-  };
-
-  CompressedRowSparseMatrix matrix(10, 10, 100);
-  int* rows = matrix.mutable_rows();
-  int* cols = matrix.mutable_cols();
-  double* values = matrix.mutable_values();
-
-  int idx = 0;
-  for (int i = 0; i < 10; ++i) {
-    rows[i] = idx;
-    for (int j = 0; j < 10; ++j) {
-      const double v = dense_matrix[i * 10 + j];
-      if (fabs(v) > 1e-6) {
-        cols[idx] = j;
-        values[idx] = v;
-        ++idx;
-      }
-    }
-  }
-  rows[10] = idx;
-
-  scoped_ptr<CompressedRowSparseMatrix> lmatrix(
-      IncompleteLQFactorization(matrix, 10, 0.0, 10, 0.0));
-
-  ConstMatrixRef mref(dense_matrix, 10, 10);
-
-  // Use Cholesky factorization to compute the L matrix.
-  Matrix expected_l_matrix  = (mref * mref.transpose()).llt().matrixL();
-  Matrix actual_l_matrix;
-  lmatrix->ToDenseMatrix(&actual_l_matrix);
-
-  EXPECT_NEAR((expected_l_matrix * expected_l_matrix.transpose() -
-               actual_l_matrix * actual_l_matrix.transpose()).norm(),
-              0.0,
-              1e-10)
-      << "expected: \n" << expected_l_matrix
-      << "\actual: \n" << actual_l_matrix;
-}
-
-TEST(IncompleteLQFactorization, DropEntriesAndAddRow) {
-  // Allocate space and then make it a zero sized matrix.
-  CompressedRowSparseMatrix matrix(10, 10, 100);
-  matrix.set_num_rows(0);
-
-  vector<pair<int, double> > scratch(10);
-
-  Vector dense_vector(10);
-  dense_vector(0) = 5;
-  dense_vector(1) = 1;
-  dense_vector(2) = 2;
-  dense_vector(3) = 3;
-  dense_vector(4) = 1;
-  dense_vector(5) = 4;
-
-  // Add a row with just one entry.
-  DropEntriesAndAddRow(dense_vector, 1, 1, 0, &scratch, &matrix);
-  EXPECT_EQ(matrix.num_rows(), 1);
-  EXPECT_EQ(matrix.num_cols(), 10);
-  EXPECT_EQ(matrix.num_nonzeros(), 1);
-  EXPECT_EQ(matrix.values()[0], 5.0);
-  EXPECT_EQ(matrix.cols()[0], 0);
-
-  // Add a row with six entries
-  DropEntriesAndAddRow(dense_vector, 6, 10, 0, &scratch, &matrix);
-  EXPECT_EQ(matrix.num_rows(), 2);
-  EXPECT_EQ(matrix.num_cols(), 10);
-  EXPECT_EQ(matrix.num_nonzeros(), 7);
-  for (int idx = matrix.rows()[1]; idx < matrix.rows()[2]; ++idx) {
-    EXPECT_EQ(matrix.cols()[idx], idx - matrix.rows()[1]);
-    EXPECT_EQ(matrix.values()[idx], dense_vector(idx - matrix.rows()[1]));
-  }
-
-  // Add the top 3 entries.
-  DropEntriesAndAddRow(dense_vector, 6, 3, 0, &scratch, &matrix);
-  EXPECT_EQ(matrix.num_rows(), 3);
-  EXPECT_EQ(matrix.num_cols(), 10);
-  EXPECT_EQ(matrix.num_nonzeros(), 10);
-
-  EXPECT_EQ(matrix.cols()[matrix.rows()[2]], 0);
-  EXPECT_EQ(matrix.cols()[matrix.rows()[2] + 1], 3);
-  EXPECT_EQ(matrix.cols()[matrix.rows()[2] + 2], 5);
-
-  EXPECT_EQ(matrix.values()[matrix.rows()[2]], 5);
-  EXPECT_EQ(matrix.values()[matrix.rows()[2] + 1], 3);
-  EXPECT_EQ(matrix.values()[matrix.rows()[2] + 2], 4);
-
-  // Only keep entries greater than 1.0;
-  DropEntriesAndAddRow(dense_vector, 6, 6, 0.2, &scratch, &matrix);
-  EXPECT_EQ(matrix.num_rows(), 4);
-  EXPECT_EQ(matrix.num_cols(), 10);
-  EXPECT_EQ(matrix.num_nonzeros(), 14);
-
-  EXPECT_EQ(matrix.cols()[matrix.rows()[3]], 0);
-  EXPECT_EQ(matrix.cols()[matrix.rows()[3] + 1], 2);
-  EXPECT_EQ(matrix.cols()[matrix.rows()[3] + 2], 3);
-  EXPECT_EQ(matrix.cols()[matrix.rows()[3] + 3], 5);
-
-  EXPECT_EQ(matrix.values()[matrix.rows()[3]], 5);
-  EXPECT_EQ(matrix.values()[matrix.rows()[3] + 1], 2);
-  EXPECT_EQ(matrix.values()[matrix.rows()[3] + 2], 3);
-  EXPECT_EQ(matrix.values()[matrix.rows()[3] + 3], 4);
-
-  // Only keep the top 2 entries greater than 1.0
-  DropEntriesAndAddRow(dense_vector, 6, 2, 0.2, &scratch, &matrix);
-  EXPECT_EQ(matrix.num_rows(), 5);
-  EXPECT_EQ(matrix.num_cols(), 10);
-  EXPECT_EQ(matrix.num_nonzeros(), 16);
-
-  EXPECT_EQ(matrix.cols()[matrix.rows()[4]], 0);
-  EXPECT_EQ(matrix.cols()[matrix.rows()[4] + 1], 5);
-
-  EXPECT_EQ(matrix.values()[matrix.rows()[4]], 5);
-  EXPECT_EQ(matrix.values()[matrix.rows()[4] + 1], 4);
-}
-
-
-}  // namespace internal
-}  // namespace ceres