This file is indexed.

/usr/include/dune/common/dynmatrix.hh is in libdune-common-dev 2.5.1-1.

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
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_DYNMATRIX_HH
#define DUNE_DYNMATRIX_HH

#include <cmath>
#include <cstddef>
#include <iostream>
#include <initializer_list>

#include <dune/common/boundschecking.hh>
#include <dune/common/exceptions.hh>
#include <dune/common/dynvector.hh>
#include <dune/common/densematrix.hh>
#include <dune/common/typetraits.hh>

namespace Dune
{

  /**
      @addtogroup DenseMatVec
      @{
   */

  /*! \file
   *  \brief This file implements a dense matrix with dynamic numbers of rows and columns.
   */

  template< class K > class DynamicMatrix;

  template< class K >
  struct DenseMatVecTraits< DynamicMatrix<K> >
  {
    typedef DynamicMatrix<K> derived_type;

    typedef DynamicVector<K> row_type;

    typedef row_type &row_reference;
    typedef const row_type &const_row_reference;

    typedef std::vector<K> container_type;
    typedef K value_type;
    typedef typename container_type::size_type size_type;
  };

  template< class K >
  struct FieldTraits< DynamicMatrix<K> >
  {
    typedef typename FieldTraits<K>::field_type field_type;
    typedef typename FieldTraits<K>::real_type real_type;
  };

  /** \brief Construct a matrix with a dynamic size.
   *
   * \tparam K is the field type (use float, double, complex, etc)
   */
  template<class K>
  class DynamicMatrix : public DenseMatrix< DynamicMatrix<K> >
  {
    std::vector< DynamicVector<K> > _data;
    typedef DenseMatrix< DynamicMatrix<K> > Base;
  public:
    typedef typename Base::size_type size_type;
    typedef typename Base::value_type value_type;
    typedef typename Base::row_type row_type;

    //===== constructors
    //! \brief Default constructor
    DynamicMatrix () {}

    //! \brief Constructor initializing the whole matrix with a scalar
    DynamicMatrix (size_type r, size_type c, value_type v = value_type() ) :
      _data(r, row_type(c, v) )
    {}

    /** \brief Constructor initializing the matrix from a list of vector
     */
    DynamicMatrix (std::initializer_list<DynamicVector<K>> const &ll)
      : _data(ll)
    {}


    template <class T,
              typename = std::enable_if_t<!Dune::IsNumber<T>::value && HasDenseMatrixAssigner<DynamicMatrix, T>::value>>
    DynamicMatrix(T const& rhs)
    {
      *this = rhs;
    }

    //==== resize related methods
    /**
     * \brief resize matrix to <code>r × c</code>
     *
     * Resize the matrix to <code>r × c</code>, using <code>v</code>
     * as the value of all entries.
     *
     * \warning All previous entries are lost, even when the matrix
     *          was not actually resized.
     *
     * \param r number of rows
     * \param c number of columns
     * \param v value of matrix entries
     */
    void resize (size_type r, size_type c, value_type v = value_type() )
    {
      _data.resize(0);
      _data.resize(r, row_type(c, v) );
    }

    //===== assignment
    // General assignment with resizing
    template <typename T,
              typename = std::enable_if_t<!Dune::IsNumber<T>::value>>
    DynamicMatrix& operator=(T const& rhs) {
      _data.resize(rhs.N());
      std::fill(_data.begin(), _data.end(), row_type(rhs.M(), K(0)));
      Base::operator=(rhs);
      return *this;
    }

    // Specialisation: scalar assignment (no resizing)
    template <typename T,
              typename = std::enable_if_t<Dune::IsNumber<T>::value>>
    DynamicMatrix& operator=(T scalar) {
      std::fill(_data.begin(), _data.end(), scalar);
      return *this;
    }

    // make this thing a matrix
    size_type mat_rows() const { return _data.size(); }
    size_type mat_cols() const {
      assert(this->rows());
      return _data.front().size();
    }
    row_type & mat_access(size_type i) {
      DUNE_ASSERT_BOUNDS(i < _data.size());
      return _data[i];
    }
    const row_type & mat_access(size_type i) const {
      DUNE_ASSERT_BOUNDS(i < _data.size());
      return _data[i];
    }
  };

  /** @} end documentation */

} // end namespace

#endif