This file is indexed.

/usr/include/CGAL/Eigen_matrix.h is in libcgal-dev 4.2-5ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
// Copyright (c) 2012  INRIA Bordeaux Sud-Ouest (France), All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
// Author(s)     : Gael Guennebaud

#ifndef CGAL_EIGEN_MATRIX_H
#define CGAL_EIGEN_MATRIX_H

#include <CGAL/basic.h> // include basic.h before testing #defines

#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
#include <Eigen/Sparse>

namespace CGAL {


/// The class Eigen_sparse_matrix
/// is a C++ wrapper around Eigen' matrix type SparseMatrix<>.
///
/// This kind of matrix can be either symmetric or not. Symmetric
/// matrices store only the lower triangle.
///
/// @heading Is Model for the Concepts: Model of the SparseLinearAlgebraTraits_d::Matrix concept.
///
/// @heading Parameters:
/// @param T Number type.

template<class T>
struct Eigen_sparse_matrix
{
// Public types
public:

  typedef Eigen::SparseMatrix<T> EigenType;
  typedef T NT;

// Public operations
public:

  /// Create a square matrix initialized with zeros.
  Eigen_sparse_matrix(int  dim,                   ///< Matrix dimension.
                      bool is_symmetric = false)  ///< Symmetric/hermitian?
    : m_is_already_built(false), m_matrix(dim,dim)
  {
    CGAL_precondition(dim > 0);

    m_is_symmetric = is_symmetric;
    // reserve memory for a regular 3D grid
    m_triplets.reserve(dim);
  }

  /// Create a rectangular matrix initialized with zeros.
  ///
  /// @commentheading Precondition: rows == columns if is_symmetric is true.
  Eigen_sparse_matrix(int  rows,                 ///< Number of rows.
                      int  columns,              ///< Number of columns.
                      bool is_symmetric = false) ///< Symmetric/hermitian?
    : m_is_already_built(false), m_matrix(rows,columns)
  {
    CGAL_precondition(rows > 0);
    CGAL_precondition(columns > 0);
    if (m_is_symmetric) {
        CGAL_precondition(rows == columns);
    }

    m_is_symmetric = is_symmetric;
    // reserve memory for a regular 3D grid
    m_triplets.reserve(rows);
  }

  /// Delete this object and the wrapped TAUCS matrix.
  ~Eigen_sparse_matrix()
  {
  }

  /// Return the matrix number of rows
  int row_dimension() const    { return m_matrix.rows(); }
  /// Return the matrix number of columns
  int column_dimension() const { return m_matrix.cols(); }


  /// Write access to a matrix coefficient: a_ij <- val.
  ///
  /// Optimizations:
  /// - For symmetric matrices, Eigen_sparse_matrix stores only the lower triangle
  ///   set_coef() does nothing if (i, j) belongs to the upper triangle.
  /// - Caller can optimize this call by setting 'new_coef' to true
  ///   if the coefficient does not already exist in the matrix.
  ///
  /// @commentheading Preconditions:
  /// - 0 <= i < row_dimension().
  /// - 0 <= j < column_dimension().
  void set_coef(int i, int j, T  val, bool new_coef = false)
  {
    CGAL_precondition(i < row_dimension());
    CGAL_precondition(j < column_dimension());

    if (m_is_symmetric && (j > i))
      return;

    if (m_is_already_built)
      m_matrix.coeffRef(i,j)=val;
    else
    {
      if ( new_coef == false )
      {
        assemble_matrix();
        m_matrix.coeffRef(i,j)=val;
      }
      else
        m_triplets.push_back(Triplet(i,j,val));
    }
  }

  /// Write access to a matrix coefficient: a_ij <- a_ij+val.
  ///
  /// Optimizations:
  /// - For symmetric matrices, Eigen_sparse_matrix stores only the lower triangle
  ///   add_coef() does nothing if (i, j) belongs to the upper triangle.
  ///
  /// @commentheading Preconditions:
  /// - 0 <= i < row_dimension().
  /// - 0 <= j < column_dimension().
  void add_coef(int i, int j, T  val)
  {
    CGAL_precondition(i < row_dimension());
    CGAL_precondition(j < column_dimension());

    if (m_is_symmetric && (j > i))
      return;

    if (m_is_already_built)
      m_matrix.coeffRef(i,j)+=val;
    else
      m_triplets.push_back(Triplet(i,j,val));
  }

  void assemble_matrix() const
  {
    m_matrix.setFromTriplets(m_triplets.begin(), m_triplets.end());
    m_is_already_built = true;
    m_triplets.clear(); //the matrix is built and will not be rebuilt
  }

  const EigenType& eigen_object() const
  {
    if(!m_is_already_built) assemble_matrix();

    // turns the matrix into compressed mode:
    //  -> release some memory
    //  -> required for some external solvers
    m_matrix.makeCompressed();
    return m_matrix;
  }

private:


  /// Eigen_sparse_matrix cannot be copied (yet)
  Eigen_sparse_matrix(const Eigen_sparse_matrix& rhs);
  Eigen_sparse_matrix& operator=(const Eigen_sparse_matrix& rhs);

// Fields
private:
  
  mutable bool m_is_already_built;
  typedef Eigen::Triplet<T,int> Triplet;
  mutable std::vector<Triplet> m_triplets;

  mutable EigenType m_matrix;

  // Symmetric/hermitian?
  bool m_is_symmetric;

}; // Eigen_sparse_matrix



/// The class Eigen_sparse_symmetric_matrix is a C++ wrapper
/// around a Eigen sparse matrix (type Eigen::SparseMatrix).
///
/// Symmetric matrices store only the lower triangle.
///
/// @heading Is Model for the Concepts: Model of the SparseLinearAlgebraTraits_d::Matrix concept.
///
/// @heading Parameters:
/// @param T Number type.

template<class T>
struct Eigen_sparse_symmetric_matrix
  : public Eigen_sparse_matrix<T>
{
// Public types
  typedef T NT;

// Public operations

  /// Create a square *symmetric* matrix initialized with zeros.
  Eigen_sparse_symmetric_matrix(int  dim)                  ///< Matrix dimension.
      : Eigen_sparse_matrix<T>(dim, true /* symmetric */)
  {
  }

  /// Create a square *symmetric* matrix initialized with zeros.
  ///
  /// @commentheading Precondition: rows == columns.
  Eigen_sparse_symmetric_matrix(int  rows,                 ///< Number of rows.
                                int  columns)              ///< Number of columns.
    : Eigen_sparse_matrix<T>(rows, columns, true /* symmetric */)
  {
  }
};

template <class FT>
struct Eigen_matrix : public ::Eigen::Matrix<FT,::Eigen::Dynamic,::Eigen::Dynamic>
{
  typedef ::Eigen::Matrix<FT,::Eigen::Dynamic,::Eigen::Dynamic> EigenType;
  
  Eigen_matrix( std::size_t n1, std::size_t n2):EigenType(n1,n2){}
  
  std::size_t number_of_rows () const {return this->rows();}
  
  std::size_t number_of_columns () const {return this->cols();}
  
  FT operator()( std::size_t i , std::size_t j ) const {return this->operator()(i,j);}
  
  void set( std::size_t i, std::size_t j,FT value){
    this->coeffRef(i,j)=value;
  }

  const EigenType& eigen_object() const{
    return static_cast<const EigenType&>(*this);
  }

};

} //namespace CGAL

#endif // CGAL_EIGEN_MATRIX_H