\section{L\+Metric$<$ T\+Power, T\+Take\+Root $>$ Class Template Reference}
\label{classmlpack_1_1metric_1_1LMetric}\index{L\+Metric$<$ T\+Power, T\+Take\+Root $>$@{L\+Metric$<$ T\+Power, T\+Take\+Root $>$}}


The L\+\_\+p metric for arbitrary integer p, with an option to take the root.  




Inheritance diagram for L\+Metric$<$ T\+Power, T\+Take\+Root $>$\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=200pt]{classmlpack_1_1metric_1_1LMetric__inherit__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ L\+Metric} ()
\begin{DoxyCompactList}\small\item\em Default constructor does nothing, but is required to satisfy the Metric policy. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Archive $>$ }\\void \textbf{ serialize} (Archive \&, const unsigned int)
\begin{DoxyCompactList}\small\item\em Serialize the metric (nothing to do). \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Static Public Member Functions}
\begin{DoxyCompactItemize}
\item 
{\footnotesize template$<$typename Vec\+TypeA , typename Vec\+TypeB $>$ }\\static Vec\+Type\+A\+::elem\+\_\+type \textbf{ Evaluate} (const Vec\+TypeA \&a, const Vec\+TypeB \&b)
\begin{DoxyCompactList}\small\item\em Computes the distance between two points. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Static Public Attributes}
\begin{DoxyCompactItemize}
\item 
static const int \textbf{ Power} = T\+Power
\begin{DoxyCompactList}\small\item\em The power of the metric. \end{DoxyCompactList}\item 
static const bool \textbf{ Take\+Root} = T\+Take\+Root
\begin{DoxyCompactList}\small\item\em Whether or not the root is taken. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$int T\+Power, bool T\+Take\+Root = true$>$\newline
class mlpack\+::metric\+::\+L\+Metric$<$ T\+Power, T\+Take\+Root $>$}

The L\+\_\+p metric for arbitrary integer p, with an option to take the root. 

This class implements the standard L\+\_\+p metric for two arbitrary vectors $ x $ and $ y $ of dimensionality $ n $\+:

\[ d(x, y) = \left( \sum_{i = 1}^{n} | x_i - y_i |^p \right)^{\frac{1}{p}}. \]

The value of p is given as a template parameter.

In addition, the function $ d(x, y) $ can be simplified, neglecting the p-\/root calculation. This is done by specifying the Take\+Root template parameter to be false. Then,

\[ d(x, y) = \sum_{i = 1}^{n} | x_i - y_i |^p \]

It is faster to compute that distance, so Take\+Root is by default off. However, when Take\+Root is false, the distance given is not actually a true metric -- it does not satisfy the triangle inequality. Some mlpack methods do not require the triangle inequality to operate correctly (such as the Binary\+Space\+Tree), but setting Take\+Root = false in some cases will cause incorrect results.

A few convenience typedefs are given\+:


\begin{DoxyItemize}
\item Manhattan\+Distance
\item Euclidean\+Distance
\item Squared\+Euclidean\+Distance
\end{DoxyItemize}


\begin{DoxyTemplParams}{Template Parameters}
{\em Power} & Power of metric; i.\+e. Power = 1 gives the L1-\/norm (Manhattan distance). \\
\hline
{\em Take\+Root} & If true, the Power\textquotesingle{}th root of the result is taken before it is returned. Setting this to false causes the metric to not satisfy the Triangle Inequality (be careful!). \\
\hline
\end{DoxyTemplParams}


Definition at line 63 of file lmetric.\+hpp.



