2 #ifndef vpdt_norm_metric_h_ 3 #define vpdt_norm_metric_h_ 22 # include <vcl_msvc_warnings.h> 30 template<
class F,
class Tensor,
class Disambiguate=
void>
51 return std::sqrt(sqr_distance(pt1,pt2,c));
59 return c.inverse_quad_form(d);
68 c.inverse_product(d,g);
85 return c.determinant();
108 return std::sqrt(sqr_distance(pt1,pt2,c));
118 for (
unsigned int i=0; i<d; ++i)
135 for (
unsigned int i=0; i<d; ++i)
149 const unsigned int d = c.size();
152 for (
unsigned int i=0; i<d; ++i)
155 for (
unsigned int j=i+1; j<d; ++j)
164 const unsigned int d = c.size();
166 for (
unsigned int i=0; i<d; ++i)
168 return static_cast<T>(det);
191 return std::sqrt(sqr_distance(pt1,pt2,c));
200 for (
unsigned int i=0; i<d; ++i)
216 for (
unsigned int i=0; i<d; ++i)
233 for (
unsigned int i=0; i<d; ++i)
236 for (
unsigned int j=i+1; j<d; ++j)
247 for (
unsigned int i=0; i<d; ++i)
249 return static_cast<T>(det);
272 return std::sqrt(sqr_distance(pt1,pt2,c));
307 #endif // vpdt_norm_metric_h_ vpdt_field_traits< F >::vector_type vector
the data type used for vectors.
vpdt_field_traits< F >::scalar_type covar_type
the data type used for the metric tensor.
static T sqr_distance(const F &pt1, const F &pt2, const covar_type &c)
Compute the square Mahalanobis distance between two points.
static T distance(const F &pt1, const F &pt2, const covar_type &c)
Compute the Mahalanobis distance between two points.
static T sqr_distance(const F &pt1, const F &pt2, const covar_type &c)
Compute the square Mahalanobis distance between two points.
VNL_EXPORT T dot_product(m const &, m const &)
vpdt_field_traits< F >::scalar_type T
the data type used for scalars.
static T covar_det(const F &pt, const covar_type &c)
Compute the determinant of the covariance matrix (metric tensor) at a point.
vpdt_field_traits< F >::matrix_type matrix
the data type used for matrices.
static T covar_det(const F &, const covar_type &c)
Compute the determinant of the covariance matrix (metric tensor) at a point.
static T sqr_distance_deriv(const F &pt1, const F &pt2, const covar_type &c, vector &g)
Compute the square Mahalanobis distance and also the derivative g wrt pt1.
static T distance(const F &pt1, const F &pt2, const covar_type &c)
Compute the Mahalanobis distance between two points.
static T sqr_distance(const F &pt1, const F &pt2, const covar_type &c)
Compute the square Mahalanobis distance between two points.
static void compute_covar(matrix &covar, const F &pt, const covar_type &c)
Compute the covariance matrix (metric tensor) at a point.
static T sqr_distance_deriv(const F &pt1, const F &pt2, const covar_type &c, vector &g)
Compute the square Mahalanobis distance and also the derivative g wrt pt1.
static T sqr_distance(const F &pt1, const F &pt2, const covar_type &c)
Compute the square Mahalanobis distance between two points.
static T covar_det(const F &, const covar_type &c)
Compute the determinant of the covariance matrix (metric tensor) at a point.
static T sqr_distance_deriv(const F &pt1, const F &pt2, const covar_type &c, vector &g)
Compute the square Mahalanobis distance and also the derivative g wrt pt1.
T & vpdt_index(vnl_vector< T > &v, unsigned int i)
Index into a vnl_vector.
vpdt_field_traits< F >::vector_type covar_type
the data type used for the metric tensor.
static T distance(const F &pt1, const F &pt2, const covar_type &c)
Compute the Mahalanobis distance between two points.
vpdt_field_traits< F >::matrix_type matrix
the data type used for matrices.
vpdt_field_traits< F >::vector_type vector
the data type used for vectors.
vpdt_field_traits< F >::matrix_type matrix
the data type used for matrices.
vpdt_field_traits< F >::scalar_type covar_type
the data type used for the metric tensor.
static void compute_covar(matrix &covar, const F &, const covar_type &c)
Compute the covariance matrix (metric tensor) at a point.
static T sqr_distance_deriv(const F &pt1, const F &pt2, const covar_type &c, vector &g)
Compute the square Mahalanobis distance and also the derivative g wrt pt1.
vpdt_field_traits< F >::vector_type vector
the data type used for vectors.
specialized template trait classes for properties of a field type
vpdt_field_traits< F >::scalar_type T
the data type used for scalars.
vpdt_field_traits< F >::vector_type vector
the data type used for vectors.
void vpdt_set_size(vnl_vector< T > &v, unsigned int s)
Set the size of a vnl_vector.
The field traits class (scalar).
static T distance(const F &pt1, const F &pt2, const covar_type &c)
Compute the Mahalanobis distance between two points.
generate the vpdt_eigen_sys_matrix type from a field type.
vpdt_field_traits< F >::matrix_type matrix
the data type used for matrices.
vpdt_field_traits< F >::scalar_type T
the data type used for scalars.
Overloaded functions to allow uniform API access to various field types.
static void compute_covar(matrix &covar, const F &, const covar_type &c)
Compute the covariance matrix (metric tensor) at a point.
A metric in field F with metric tensor Tensor.
A symmetric matrix represented in eigenvalue decomposition.
static void compute_covar(matrix &covar, const F &, const covar_type &c)
Compute the covariance matrix (metric tensor) at a point.
vpdt_eigen_sym_matrix_gen< F >::type covar_type
the data type used for the metric tensor.
unsigned int vpdt_size(const vnl_vector< T > &v)
Access the size of a vnl_vector.
vpdt_field_traits< F >::scalar_type T
the data type used for scalars.
static T covar_det(const F &pt, const covar_type &c)
Compute the determinant of the covariance matrix (metric tensor) at a point.