vpdt_field_traits.h
Go to the documentation of this file.
1 // This is core/vpdl/vpdt/vpdt_field_traits.h
2 #ifndef vpdt_field_traits_h_
3 #define vpdt_field_traits_h_
4 //:
5 // \file
6 // \author Matthew Leotta
7 // \brief specialized template trait classes for properties of a field type
8 // \date March 5, 2009
9 //
10 // Each type of object upon which you define a field for a probability
11 // distribution requires a field traits class. The field traits determine
12 // the dimension, scalar type, field type, vector type, matrix type, etc to be used.
13 //
14 // \verbatim
15 // Modifications
16 // None
17 // \endverbatim
18 
19 #include <vnl/vnl_vector.h>
20 #include <vnl/vnl_matrix.h>
21 #include <vnl/vnl_vector_fixed.h>
22 #include <vnl/vnl_matrix_fixed.h>
23 #include <cassert>
24 #ifdef _MSC_VER
25 # include <vcl_msvc_warnings.h>
26 #endif
27 
28 
29 //: The field traits class (scalar)
30 // The default is to treat it as a 1-d (scalar) field
31 template <class T>
33 {
34  //: The compile time dimension of the field
35  static const unsigned int dimension = 1;
36  //: The type used for scalar operations
37  typedef T scalar_type;
38  //: the data type to represent a point in the field
39  typedef T field_type;
40  //: the data type used for vectors (difference between points)
41  typedef T vector_type;
42  //: the data type used for square matrices
43  typedef T matrix_type;
44 
45  //: use this to disambiguate templates
46  typedef void type_is_scalar;
47 };
48 
49 
50 //: The field traits class (vnl_vector_fixed)
51 // This specialization is for fixed length vnl vectors
52 template <class T, unsigned int n>
54 {
55  //: The compile time dimension of the field
56  static const unsigned int dimension = n;
57  //: The type used for scalar operations
58  typedef T scalar_type;
59  //: the data type to represent a point in the field
61  //: the data type used for vectors (difference between points)
63  //: the data type used for square matrices
65 
66  //: use this to disambiguate templates
67  typedef void type_is_vector;
68 };
69 
70 
71 //: The field traits class (vnl_vector)
72 // This specialization is for variable length vnl vectors
73 // \note dimension of 0 indicates variable dimension at run time
74 template <class T>
76 {
77  //: The compile time dimension of the field
78  static const unsigned int dimension = 0;
79  //: The type used for scalar operations
80  typedef T scalar_type;
81  //: the data type to represent a point in the field
83  //: the data type used for vectors (difference between points)
85  //: the data type used for square matrices
87 
88  //: use this to disambiguate templates
89  typedef void type_is_vector;
90 };
91 
92 
93 
94 #endif // vpdt_field_traits_h_
T field_type
the data type to represent a point in the field.
T vector_type
the data type used for vectors (difference between points).
vnl_vector_fixed< T, n > field_type
the data type to represent a point in the field.
vnl_vector< T > vector_type
the data type used for vectors (difference between points).
void type_is_scalar
use this to disambiguate templates.
vnl_vector< T > field_type
the data type to represent a point in the field.
T scalar_type
The type used for scalar operations.
static const unsigned int dimension
The compile time dimension of the field.
T scalar_type
The type used for scalar operations.
T matrix_type
the data type used for square matrices.
vnl_matrix_fixed< T, n, n > matrix_type
the data type used for square matrices.
void type_is_vector
use this to disambiguate templates.
The field traits class (scalar).
vnl_vector_fixed< T, n > vector_type
the data type used for vectors (difference between points).
void type_is_vector
use this to disambiguate templates.
T scalar_type
The type used for scalar operations.
vnl_matrix< T > matrix_type
the data type used for square matrices.