KrisLibrary  1.0.0
metric.h
Go to the documentation of this file.
1 #ifndef MATH_METRIC_H
2 #define MATH_METRIC_H
3 
4 #include "VectorTemplate.h"
5 #include "MatrixTemplate.h"
6 
12 namespace Math {
13 
16 
19 template <class T>
21 {
22  public:
23  explicit NormAccumulator(Real exponent=2.0);
24  void collect(T val);
25  void collect(T val,Real weight);
26  T norm() const;
27  T normSquared() const;
28  inline void operator << (T val) { collect(val); }
29  inline operator T () const { return norm(); }
30 
31  Real exponent;
32  T data;
33 };
34 
35 template<class T>
36 T Norm(const VectorTemplate<T>& x,Real norm);
37 template<class T>
38 T Norm_L1(const VectorTemplate<T>& x);
39 template<class T>
40 T Norm_L2(const VectorTemplate<T>& x);
42 template<class T>
43 T Norm_L2_Safe(const VectorTemplate<T>& x);
44 template<class T>
45 T Norm_LInf(const VectorTemplate<T>& x);
46 template<class T>
47 T Norm_Mahalanobis(const VectorTemplate<T>& x,const MatrixTemplate<T>& A);
48 template<class T>
49 T Norm_Weighted(const VectorTemplate<T>& x,Real norm,const VectorTemplate<T>& w);
50 template<class T>
51 T Norm_WeightedL1(const VectorTemplate<T>& x,const VectorTemplate<T>& w);
52 template<class T>
53 T Norm_WeightedL2(const VectorTemplate<T>& x,const VectorTemplate<T>& w);
54 template<class T>
55 T Norm_WeightedLInf(const VectorTemplate<T>& x,const VectorTemplate<T>& w);
56 
57 template<class T>
58 T Distance(const VectorTemplate<T>& x,const VectorTemplate<T>& y,Real norm);
59 template<class T>
60 T Distance_L1(const VectorTemplate<T>& x,const VectorTemplate<T>& y);
61 template<class T>
62 T Distance_L2(const VectorTemplate<T>& x,const VectorTemplate<T>& y);
64 template<class T>
65 T Distance_L2_Safe(const VectorTemplate<T>& x,const VectorTemplate<T>& y);
66 template<class T>
67 T Distance_LInf(const VectorTemplate<T>& x,const VectorTemplate<T>& y);
68 template<class T>
69 T Distance_Mahalanobis(const VectorTemplate<T>& x,const VectorTemplate<T>& y,const MatrixTemplate<T>& A);
70 template<class T>
71 T Distance_Weighted(const VectorTemplate<T>& x,const VectorTemplate<T>& y,Real norm,const VectorTemplate<T>& w);
72 template<class T>
73 T Distance_WeightedL1(const VectorTemplate<T>& x,const VectorTemplate<T>& y,const VectorTemplate<T>& w);
74 template<class T>
75 T Distance_WeightedL2(const VectorTemplate<T>& x,const VectorTemplate<T>& y,const VectorTemplate<T>& w);
76 template<class T>
77 T Distance_WeightedLInf(const VectorTemplate<T>& x,const VectorTemplate<T>& y,const VectorTemplate<T>& w);
78 
79 template<class T>
80 T Norm_L1(const MatrixTemplate<T>& A);
81 template<class T>
82 T Norm_LInf(const MatrixTemplate<T>& A);
83 template<class T>
84 T Norm_Frobenius(const MatrixTemplate<T>& A);
86 template<class T>
87 T Norm_Frobenius_Safe(const MatrixTemplate<T>& A);
88 
89 template<class T>
90 T Distance_L1(const MatrixTemplate<T>& A,const MatrixTemplate<T>& B);
91 template<class T>
92 T Distance_LInf(const MatrixTemplate<T>& A,const MatrixTemplate<T>& B);
93 template<class T>
94 T Distance_Frobenius(const MatrixTemplate<T>& A,const MatrixTemplate<T>& B);
96 template<class T>
97 T Distance_Frobenius_Safe(const MatrixTemplate<T>& A,const MatrixTemplate<T>& B);
98 
100 } //namespace Math
101 
102 #endif
A matrix over the field T.
Definition: function.h:10
Contains all definitions in the Math package.
Definition: WorkspaceBound.h:12
A vector over the field T.
Definition: function.h:9
Definition: metric.h:20