This file is indexed.

/usr/include/Wt/WGenericMatrix is in libwt-dev 3.3.6+dfsg-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
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2010 Emweb bvba, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#ifndef WGENERICMATRIX_H_
#define WGENERICMATRIX_H_

#include <Wt/WDllDefs.h>
#ifdef _MSC_VER
// Avoid 64-bit related warnings on MSVC
#pragma warning( push )
#pragma warning( disable : 4244 )
#pragma warning( disable : 4267 )
#endif
#define BOOST_SERIALIZATION_NO_LIB
#include <boost/numeric/ublas/matrix.hpp>
#ifdef _MSC_VER
#pragma warning( pop )
#endif
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>

#include <ostream>

namespace Wt {

/*! \class WGenericMatrix Wt/WGenericMatrix Wt/WGenericMatrix
 * \brief A value class that describes a matrix
 *
 * This class represents a fixed-size dense (!= sparse) matrix. It
 * can be templatized to the number of rows and columns, and to the
 * datatype stored (integer types, floatin point types, complex types, ...)
 *
 * The row order of this matrix class is row-major. This means that when
 * accessing the raw data store linearly, you will first encounter all
 * elements of the first row, then the second row, and so on.
 *
 * This template class is used in Wt as base class for transformation
 * matrices, but can also be used as a general matrix class. Efficiency
 * for this use case was considered when this class was implemented, but
 * we recommend that you use a more specialized matrix class library
 * if the algorithms you need exceed what's offered here (for example,
 * if you intend to do many linear algebra computations, you may
 * consider boost ublass, MTL, ...).
 */
template<typename T, std::size_t Rows, std::size_t Cols>
class WGenericMatrix
{
public:
  typedef boost::numeric::ublas::bounded_matrix<T, Rows, Cols,
    boost::numeric::ublas::row_major> MatrixType;
  typedef typename boost::numeric::ublas::bounded_matrix<T, Rows, Cols,
    boost::numeric::ublas::row_major>::array_type ArrayType;

  /*! \brief Construct a identity matrix
   *
   * An identity matrix in this context is a matrix where m(i,i) = 1
   * and m(i,j) = 0, for i != j.
   */
  WGenericMatrix()
  {
    setToIdentity();
  }

  /*! \brief Copy Constructor
   */
  WGenericMatrix(const WGenericMatrix<T, Rows, Cols> &other): m_(other.m_) {}

  /*! \brief Constructs a matrix from an array of elements.
   *
   * The input array is assumed to be in row-major order. If elements is 0,
   * the matrix data is not initialized.
   */
  explicit WGenericMatrix(const T* elements)
  {
    if (elements) {
      for(unsigned int i = 0; i < Rows; ++i)
        for(unsigned int j = 0; j < Cols; ++j)
          m_(i, j) = elements[i * Rows + j];
    }
  }

  /*! \brief Returns a const pointer to the internal data store.
   *
   * The array can be indexed with []. You can iterate over the
   * entire data store by using begin() and end() iterators. The
   * row order of the data is row major.
   */
  const ArrayType &constData() const { return m_.data(); }

  /*! \brief Export the matrix data
   *
   * Stores the matrix in an array of Rows*Cols elements of type T,
   * pointed to by data. The data will be stored in row major order.
   */
  void copyDataTo(T *data)
  {
    for(unsigned int i = 0; i < Rows; ++i)
      for (unsigned int j = 0; j < Cols; ++j)
        data[i * Rows + j] = m_(i, j);
  }

  /*! \brief Returns a reference to the internal data store.
   *
   * The array can be indexed with []. You can iterate over the
   * entire data store by using begin() and end() iterators. The
   * row order of the data is row major.
   */
  ArrayType &data() { return m_.data(); }

  /*! \brief Returns a const reference to the internal data store.
   *
   * The array can be indexed with []. You can iterate over the
   * entire data store by using begin() and end() iterators. The
   * row order of the data is row major.
   */
  const ArrayType &data() const { return m_.data(); }

  /*! \brief Fills every element of the matrix with the given value
   */
  void fill(T value)
  {
    for (unsigned i = 0; i < Rows * Cols; ++i)
      m_.data()[i] = value;
  }

  /*! \brief Identity check.
   *
   * Returns true if the transform represents an identity transformation.
   */
  bool isIdentity() const
  {
    using namespace boost::numeric::ublas;
    identity_matrix<T> I(Rows > Cols ? Rows : Cols);
    for(unsigned i = 0; i < Rows; ++i)
      for (unsigned j = 0; j < Cols; ++j)
        if (m_(i, j) != I(i, j))
          return false;
    return true;
  }

  /*! \brief Set this matrix to the identity matrix
   *
   * An identity matrix is in this context a matrix where m(i,i) = 1
   * and m(i,j) = 0, for i != j.
   */
  void setToIdentity()
  {
    #ifndef WT_TARGET_JAVA
    using namespace boost::numeric::ublas;
    m_ = project(identity_matrix<T>(Rows > Cols ? Rows : Cols),
        range(0, Rows), range(0, Cols));
    #endif
  }

  /*! \brief Returns the transposed of the matrix
   */
  WGenericMatrix<T, Cols, Rows> transposed() const
  {
    return WGenericMatrix<T, Cols, Rows>(boost::numeric::ublas::trans(m_));
  }

  /*! \brief Equality operator.
   *
   * Returns \c true if the matrices are exactly the same.
   */
  bool operator==(const WGenericMatrix<T, Rows, Cols>& rhs) const
  {
    for(unsigned i = 0; i < Rows; ++i)
      for (unsigned j = 0; j < Cols; ++j)
        if (rhs.m_(i, j) != m_(i, j))
          return false;
    return true;
  }

