unsafe_col() is faster.

This commit is contained in:
Ryan Curtin
2012-05-18 03:30:20 +00:00
parent 858356907d
commit 174fc0514d
2 changed files with 7 additions and 6 deletions
+2 -2
View File
@@ -91,8 +91,8 @@ void MaxIP<KernelType>::Search(const size_t k,
{
for (size_t r = 0; r < referenceSet.n_cols; ++r)
{
const double eval = KernelType::Evaluate(querySet.col(q),
referenceSet.col(r));
const double eval = KernelType::Evaluate(querySet.unsafe_col(q),
referenceSet.unsafe_col(r));
size_t insertPosition;
for (insertPosition = 0; insertPosition < indices.n_rows;
@@ -40,8 +40,9 @@ bool MaxIPRules<MetricType>::CanPrune(const size_t queryIndex,
// and since we are using cover trees, p_0 is the point referred to by the
// node, and R_p will be the expansion constant to the power of the scale plus
// one.
const double eval = MetricType::Kernel::Evaluate(querySet.col(queryIndex),
referenceSet.col(referenceNode.Point()));
const double eval = MetricType::Kernel::Evaluate(
querySet.unsafe_col(queryIndex),
referenceSet.unsafe_col(referenceNode.Point()));
// See if base case can be added.
if (eval > products(products.n_rows - 1, queryIndex))
@@ -57,8 +58,8 @@ bool MaxIPRules<MetricType>::CanPrune(const size_t queryIndex,
double maxProduct = eval + std::pow(referenceNode.ExpansionConstant(),
referenceNode.Scale() + 1) *
sqrt(MetricType::Kernel::Evaluate(querySet.col(queryIndex),
querySet.col(queryIndex)));
sqrt(MetricType::Kernel::Evaluate(querySet.unsafe_col(queryIndex),
querySet.unsafe_col(queryIndex)));
if (maxProduct > products(products.n_rows - 1, queryIndex))
return false;