From b5ec42b29be85fdb1b191ae6bd313a41e331e205 Mon Sep 17 00:00:00 2001 From: Dongryeol Lee Date: Tue, 20 May 2008 02:18:08 +0000 Subject: [PATCH] Implemented the evaluation method for matrix-factorized local expansion. --- .../matrix_factorized_local_expansion.h | 2 +- .../matrix_factorized_local_expansion_impl.h | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/fastlib2/mlpack/series_expansion/matrix_factorized_local_expansion.h b/fastlib2/mlpack/series_expansion/matrix_factorized_local_expansion.h index 3f097097e9..6a7dd7a855 100644 --- a/fastlib2/mlpack/series_expansion/matrix_factorized_local_expansion.h +++ b/fastlib2/mlpack/series_expansion/matrix_factorized_local_expansion.h @@ -193,7 +193,7 @@ class MatrixFactorizedLocalExpansion { * coefficients are added up to the passed-in local * expansion coefficients. */ - void TranslateToLocal(MatrixFactorizedLocalExpansion &se); + void TranslateToLocal(MatrixFactorizedLocalExpansion &se) const; }; diff --git a/fastlib2/mlpack/series_expansion/matrix_factorized_local_expansion_impl.h b/fastlib2/mlpack/series_expansion/matrix_factorized_local_expansion_impl.h index dfc160d868..8fd697d434 100644 --- a/fastlib2/mlpack/series_expansion/matrix_factorized_local_expansion_impl.h +++ b/fastlib2/mlpack/series_expansion/matrix_factorized_local_expansion_impl.h @@ -42,12 +42,24 @@ void MatrixFactorizedLocalExpansion::CombineBasisFunctions template double MatrixFactorizedLocalExpansion::EvaluateField (const Matrix& data, int row_num) const { - return -1; + + // Take the dot product of the (row_num - + // local_to_local_translation_begin_) th row of the evaluation + // operator. + double dot_product = 0; + + for(index_t i = 0; i < evaluation_operator_->n_cols(); i++) { + dot_product += + evaluation_operator_->get(row_num - local_to_local_translation_begin_, + i) * coeffs_[i]; + } + return dot_product; } template double MatrixFactorizedLocalExpansion::EvaluateField (const Vector& x_q) const { + DEBUG_ASSERT_MSG(false, "Please implement me!"); return -1; } @@ -180,7 +192,7 @@ void MatrixFactorizedLocalExpansion::TrainBasisFunctions template void MatrixFactorizedLocalExpansion::TranslateToLocal -(MatrixFactorizedLocalExpansion &se) { +(MatrixFactorizedLocalExpansion &se) const { // Local-to-local translation involves determining the indices of // the query points that belong to the local moment to be