This file is indexed.

/usr/include/dolfin/common/Array.h is in libdolfin1.0-dev 1.0.0-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
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
// Copyright (C) 2009-2011 Garth N. Wells
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: 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.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// Modified by Anders Logg 2010-2011
//
// First added:  2009-12-06
// Last changed: 2011-11-13

#ifndef __DOLFIN_ARRAY_H
#define __DOLFIN_ARRAY_H

#include <sstream>
#include <string>
#include <utility>
#include <boost/shared_array.hpp>


#include <dolfin/common/constants.h>
#include <dolfin/common/types.h>
#include <dolfin/log/log.h>

#include "NoDeleter.h"

namespace dolfin
{

  /// This class provides a simple wrapper for a pointer to an array. A purpose
  /// of this class is to enable the simple and safe exchange of data between
  /// C++ and Python.

  template <typename T> class Array
  {
  public:

    /// Create empty array
    Array() : _size(0), x(0) {}

    /// Create array of size N
    explicit Array(uint N) : _size(N), x(new T[N]) {}

    /// Copy constructor (arg name need to have a different name that 'x')
    Array(const Array& other) : _size(0), x(0)
    { *this = other; }

    /// Construct array from a shared pointer
    Array(uint N, boost::shared_array<T> x) : _size(N), x(x) {}

    /// Construct array from a pointer. Array will not take ownership.
    Array(uint N, T* x) : _size(N), x(boost::shared_array<T>(x, NoDeleter())) {}

    /// Assignment operator
    const Array& operator= (const Array& x)
    {
      // Resize if necessary
      if (x.size() == 0 && !x.x)
      {
        this->x.reset();
        this->_size = 0;
      }
      else if (this->_size != x.size())
      {
        this->x.reset(new T[x.size()]);
        this->_size = x.size();
      }

      // Copy data
      if (_size > 0)
      {
        dolfin_assert(this->x);
        dolfin_assert(x.x);
        std::copy(&x.x[0], &x.x[_size], &this->x[0]);
      }

      return *this;
    }

    /// Construct array from a pointer. Array will not take ownership.
    void update(uint N, T* _x)
    {
      _size = N;
      x.reset(_x, NoDeleter());
    }

    /// Return informal string representation (pretty-print).
    /// Note that the Array class is not a subclass of Variable (for
    /// efficiency) which means that one needs to call str() directly
    /// instead of using the info() function on Array objects.
    std::string str(bool verbose) const
    {
      std::stringstream s;

      if (verbose)
      {
        s << str(false) << std::endl << std::endl;

        for (uint i = 0; i < size(); i++)
          s << i << ": " << (*this)[i] << std::endl;
      }
      else
        s << "<Array<T> of size " << size() << ">";

      return s.str();
    }

    /// Clear array
    void clear()
    {
      this->x.reset();
      this->_size = 0;
    }

    /// Resize array to size N. If size changes, contents will be destroyed.
    void resize(uint N)
    {
      // Special case
      if (N == _size)
        return;

      // Special case
      if (N == 0)
      {
        clear();
        return;
      }

      // FIXME: Do we want to allow resizing of shared data?
      if (x.unique())
      {
        _size = N;
        x.reset(new T[N]);
      }
      else
      {
        dolfin_error("Array.h",
                     "resize Array",
                     "Data is shared");
      }
    }

    /// Return size of array
    uint size() const
    { return _size; }

    /// Zero array
    void zero()
    { dolfin_assert(x); std::fill(&x[0], &x[_size], 0.0); }

    /// Set entries which meet (abs(x[i]) < eps) to zero
    void zero_eps(double eps=DOLFIN_EPS);

    /// Return minimum value of array
    T min() const
    { dolfin_assert(x); return *std::min_element(&x[0], &x[_size]); }

    /// Return maximum value of array
    T max() const
    { dolfin_assert(x); return *std::max_element(&x[0], &x[_size]); }

    /// Access value of given entry (const version)
    const T& operator[] (uint i) const
    { dolfin_assert(x); dolfin_assert(i < _size); return x[i]; }

    /// Access value of given entry (non-const version)
    T& operator[] (uint i)
    {
      dolfin_assert(x);
      dolfin_assert(i < _size);
      return x[i];
    }

    /// Assign value to all entries
    const Array<T>& operator= (T& x)
    {
      dolfin_assert(this->x);
      for (uint i = 0; i < _size; ++i)
        this->x[i] = x;
      return *this;
    }

    /// Return pointer to data (const version)
    const boost::shared_array<T> data() const
    { return x; }

    /// Return pointer to data (non-const version)
    boost::shared_array<T> data()
    { return x; }

  private:

    // Length of array
    uint _size;

    // Array data
    boost::shared_array<T> x;

  };

  template <typename T>
  inline void Array<T>::zero_eps(double eps)
  {
    dolfin_error("Array.h",
                 "zero small entries in array",
                 "Only available when data type is <double>");
  }

  template <>
  inline void Array<double>::zero_eps(double eps)
  {
    dolfin_assert(x);
    for (uint i = 0; i < _size; ++i)
    {
      if (std::abs(x[i]) < eps)
        x[i] = 0.0;
    }
  }

}

#endif