  /*! \brief Inequality operator.
   *
   * Returns \c true if the transforms are different.
   */
  bool operator!=(const WGenericMatrix<T, Rows, Cols> &rhs) const {
    return !(*this == rhs);
  }

  /*! \brief Returns the element at the given position
   */
  const T &operator()(int row, int column) const
  {
    return m_(row, column);
  }

  /*! \brief Returns the element at the given position
   */
  T &operator()(int row, int column) { return m_(row, column); }

  /*! \brief Returns the element at the given position
   */
  const T &at(int row, int column) const
  {
    return m_(row, column);
  }

  /*! \brief Returns the element at the given position
   */
  T &at(int row, int column) { return m_(row, column); } 

#ifdef WT_TARGET_JAVA
  void setElement(int row, int column, float v);
#endif

  /*! \brief Multiply every element of the matrix with the given factor
   */
  WGenericMatrix<T, Rows, Cols> &operator*=(const T &factor)
  {
#ifndef WT_TARGET_JAVA
    m_ *= factor;
    return *this;
#endif
  }

  /*! \brief Divide every element of the matrix by the given factor
   */
  WGenericMatrix<T, Rows, Cols> &operator/=(const T &factor)
  {
#ifndef WT_TARGET_JAVA
    m_ /= factor;
    return *this;
#endif
  }

  /*! \brief Add the given matrix to this matrix
   */
  WGenericMatrix<T, Rows, Cols> &operator+=(
    const WGenericMatrix<T, Rows, Cols> &rhs)
  {
#ifndef WT_TARGET_JAVA
    m_ += rhs.m_;
    return *this;
#endif
  }

  /*! \brief Substract the given matrix from this matrix
   */
  WGenericMatrix<T, Rows, Cols> &operator-=(
    const WGenericMatrix<T, Rows, Cols> &rhs)
  {
#ifndef WT_TARGET_JAVA
    m_ -= rhs.m_;
    return *this;
#endif
  }

  MatrixType &impl() { return m_; }
  const MatrixType &impl() const { return m_; }
  WGenericMatrix(const MatrixType &m): m_(m) {}

private:
  MatrixType m_;
};

/*! \brief Multiply two matrices
 */
template<typename T, std::size_t A, std::size_t B, std::size_t C>
inline WGenericMatrix<T, A, C> operator*(const WGenericMatrix<T, A, B> &l,
  const WGenericMatrix<T, B, C> &r)
{
#ifndef WT_TARGET_JAVA
  using namespace boost::numeric::ublas;
  return WGenericMatrix<T, A, C>(prod(l.impl(), r.impl()));
#endif
}

/*! \brief Print the matrix to an ostream
 */
template<typename T, std::size_t Rows, std::size_t Cols>
std::ostream &operator<<(std::ostream &os,
  const WGenericMatrix<T, Rows, Cols> &m)
{
#ifndef WT_TARGET_JAVA
  return os << m.impl();
#endif
}

/*! \brief Multiply every element in the matrix with the given factor
 */
template<typename T, std::size_t Rows, std::size_t Cols>
inline WGenericMatrix<T, Rows, Cols> operator*(const T &factor,
  const WGenericMatrix<T, Rows, Cols> &m)
{
#ifndef WT_TARGET_JAVA
  return WGenericMatrix<T, Rows, Cols>(factor * m.impl());
#endif
}

/*! \brief Multiply every element in the matrix with the given factor
 */
template<typename T, std::size_t Rows, std::size_t Cols>
inline WGenericMatrix<T, Rows, Cols> operator*(
  const WGenericMatrix<T, Rows, Cols> &m, const T &factor)
{
#ifndef WT_TARGET_JAVA
  return WGenericMatrix<T, Rows, Cols>(m.impl() * factor);
#endif
}

/*! \brief Divide every element in the matrix by the given factor
 */
template<typename T, std::size_t Rows, std::size_t Cols>
inline WGenericMatrix<T, Rows, Cols> operator/(
  const WGenericMatrix<T, Rows, Cols> &m, const T &factor)
{
#ifndef WT_TARGET_JAVA
  return WGenericMatrix<T, Rows, Cols>(m.impl() / factor);
#endif
}

/*! \brief Add two matrices together
 */
template<typename T, std::size_t Rows, std::size_t Cols>
inline WGenericMatrix<T, Rows, Cols> operator+(
  const WGenericMatrix<T, Rows, Cols> &l,
  const WGenericMatrix<T, Rows, Cols> &r)
{
#ifndef WT_TARGET_JAVA
  return WGenericMatrix<T, Rows, Cols>(l.impl() + r.impl());
#endif
}

/*! \brief Substract two matrices
 */
template<typename T, std::size_t Rows, std::size_t Cols>
inline WGenericMatrix<T, Rows, Cols> operator-(
  const WGenericMatrix<T, Rows, Cols> &l,
  const WGenericMatrix<T, Rows, Cols> &r)
{
#ifndef WT_TARGET_JAVA
  return WGenericMatrix<T, Rows, Cols>(l.impl() - r.impl());
#endif
}

/*! \brief Negate every element in the matrix
 */
template<typename T, std::size_t Rows, std::size_t Cols>
inline WGenericMatrix<T, Rows, Cols> operator-(
  const WGenericMatrix<T, Rows, Cols> &m)
{
#ifndef WT_TARGET_JAVA
  return WGenericMatrix<T, Rows, Cols>(-m.impl());
#endif
}

}
#endif // WGENERICMATRIX_H_