This file is indexed.

/usr/include/hmat/hmat_cpp_interface.hpp is in libhmat-oss-dev 1.2.0-2ubuntu1.

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
/*
  HMat-OSS (HMatrix library, open source software)

  Copyright (C) 2014-2015 Airbus Group SAS

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  This program 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 General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

  http://github.com/jeromerobert/hmat-oss
*/

/** @file
   @ingroup HMatrix
   @brief C++ interface to the HMatrix library.
 */
#ifndef HMAT_CPP_INTERFACE_HPP
#define HMAT_CPP_INTERFACE_HPP
#include "hmat/hmat.h"

#include "clustering.hpp"
#include "compression.hpp"
#include "h_matrix.hpp"
#include "default_engine.hpp"

namespace hmat {

class ClusterTree;
class AdmissibilityCondition;

class DofCoordinates;
class ClusteringAlgorithm;

/** Settings for the HMatrix library.

    A single static instance of this class exist, but settings the values is not
    sufficient for the settings to take effect. One must call \a
    HMatSettings::setParameters().
*/
//TODO remove all global settings
class HMatSettings: public hmat::MatrixSettings {
public:
  double assemblyEpsilon; ///< Tolerance for the assembly.
  double recompressionEpsilon; ///< Tolerance for the recompression (using SVD)
  CompressionMethod compressionMethod; ///< Compression method
  int compressionMinLeafSize; ///< Force SVD compression if max(rows->n, cols->n) < compressionMinLeafSize
  /** \f$\eta\f$ in the admissiblity condition for two clusters \f$\sigma\f$ and \f$\tau\f$:
      \f[
      \min(diam(\sigma), diam(\tau)) < \eta \cdot d(\sigma, \tau)
      \f]
   */
  int maxLeafSize; ///< Maximum size of a leaf in a ClusterTree (and of a non-admissible block in an HMatrix)
  int maxParallelLeaves; ///< max(|L0|)
  bool coarsening; ///< Coarsen the matrix structure after assembly.
  bool recompress; ////< Recompress the matrix after assembly.
  bool validateCompression; ///< Validate the rk-matrices after compression
  bool validationReRun; ///< For blocks above error threshold, re-run the compression algorithm
  bool validationDump; ///< For blocks above error threshold, dump the faulty block to disk
  double validationErrorThreshold; ///< Error threshold for the compression validation
private:
  /** This constructor sets the default values.
   */
  HMatSettings() : assemblyEpsilon(1e-4), recompressionEpsilon(1e-4),
                   compressionMethod(AcaPlus),  compressionMinLeafSize(100),
                   maxLeafSize(100),
                   maxParallelLeaves(5000),
                   coarsening(false),
                   recompress(true), validateCompression(false),
                   validationReRun(false), validationDump(false), validationErrorThreshold(0.) {
    setParameters();
  }
  // Disable the copy.
  HMatSettings(const HMatSettings&);
  void operator=(const HMatSettings&);

  public:
  // Classic Singleton pattern.
  static HMatSettings& getInstance() {
      static HMatSettings instance;
      return instance;
    }

