/usr/include/hmat/assembly.hpp is in libhmat-oss-dev 1.2.0-2.
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 | /*
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
*/
#ifndef _INTERACTION_HPP
#define _INTERACTION_HPP
#include <vector>
#include "data_types.hpp"
#include "hmat/hmat.h"
namespace hmat {
class ClusterData;
class ClusterTree;
struct LocalSettings;
template<typename T> class FullMatrix;
template<typename T> class Vector;
template<typename T> class RkMatrix;
template<typename T> class Function;
template<typename T> class BlockFunction;
template<typename T> class SimpleFunction;
/** Allow to be notified when the prepareBlock method need to allocate memory */
class AllocationObserver {
public:
virtual void allocate(size_t) const {}
virtual void free(size_t) const {}
};
/**
* Abstract class, describing the creation of the H-matrix blocks
*/
template<typename T> class Assembly {
public:
/**
* @brief assemble Assemble a block of the matrix
* This function must set fullMatrix or rkMatrix following this rules:
* - Setting both fullMatrix and rkMatrix is an error
* - Setting none mean the block is empty and not compressed
*/
virtual void assemble(const LocalSettings & settings,
const ClusterTree & rows, const ClusterTree & cols,
bool admissible,
FullMatrix<T> * & fullMatrix, RkMatrix<T> * & rkMatrix,
const AllocationObserver & = AllocationObserver()) = 0;
};
/**
* An assembling which use a Function object to compute blocks
*/
template<typename T> class AssemblyFunction: public Assembly<T> {
public:
AssemblyFunction(const Function<T> & function): function_(function) {}
virtual void assemble(const LocalSettings & settings,
const ClusterTree & rows, const ClusterTree & cols,
bool admissible,
FullMatrix<T> * & fullMatrix, RkMatrix<T> * & rkMatrix,
const AllocationObserver & = AllocationObserver());
protected:
const Function<T> & function_;
};
/**
* @Deprecated use AssemblyFunction instead
*/
template<typename T> class SimpleAssemblyFunction: public AssemblyFunction<T>, SimpleFunction<T> {
public:
SimpleAssemblyFunction():
AssemblyFunction<T>(*static_cast<SimpleFunction<T>*>(this)) {}
};
/**
* @Deprecated use AssemblyFunction instead
*/
template<typename T> class BlockAssemblyFunction: public AssemblyFunction<T> {
public:
BlockAssemblyFunction(const ClusterData* _rowData, const ClusterData* _colData,
void* matrixUserData,
hmat_prepare_func_t _prepare, hmat_compute_func_t _compute):
AssemblyFunction<T>(blockFunction),
blockFunction(_rowData, _colData, matrixUserData, _prepare, _compute){}
protected:
BlockFunction<T> blockFunction;
};
/** Abstract base class representing an assembly function.
*/
template<typename T> class Function {
public:
virtual ~Function() {}
virtual FullMatrix<typename Types<T>::dp>* assemble(const ClusterData* rows,
const ClusterData* cols,
const hmat_block_info_t * block_info = NULL,
const AllocationObserver & = AllocationObserver()) const = 0;
/*! \brief Prepare the Assembly function to optimize getRow() and getCol().
In some cases, it is more efficient to tell the client code that a
given block is going to be assembled. The data needed to track
this are stored in \a handle.
\param rows the rows of the block
\param cols the columns of the block
\param handle The handle that is storing the associated data.
*/
virtual void prepareBlock(const ClusterData* rows, const ClusterData* cols,
hmat_block_info_t * block_info, const AllocationObserver &) const;
/*! \brief Release a block prepared with \a AssemblyFunction::releaseBlock().
\param handle the handle passed to \a AssemblyFunction::releaseBlock().
*/
virtual void releaseBlock(hmat_block_info_t *, const AllocationObserver &) const {}
/*! \brief Return a row of a matrix block.
This functions returns a \a Vector representing the row of index
\a rowIndex in the subblock defined by its \a rows and \a cols.
\param rows the rows of the subblock
\param cols the columns of the subblock
\param rowIndex the row index in the subblock
\param handle the optional handle created by \a AssemblyFunction::prepareBlock()
\param result the computed row
\return the row as a \a Vector
*/
virtual void getRow(const ClusterData* rows, const ClusterData* cols,
int rowIndex, void* handle,
Vector<typename Types<T>::dp>* result) const = 0;
/*! \brief Return a column of a matrix block.
This functions returns a \a Vector representing the column of
index \a rowIndex in the subblock defined by its \a rows and \a
cols.
\param rows the rows of the subblock
\param cols the columns of the subblock
\param colIndex the row index in the subblock
\param handle the optional handle created by \a AssemblyFunction::prepareBlock()
\param result the computed column
\return the column as a \a Vector
*/
virtual void getCol(const ClusterData* rows, const ClusterData* cols,
int colIndex, void* handle,
Vector<typename Types<T>::dp>* result) const = 0;
};
/**
* \brief Initialiaze a hmat_bloc_info_t structure.
* Should be used in any prepareBlock implementations
*/
void initBlockInfo(hmat_block_info_t * info);
/** Simple \a AssemblyFunction that allows to only redefine \a AssemblyFunction::interaction().
The rest of the function work by executing a trivial loop on
\a SimpleAssemblyFunction<T>::interaction().
*/
template<typename T> class SimpleFunction : public Function<T> {
public:
/**
* @brief Return the element (i, j) of the matrix.
* This function has to ignore any mapping.
*/
virtual typename Types<T>::dp interaction(int i, int j) const = 0;
virtual ~SimpleFunction() {}
virtual FullMatrix<typename Types<T>::dp>* assemble(const ClusterData* rows,
const ClusterData* cols,
const hmat_block_info_t * block_info = NULL,
const AllocationObserver & = AllocationObserver()) const;
virtual void getRow(const ClusterData* rows, const ClusterData* cols,
int rowIndex, void* handle,
Vector<typename Types<T>::dp>* result) const;
virtual void getCol(const ClusterData* rows, const ClusterData* cols,
int colIndex, void* handle,
Vector<typename Types<T>::dp>* result) const;
};
template<typename T> class BlockFunction : public Function<T> {
private:
hmat_prepare_func_t prepare;
hmat_compute_func_t compute;
void* matrixUserData;
int* rowMapping;
int* rowReverseMapping;
int* colMapping;
int* colReverseMapping;
void prepareImpl(const ClusterData* rows, const ClusterData* cols,
hmat_block_info_t * block_info) const;
public:
BlockFunction(const ClusterData* _rowData, const ClusterData* _colData,
void* matrixUserData,
hmat_prepare_func_t _prepare, hmat_compute_func_t _compute);
~BlockFunction();
FullMatrix<typename Types<T>::dp>* assemble(const ClusterData* rows,
const ClusterData* cols,
const hmat_block_info_t * block_info,
const AllocationObserver & = AllocationObserver()) const;
virtual void prepareBlock(const ClusterData* rows, const ClusterData* cols,
hmat_block_info_t * block_info, const AllocationObserver &) const;
virtual void releaseBlock(hmat_block_info_t * block_info, const AllocationObserver &) const;
virtual void getRow(const ClusterData* rows, const ClusterData* cols,
int rowIndex, void* handle, Vector<typename Types<T>::dp>* result) const;
virtual void getCol(const ClusterData* rows, const ClusterData* cols,
int colIndex, void* handle,
Vector<typename Types<T>::dp>* result) const;
};
} // end namespace hmat
#endif
|