LpNorm.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_FUNCTORS_LPNORM_H_
36 #define _BLAZE_MATH_FUNCTORS_LPNORM_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/system/Inline.h>
45 
46 
47 namespace blaze {
48 
49 //=================================================================================================
50 //
51 // CLASS DEFINITION
52 //
53 //=================================================================================================
54 
55 //*************************************************************************************************
59 template< size_t... P > // Compile time norm parameter
60 struct LpNorm
61 {
62  //**********************************************************************************************
65  explicit inline LpNorm()
66  {}
67  //**********************************************************************************************
68 
69  //**********************************************************************************************
75  template< typename T >
76  BLAZE_ALWAYS_INLINE decltype(auto) operator()( const T& a ) const
77  {
78  BLAZE_STATIC_ASSERT_MSG( sizeof...( P ) == 1UL, "Missing norm parameter detected" );
79  return lpNorm( a, P... );
80  }
81  //**********************************************************************************************
82 
83  //**********************************************************************************************
90  template< typename T, typename ST >
91  BLAZE_ALWAYS_INLINE decltype(auto) operator()( const T& a, ST p ) const
92  {
93  BLAZE_STATIC_ASSERT_MSG( sizeof...( P ) == 0UL, "Over-specified norm parameter detected" );
94  return lpNorm( a, p );
95  }
96  //**********************************************************************************************
97 };
98 //*************************************************************************************************
99 
100 
101 
102 
103 //=================================================================================================
104 //
105 // CLASS SPECIALIZATIONS
106 //
107 //=================================================================================================
108 
109 //*************************************************************************************************
114 template<>
115 struct LpNorm<1UL>
116 {
117  //**********************************************************************************************
120  explicit inline LpNorm()
121  {}
122  //**********************************************************************************************
123 
124  //**********************************************************************************************
130  template< typename T >
131  BLAZE_ALWAYS_INLINE decltype(auto) operator()( const T& a ) const
132  {
133  return l1Norm( a );
134  }
135  //**********************************************************************************************
136 };
138 //*************************************************************************************************
139 
140 
141 //*************************************************************************************************
146 template<>
147 struct LpNorm<2UL>
148 {
149  //**********************************************************************************************
152  explicit inline LpNorm()
153  {}
154  //**********************************************************************************************
155 
156  //**********************************************************************************************
162  template< typename T >
163  BLAZE_ALWAYS_INLINE decltype(auto) operator()( const T& a ) const
164  {
165  return l2Norm( a );
166  }
167  //**********************************************************************************************
168 };
170 //*************************************************************************************************
171 
172 
173 //*************************************************************************************************
178 template<>
179 struct LpNorm<3UL>
180 {
181  //**********************************************************************************************
184  explicit inline LpNorm()
185  {}
186  //**********************************************************************************************
187 
188  //**********************************************************************************************
194  template< typename T >
195  BLAZE_ALWAYS_INLINE decltype(auto) operator()( const T& a ) const
196  {
197  return l3Norm( a );
198  }
199  //**********************************************************************************************
200 };
202 //*************************************************************************************************
203 
204 
205 //*************************************************************************************************
210 template<>
211 struct LpNorm<4UL>
212 {
213  //**********************************************************************************************
216  explicit inline LpNorm()
217  {}
218  //**********************************************************************************************
219 
220  //**********************************************************************************************
226  template< typename T >
227  BLAZE_ALWAYS_INLINE decltype(auto) operator()( const T& a ) const
228  {
229  return l4Norm( a );
230  }
231  //**********************************************************************************************
232 };
234 //*************************************************************************************************
235 
236 } // namespace blaze
237 
238 #endif
decltype(auto) l3Norm(const DenseMatrix< MT, SO > &dm)
Computes the L3 norm for the given dense matrix.
Definition: DMatNormExpr.h:582
decltype(auto) l2Norm(const DenseMatrix< MT, SO > &dm)
Computes the L2 norm for the given dense matrix.
Definition: DMatNormExpr.h:556
decltype(auto) l4Norm(const DenseMatrix< MT, SO > &dm)
Computes the L4 norm for the given dense matrix.
Definition: DMatNormExpr.h:608
decltype(auto) lpNorm(const DenseMatrix< MT, SO > &dm, ST p)
Computes the Lp norm for the given dense matrix.
Definition: DMatNormExpr.h:640
#define BLAZE_STATIC_ASSERT_MSG(expr, msg)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:123
decltype(auto) BLAZE_ALWAYS_INLINE operator()(const T &a) const
Calls the lpNorm() function with the given object/value.
Definition: LpNorm.h:76
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Compile time assertion.
decltype(auto) l1Norm(const DenseMatrix< MT, SO > &dm)
Computes the L1 norm for the given dense matrix.
Definition: DMatNormExpr.h:530
LpNorm()
Default constructor of the LpNorm functor.
Definition: LpNorm.h:65
Generic wrapper for the lpNorm() function.
Definition: Forward.h:97
System settings for the inline keywords.