\subsection{Constructor \& Destructor Documentation}
\mbox{\label{classmlpack_1_1metric_1_1LMetric_ad296b4c8538551ddcef38a49d0842ca7}} 
\index{mlpack\+::metric\+::\+L\+Metric@{mlpack\+::metric\+::\+L\+Metric}!L\+Metric@{L\+Metric}}
\index{L\+Metric@{L\+Metric}!mlpack\+::metric\+::\+L\+Metric@{mlpack\+::metric\+::\+L\+Metric}}
\subsubsection{L\+Metric()}
{\footnotesize\ttfamily \textbf{ L\+Metric} (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Default constructor does nothing, but is required to satisfy the Metric policy. 



Definition at line 70 of file lmetric.\+hpp.



\subsection{Member Function Documentation}
\mbox{\label{classmlpack_1_1metric_1_1LMetric_af39380107875eb94f0efef7d37cc57df}} 
\index{mlpack\+::metric\+::\+L\+Metric@{mlpack\+::metric\+::\+L\+Metric}!Evaluate@{Evaluate}}
\index{Evaluate@{Evaluate}!mlpack\+::metric\+::\+L\+Metric@{mlpack\+::metric\+::\+L\+Metric}}
\subsubsection{Evaluate()}
{\footnotesize\ttfamily static Vec\+Type\+A\+::elem\+\_\+type Evaluate (\begin{DoxyParamCaption}\item[{const Vec\+TypeA \&}]{a,  }\item[{const Vec\+TypeB \&}]{b }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Computes the distance between two points. 


\begin{DoxyTemplParams}{Template Parameters}
{\em Vec\+TypeA} & Type of first vector (generally arma\+::vec or arma\+::sp\+\_\+vec). \\
\hline
{\em Vec\+TypeB} & Type of second vector. \\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em a} & First vector. \\
\hline
{\em b} & Second vector. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Distance between vectors a and b. 
\end{DoxyReturn}


Referenced by Spherical\+Kernel\+::\+Convolution\+Integral(), Gaussian\+Kernel\+::\+Convolution\+Integral(), Spherical\+Kernel\+::\+Evaluate(), Triangular\+Kernel\+::\+Evaluate(), Laplacian\+Kernel\+::\+Evaluate(), Gaussian\+Kernel\+::\+Evaluate(), Cauchy\+Kernel\+::\+Evaluate(), and L\+Metric$<$ T\+Power, true $>$\+::\+L\+Metric().

\mbox{\label{classmlpack_1_1metric_1_1LMetric_aa5b3dd8336182f751ebec27167c22415}} 
\index{mlpack\+::metric\+::\+L\+Metric@{mlpack\+::metric\+::\+L\+Metric}!serialize@{serialize}}
\index{serialize@{serialize}!mlpack\+::metric\+::\+L\+Metric@{mlpack\+::metric\+::\+L\+Metric}}
\subsubsection{serialize()}
{\footnotesize\ttfamily void serialize (\begin{DoxyParamCaption}\item[{Archive \&}]{,  }\item[{const unsigned}]{int }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Serialize the metric (nothing to do). 



Definition at line 88 of file lmetric.\+hpp.



\subsection{Member Data Documentation}
\mbox{\label{classmlpack_1_1metric_1_1LMetric_add828b673634e896b13f47cc7fb331f5}} 
\index{mlpack\+::metric\+::\+L\+Metric@{mlpack\+::metric\+::\+L\+Metric}!Power@{Power}}
\index{Power@{Power}!mlpack\+::metric\+::\+L\+Metric@{mlpack\+::metric\+::\+L\+Metric}}
\subsubsection{Power}
{\footnotesize\ttfamily const int Power = T\+Power\hspace{0.3cm}{\ttfamily [static]}}



The power of the metric. 



Definition at line 91 of file lmetric.\+hpp.

\mbox{\label{classmlpack_1_1metric_1_1LMetric_a0615e7186f9a9847e2f71d2d2622579d}} 
\index{mlpack\+::metric\+::\+L\+Metric@{mlpack\+::metric\+::\+L\+Metric}!Take\+Root@{Take\+Root}}
\index{Take\+Root@{Take\+Root}!mlpack\+::metric\+::\+L\+Metric@{mlpack\+::metric\+::\+L\+Metric}}
\subsubsection{Take\+Root}
{\footnotesize\ttfamily const bool Take\+Root = T\+Take\+Root\hspace{0.3cm}{\ttfamily [static]}}



Whether or not the root is taken. 



Definition at line 93 of file lmetric.\+hpp.



The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
/var/www/mlpack.\+ratml.\+org/mlpack.\+org/\+\_\+src/mlpack-\/3.\+3.\+1/src/mlpack/core/metrics/\textbf{ lmetric.\+hpp}\end{DoxyCompactItemize}