  /** Change the settings of the HMatrix library.

      This method has to be called for the settings to take effect.
   */
  void setParameters() const;
  /** Output a textual representation of the settings to out.

      @param out The output stream, std::cout by default.
   */
  void printSettings(std::ostream& out = std::cout) const;
};

DofCoordinates* createCoordinates(double* coord, int dim, int size);

/** Create a ClusterTree.

    The exact type of the returned ClusterTree depends on the global HMatrix
    library settings (\a HMatSettings::clustering).  Passing the returned
    ClusterTree pointer to the constructor of \a HMatInterface transfers its
    ownership to this instance. It is then automatically freed at the destrution
    of its owner.

    @note This is the only proper way to dispose of a ClusterTree instance.

    @param dls Array of DofCoordinate, of length n
    @return a ClusterTree instance.
 */
ClusterTree* createClusterTree(const DofCoordinates& dls, const ClusteringAlgorithm& algo = MedianBisectionAlgorithm());

class DefaultProgress
{
    public:
        static hmat_progress_t * getInstance();
        hmat_progress_t delegate;
    private:
        DefaultProgress();
        DefaultProgress(DefaultProgress const &);
        void operator=(DefaultProgress const&);
};

/** C++ interface to the HMatrix library.

    This is the sole entry point to the HMatrix library.

    This interface is templated over the scalar type, T. This type has to be one
    of {S_t, D_t, C_t, Z_t}, using the standard BLAS notation. For the complex
    types, the C++ complex<> type is used. It is guaranteed to have the same
    layout as the equivalent FORTRAN types.

    The user code *has* to call \a HMatInterface<T>::init() before using any
    other function, and \a HMatInterface<T>::finalize() at the end.
*/
template<typename T, template <typename> class E = DefaultEngine>
class HMatInterface {
 private:
  static bool initialized; ///< True if the library has been initialized.

private:
  E<T> engine_;
  hmat_factorization_t factorizationType;

public:
  /** Initialize the library.

      @warning This *must* be called before using the HMatrix library.
   */
  static int init();
  /** Finalize the library.

      @warning The library cannot be used after this has been called.
   */
  static void finalize();
  /** Build a new HMatrix from two cluster sets.

      @note The ownership of the two ClusterTree instances (which don't need to
      be different) is transfered to the returned HMatInterface instance, and
      will be disposed at destruction time.

      @param _rows The row ClusterTree instance, built with \a createClusterTree()
      @param _cols The column ClusterTree instance, built with \a createClusterTree()
      @param symmetric If kLowerSymmetric, only lower triangular structure is created
      @return a new HMatInterface instance.
   */

  HMatInterface(ClusterTree* _rows, ClusterTree* _cols, SymmetryFlag sym,
                AdmissibilityCondition * admissibilityCondition =
                &StandardAdmissibilityCondition::DEFAULT_ADMISSIBLITY);
  /** Destroy an HMatInterface instance.

      @note This destructor is *not* virtual, as this class is not meant to be subclassed.
   */
  ~HMatInterface();
  /** Assemble an HMatrix.

      This builds an HMatrix using a provided AssemblyFunction. The compression
      method is determined by \a HMatSettings::compressionMethod, and the
      tolerance by \a HMatSettings::assemblyEpsilon. A recompression is done
      when \a HMatSettings::recompress is true.

      @param f The assembly function used to compute various matrix sub-parts
      @param sym If kLowerSymmetric, compute only the lower triangular matrix, and transpose
                 block to store upper counterpart.
      @param synchronize
   */
  void assemble(Assembly<T>& f, SymmetryFlag sym, bool synchronize=true,
                hmat_progress_t * progress = DefaultProgress::getInstance());

  /** Compute a \f$LU\f$ or \f$LDL^T\f$ decomposition of the HMatrix, in place.

      An LDL^T decomposition is done if the HMatrix is symmetric and has been
      assembled as such (with sym = kLowerSymmetric in
      HMatInterface<T>::assemble()), and if HMatSettings::useLdlt is
      true. Otherwise an LU decomposition is done.
   */
  void factorize(hmat_factorization_t, hmat_progress_t * progress = DefaultProgress::getInstance());

  /** Compute the inverse of the HMatrix, in place.
   */
  void inverse(hmat_progress_t * progress = DefaultProgress::getInstance());

