Multithread DENSE_SCHUR

Replace the global lock in BlockRandomAccessDenseMatrix
with a per cell lock.

Change-Id: Iddbe38616157b6e0d3770eede3335a056c3ba18c
diff --git a/internal/ceres/block_random_access_dense_matrix.cc b/internal/ceres/block_random_access_dense_matrix.cc
index aedfc74..e582279 100644
--- a/internal/ceres/block_random_access_dense_matrix.cc
+++ b/internal/ceres/block_random_access_dense_matrix.cc
@@ -40,16 +40,21 @@
 
 BlockRandomAccessDenseMatrix::BlockRandomAccessDenseMatrix(
     const vector<int>& blocks) {
-  block_layout_.resize(blocks.size(), 0);
+  const int num_blocks = blocks.size();
+  block_layout_.resize(num_blocks, 0);
   num_rows_ = 0;
-  for (int i = 0; i < blocks.size(); ++i) {
+  for (int i = 0; i < num_blocks; ++i) {
     block_layout_[i] = num_rows_;
     num_rows_ += blocks[i];
   }
 
   values_.reset(new double[num_rows_ * num_rows_]);
-  CHECK_NOTNULL(values_.get());
-  cell_info_.values = values_.get();
+
+  cell_infos_.reset(new CellInfo[num_blocks * num_blocks]);
+  for (int i = 0; i < num_blocks * num_blocks; ++i) {
+    cell_infos_[i].values = values_.get();
+  }
+
   SetZero();
 }
 
@@ -68,7 +73,7 @@
   *col = block_layout_[col_block_id];
   *row_stride = num_rows_;
   *col_stride = num_rows_;
-  return &cell_info_;
+  return &cell_infos_[row_block_id * block_layout_.size() + col_block_id];
 }
 
 // Assume that the user does not hold any locks on any cell blocks