Initial checkin of the matrix-factorized FMM
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
# Library build rule for the series expansion implementation
|
||||
librule(
|
||||
name = "series_expansion",
|
||||
sources = ["series_expansion_aux.cc"],
|
||||
headers = ["cur_decomposition.h",
|
||||
"farfield_expansion.h",
|
||||
"farfield_expansion_impl.h",
|
||||
"matrix_factorized_farfield_expansion.h",
|
||||
"matrix_factorized_farfield_expansion_impl.h",
|
||||
"mult_farfield_expansion.h",
|
||||
"mult_farfield_expansion_impl.h",
|
||||
"kernel_aux.h",
|
||||
"local_expansion.h",
|
||||
"local_expansion_impl.h",
|
||||
"matrix_factorized_local_expansion.h",
|
||||
"matrix_factorized_local_expansion_impl.h",
|
||||
"mult_local_expansion.h",
|
||||
"mult_local_expansion_impl.h",
|
||||
"mult_series_expansion_aux.h",
|
||||
"series_expansion_aux.h",
|
||||
"mult_series_expansion_aux.h"],
|
||||
deplibs = ["fastlib:fastlib_int"]
|
||||
)
|
||||
|
||||
# Test driver for series expansion library
|
||||
binrule(
|
||||
name = "main",
|
||||
sources = ["main.cc"],
|
||||
headers = [],
|
||||
deplibs = [":series_expansion"]
|
||||
)
|
||||
|
||||
# to build:
|
||||
# 1. make sure have environment variables set up:
|
||||
# $ source /full/path/to/fastlib/script/fl-env /full/path/to/fastlib
|
||||
# (you might want to put this in bashrc)
|
||||
# 2. fl-build main
|
||||
# - this automatically will assume --mode=check, the default
|
||||
# - type fl-build --help for help
|
||||
# 3. ./main
|
||||
# - to build same target again, type: make
|
||||
# - to force recompilation, type: make clean
|
||||
@@ -0,0 +1,82 @@
|
||||
/** @file matrix_factorized_fmm.h
|
||||
*
|
||||
* This file implements a prototype algorithm for computing the
|
||||
* pairwise summation using a matrix-factorized formulation of fast
|
||||
* multipole methods.
|
||||
*
|
||||
* @author Dongryeol Lee (dongryel)
|
||||
* @bug In progress
|
||||
*/
|
||||
|
||||
#ifndef MATRIX_FACTORIZED_FMM_H
|
||||
#define MATRIX_FACTORIZED_FMM_H
|
||||
|
||||
#include "matrix_factorized_farfield_expansion.h"
|
||||
#include "matrix_factorized_local_expansion.h"
|
||||
#include "fastlib/fastlib.h"
|
||||
|
||||
#define INSIDE_MATRIX_FACTORIZED_FMM_IMPL_H
|
||||
|
||||
|
||||
|
||||
template<typename TKernelAux>
|
||||
class MatrixFactorizedFMM {
|
||||
|
||||
private:
|
||||
|
||||
#include "matrix_factorized_fmm_stat.h"
|
||||
|
||||
////////// Private Member Variables //////////
|
||||
|
||||
/** @brief The module holding the parameters.
|
||||
*/
|
||||
struct datanode *module_;
|
||||
|
||||
/** @brief Series expansion auxilary object.
|
||||
*/
|
||||
TKernelAux ka_;
|
||||
|
||||
/** @brief The reference dataset.
|
||||
*/
|
||||
Matrix reference_set_;
|
||||
|
||||
/** @brief The reference weights.
|
||||
*/
|
||||
Vector reference_weights_;
|
||||
|
||||
/** @brief The root of the reference tree.
|
||||
*/
|
||||
ReferenceTree *reference_tree_root_;
|
||||
|
||||
/** @brief The permutation mapping indices of reference_set_ to its
|
||||
* original order.
|
||||
*/
|
||||
ArrayList<index_t> old_from_new_references_;
|
||||
|
||||
////////// Private Member Functions //////////
|
||||
|
||||
/** @brief The exhaustive base case for evaluating the reference
|
||||
* contributions to the given set of query points.
|
||||
*/
|
||||
void BaseCase_(const Matrix &query_set,
|
||||
const ArrayList<index_t> &query_index_permutation,
|
||||
const QueryTree *query_node,
|
||||
const ReferenceTree *reference_node,
|
||||
Vector &query_kernel_sums) const;
|
||||
|
||||
public:
|
||||
|
||||
/** @brief Initializes the fast multipole method with the given
|
||||
* reference set.
|
||||
*
|
||||
* @param references The reference set.
|
||||
* @param module_in The module holding the parameters.
|
||||
*/
|
||||
void Init(const Matrix &references, struct datanode *module_in);
|
||||
|
||||
};
|
||||
|
||||
#include "matrix_factorized_fmm_impl.h"
|
||||
#undef INSIDE_MATRIX_FACTORIZED_FMM_IMPL_H
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef INSIDE_MATRIX_FACTORIZED_FMM_IMPL_H
|
||||
#error "This is not a public header file!"
|
||||
#endif
|
||||
|
||||
template<typename TKernelAux>
|
||||
void MatrixFactorizedFMM<TKernelAux>::BaseCase_
|
||||
(const Matrix &query_set, const ArrayList<index_t> &query_index_permutation,
|
||||
const QueryTree *query_node, const ReferenceTree *reference_node,
|
||||
Vector &query_kernel_sums) const {
|
||||
|
||||
|
||||
// Loop over each query point in the query node.
|
||||
for(index_t q = query_node->begin(); q < query_node->end(); q++) {
|
||||
|
||||
// Get the pointer to the current query point.
|
||||
const double *query_point = query_set.GetColumnPtr(q);
|
||||
|
||||
// Loop over each reference point in the reference node.
|
||||
for(index_t r = reference_node->begin(); r < reference_node->end();
|
||||
r++) {
|
||||
|
||||
// Get the pointer to the current reference point.
|
||||
const double *reference_point = reference_set_.GetColumnPtr(r);
|
||||
|
||||
// Compute the pairwise distance and kernel value.
|
||||
double squared_distance = la::DistanceSqEuclidean(query_set.n_rows(),
|
||||
query_point,
|
||||
reference_point);
|
||||
double weighted_kernel_value = reference_weights_[r] *
|
||||
ka_.kernel_.EvalUnnormOnSq(squared_distance);
|
||||
|
||||
query_kernel_sums[query_index_permutation[q]] += weighted_kernel_value;
|
||||
|
||||
} // end of iterating over each reference point.
|
||||
|
||||
} // end of looping over each query point.
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
#ifndef INSIDE_MATRIX_FACTORIZED_FMM_IMPL_H
|
||||
#error "This is not a public header file!"
|
||||
#endif
|
||||
|
||||
class MatrixFactorizedFMMReferenceNodeStat {
|
||||
public:
|
||||
|
||||
/** @brief The default constructor.
|
||||
*/
|
||||
MatrixFactorizedFMMReferenceNodeStat() {
|
||||
}
|
||||
|
||||
/** @brief The default destructor.
|
||||
*/
|
||||
~MatrixFactorizedFMMReferenceNodeStat() {}
|
||||
|
||||
/** @brief Far field expansion created by the reference points in
|
||||
* this node.
|
||||
*/
|
||||
typename TKernelAux::TFarFieldExpansion farfield_expansion_;
|
||||
|
||||
void Init(const TKernelAux &ka) {
|
||||
farfield_expansion_.Init(ka);
|
||||
}
|
||||
|
||||
void Init(const Matrix& dataset, index_t &start, index_t &count) {
|
||||
}
|
||||
|
||||
void Init(const Matrix& dataset, index_t &start, index_t &count,
|
||||
const MatrixFactorizedFMMReferenceNodeStat& left_stat,
|
||||
const MatrixFactorizedFMMReferenceNodeStat& right_stat) {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class MatrixFactorizedFMMQueryNodeStat {
|
||||
public:
|
||||
|
||||
/** @brief The default constructor.
|
||||
*/
|
||||
MatrixFactorizedFMMQueryNodeStat() {
|
||||
}
|
||||
|
||||
/** @brief The default destructor.
|
||||
*/
|
||||
~MatrixFactorizedFMMQueryNodeStat() {}
|
||||
|
||||
/** @brief The local expansion for the query points in this node.
|
||||
*/
|
||||
typename TKernelAux::TFarFieldExpansion local_expansion_;
|
||||
|
||||
void Init(const TKernelAux &ka) {
|
||||
local_expansion_.Init(ka);
|
||||
}
|
||||
|
||||
void Init(const Matrix& dataset, index_t &start, index_t &count) {
|
||||
}
|
||||
|
||||
void Init(const Matrix& dataset, index_t &start, index_t &count,
|
||||
const MatrixFactorizedFMMQueryNodeStat& left_stat,
|
||||
const MatrixFactorizedFMMQueryNodeStat& right_stat) {
|
||||
}
|
||||
};
|
||||
|
||||
/** @brief The type of our query tree.
|
||||
*/
|
||||
typedef BinarySpaceTree<DHrectBound<2>, Matrix, MatrixFactorizedFMMQueryNodeStat > QueryTree;
|
||||
|
||||
/** @brief The type of our reference tree.
|
||||
*/
|
||||
typedef BinarySpaceTree<DHrectBound<2>, Matrix, MatrixFactorizedFMMReferenceNodeStat > ReferenceTree;
|
||||
@@ -7,7 +7,7 @@ class SubspaceStat {
|
||||
|
||||
private:
|
||||
|
||||
static const double epsilon_ = 0.01;
|
||||
static const double epsilon_ = 0.1;
|
||||
|
||||
static void ComputeResidualBasis_(const Matrix &first_basis,
|
||||
const Matrix &second_basis,
|
||||
|
||||
Reference in New Issue
Block a user