  /** Matrix-Vector product.

      This computes \f$ y \gets \alpha . op(A) x + \beta y\f$, with A = this, x
      and y FullMatrix<T>. If trans == 'N', then op(A) = A, if trans == 'T',
      then op(A) = A^T, as in BLAS.

      @param trans 'N' or 'T'
      @param alpha
      @param x
      @param beta
      @param y
   */
  void gemv(char trans, T alpha, FullMatrix<T>& x, T beta, FullMatrix<T>& y) const;
  /** Matrix-Matrix product.

      This computes \f$ C \gets \alpha . op(A) \times op(B) + \beta C\f$ with A,
      B, C three HMatInterface<T> instancem, and C = this.  If trans* == 'N'
      then op(*) = *, if trans* == 'T', then op(*) = *^T, as in BLAS.

      @note transA == transB == 'T' is not supported.

      @param transA 'N' or 'T'
      @param transB 'N' or 'T'
      @param alpha
      @param a
      @param b
      @param beta
   */
  void gemm(char transA, char transB, T alpha, const HMatInterface<T, E>* a, const HMatInterface<T, E>* b, T beta);
  /** Full <- Full x HMatrix product.

      This computes the product \f$ C_F \gets \alpha . op(A_F) \times op(B_H) +
      \beta C_F\f$, with \f$A_F\f$, \f$C_F\f$ two FullMatrix<T>, and \f$B_H\f$
      an HMatrixInterface<T> instance.

      The meaning of the arguments is as in \a HMatInterface<T>::gemm(), and in
      BLAS.
   */
  static void gemm(FullMatrix<T>& c, char transA, char transB, T alpha, FullMatrix<T>& a, const HMatInterface<T, E>& b, T beta);
  /** Return a new copy of this.
   */
  HMatInterface<T, E>* copy() const;
  /** Transpose this in place.
   */
  void transpose();
  /** Solve the system \f$A x = b\f$ in place, with A = this, and b a FullMatrix.

      @warning A has to be factored first with \a HMatInterface<T>::factorize().
   */
  void solve(FullMatrix<T>& b) const;
  /** Solve the system \f$A x = B\f$ in place, with A = this, and B a HMatInterface<T>.

      @warning A has to be factored first with \a HMatInterface<T>::factorize().
   */
  void solve(HMatInterface<T, E>& b) const;
  /** Solve the system \f$op(L) x = b\f$ in place, with L being the lower triangular part of
      an already factorized matrix, and b a FullMatrix.

      @warning A has to be factored first with \a HMatInterface<T>::factorize().
   */
  void solveLower(FullMatrix<T>& b, bool transpose=false) const;
  /** Return an approximation of the Frobenius norm of this.
   */
  double norm() const;
  /** this <- alpha * this
   */
  void scale(T alpha);

  /** this <- this + alpha * Id
   */
  void addIdentity(T alpha);

  /**
   * Fill a hmat_info_t structure with information of this matrix.
   * @note This is only meaningful once the HMatrix has been assembled.
   */
  void info(hmat_info_t &) const;

  /** Create a Postscript file representing the HMatrix.

    The result .ps file shows the matrix structure and the compression ratio. In
    the output, red = full block, green = compressed. The darker the green, the
    worst the compression ration is. There is saturation at black when the block
    size is divided by less than 5.

    @param filename output filename.
   */
  void createPostcriptFile(const std::string& filename) const;
  /*! \brief Dump some HMatrix metadata to a Python-readable file.

    This function create a file that is readable by Python's eval()
    function, which contains a dictionnary with the following data:

    {'points': [(x1, y1, z1), ...],
     'mapping': [indices[0], indices[1], ...],
     'tree': {
       'isLeaf': False,
       'depth': 0,
       'rows': {'offset': 0, 'n': 15243, 'boundingBox': [(-0.0249617, -0.0249652, -0.0249586), (0.0962927, 0.0249652, 0.0249688)]},
       'cols': {'offset': 0, 'n': 15243, 'boundingBox': [(-0.0249617, -0.0249652, -0.0249586), (0.0962927, 0.0249652, 0.0249688)]},
       'children': [child1, child2, child3, child4]
     }
    }

    \param filename path to the output file.
   */
  void dumpTreeToFile(const std::string& filename) const;
  void dumpTreeToFile(const std::string& filename, const HMatrixNodeDumper<T>& dumper_extra) const;
  /** Return the number of block cluster tree nodes.
   */
  int nodesCount() const;
  /** Recursively apply a procedure to all nodes of an HMatrix.
   */
  void walk(TreeProcedure<HMatrix<T> > *proc);

  typename E<T>::Settings & engineSettings() { return engine_.settings; }

  const ClusterData * rows() const {
      return engine_.hmat->rows();
  }

  const ClusterData * cols() const {
      return engine_.hmat->cols();
  }

  const E<T> & engine() const {
      return engine_;
  }

private:
  HMatInterface(HMatrix<T>* h);
  /// Disallow the copy
  HMatInterface(const HMatInterface<T, E>& o);
};
}  // end namespace hmat

#endif