/usr/include/hmat/interaction.hpp is in libhmat-oss-dev 1.0.4-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 | /*
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"
class ClusterData;
class ClusterTree;
template<typename T> class FullMatrix;
template<typename T> class Vector;
/** Abstract base class representing an assembly function.
*/
template<typename T> class AssemblyFunction {
public:
/** 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 ~AssemblyFunction() {};
virtual FullMatrix<typename Types<T>::dp>* assemble(const ClusterData* rows,
const ClusterData* cols) 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,
void** handle) const {}
/*! \brief Release a block prepared with \a AssemblyFunction::releaseBlock().
\param handle the handle passed to \a AssemblyFunction::releaseBlock().
*/
virtual void releaseBlock(void* handle) 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()
\return the row as a \a Vector
*/
virtual Vector<typename Types<T>::dp>* getRow(const ClusterData* rows,
const ClusterData* cols,
int rowIndex, void* handle=NULL) const = 0;
/*! \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()
\return the column as a \a Vector
*/
virtual Vector<typename Types<T>::dp>* getCol(const ClusterData* rows,
const ClusterData* cols,
int colIndex, void* handle=NULL) 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;
};
/** 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 SimpleAssemblyFunction : public AssemblyFunction<T> {
public:
virtual typename Types<T>::dp interaction(int i, int j) const = 0;
virtual ~SimpleAssemblyFunction() {};
virtual FullMatrix<typename Types<T>::dp>* assemble(const ClusterData* rows,
const ClusterData* cols) const;
virtual Vector<typename Types<T>::dp>* getRow(const ClusterData* rows,
const ClusterData* cols,
int rowIndex, void* handle=NULL) const;
virtual void getRow(const ClusterData* rows, const ClusterData* cols,
int rowIndex, void* handle,
Vector<typename Types<T>::dp>* result) const;
virtual Vector<typename Types<T>::dp>* getCol(const ClusterData* rows,
const ClusterData* cols,
int colIndex, void* handle=NULL) 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 BlockAssemblyFunction : public AssemblyFunction<T> {
private:
prepare_func prepare;
compute_func compute;
release_func free_data;
void* user_context;
int* rowMapping;
int* rowReverseMapping;
int* colMapping;
int* colReverseMapping;
public:
BlockAssemblyFunction(const ClusterData* _rowData, const ClusterData* _colData,
void* _user_context,
prepare_func _prepare, compute_func _compute,
release_func _free_data);
~BlockAssemblyFunction();
typename Types<T>::dp interaction(int i, int j) const;
FullMatrix<typename Types<T>::dp>* assemble(const ClusterData* rows,
const ClusterData* cols) const;
virtual void prepareBlock(const ClusterData* rows, const ClusterData* cols,
void** handle) const;
virtual void releaseBlock(void* handle) const;
virtual Vector<typename Types<T>::dp>* getRow(const ClusterData* rows,
const ClusterData* cols,
int rowIndex, void* handle=NULL) const;
virtual void getRow(const ClusterData* rows, const ClusterData* cols,
int rowIndex, void* handle, Vector<typename Types<T>::dp>* result) const;
virtual Vector<typename Types<T>::dp>* getCol(const ClusterData* rows,
const ClusterData* cols,
int colIndex, void* handle=NULL) const;
virtual void getCol(const ClusterData* rows, const ClusterData* cols,
int colIndex, void* handle,
Vector<typename Types<T>::dp>* result) const;
};
#endif
|