ITK  5.4.0
Insight Toolkit
itkNumericTraitsArrayPixel.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkNumericTraitsArrayPixel_h
19 #define itkNumericTraitsArrayPixel_h
20 
21 #include "itkNumericTraits.h"
22 #include "itkArray.h"
23 
24 namespace itk
25 {
29 template <typename T>
31 {
32 private:
38 
39 public:
41  using ValueType = T;
42  using Self = Array<T>;
43 
46 
49 
53 
56 
59 
62 
65 
71  static const Self
72  max(const Self & a)
73  {
74  Self b(a.Size());
75 
77  return b;
78  }
79 
80  static const Self
81  min(const Self & a)
82  {
83  Self b(a.Size());
84 
86  return b;
87  }
88 
89  static const Self
90  ZeroValue(const Self & a)
91  {
92  Self b(a.Size());
93 
94  b.Fill(T{});
95  return b;
96  }
97 
98  static const Self
99  OneValue(const Self & a)
100  {
101  Self b(a.Size());
102 
104  return b;
105  }
106 
107  static const Self
108  NonpositiveMin(const Self & a)
109  {
110  Self b(a.Size());
112  return b;
113  }
114 
115  static constexpr bool IsSigned = std::is_signed_v<ValueType>;
116  static constexpr bool IsInteger = std::is_integral_v<ValueType>;
118 
120  static void
121  SetLength(Array<T> & m, const unsigned int s)
122  {
123  m.SetSize(s);
124  m.Fill(T{});
125  }
129  static size_t
130  GetLength(const Array<T> & m)
131  {
132  return m.GetSize();
133  }
134 
135  static void
137  {
138  mv = v;
139  }
140 
141  template <typename TArray>
142  static void
143  AssignToArray(const Self & v, TArray & mv)
144  {
145  for (unsigned int i = 0; i < GetLength(v); ++i)
146  {
147  mv[i] = v[i];
148  }
149  }
150 };
151 } // end namespace itk
152 
153 #endif // itkNumericTraitsArrayPixel_h
itk::NumericTraits< Array< T > >::NonpositiveMin
static const Self NonpositiveMin(const Self &a)
Definition: itkNumericTraitsArrayPixel.h:108
Self
AddImageFilter Self
Definition: itkAddImageFilter.h:89
itk::NumericTraits< Array< T > >::ElementFloatType
typename NumericTraits< T >::FloatType ElementFloatType
Definition: itkNumericTraitsArrayPixel.h:35
itk::NumericTraits::AccumulateType
double AccumulateType
Definition: itkNumericTraits.h:75
itk::NumericTraits< Array< T > >::ElementAccumulateType
typename NumericTraits< T >::AccumulateType ElementAccumulateType
Definition: itkNumericTraitsArrayPixel.h:34
itk::NumericTraits< Array< T > >::AssignToArray
static void AssignToArray(const Self &v, TArray &mv)
Definition: itkNumericTraitsArrayPixel.h:143
itk::NumericTraits::IsSigned
static constexpr bool IsSigned
Definition: itkNumericTraits.h:134
itk::NumericTraits::IsInteger
static constexpr bool IsInteger
Definition: itkNumericTraits.h:139
itk::NumericTraits< Array< T > >::GetLength
static vcl_size_t GetLength(const Array< T > &m)
Definition: itkNumericTraitsArrayPixel.h:130
itk::Array::GetSize
SizeValueType GetSize() const
Definition: itkArray.h:158
itk::NumericTraits< Array< T > >::OneValue
static const Self OneValue(const Self &a)
Definition: itkNumericTraitsArrayPixel.h:99
itk::NumericTraits< Array< T > >::ScalarRealType
ElementRealType ScalarRealType
Definition: itkNumericTraitsArrayPixel.h:61
itk::NumericTraits::PrintType
T PrintType
Definition: itkNumericTraits.h:69
itk::NumericTraits< Array< T > >::ValueType
T ValueType
Definition: itkNumericTraitsArrayPixel.h:41
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:59
itkArray.h
itk::NumericTraits< Array< T > >::ElementAbsType
typename NumericTraits< T >::AbsType ElementAbsType
Definition: itkNumericTraitsArrayPixel.h:33
itk::NumericTraits< Array< T > >::ElementPrintType
typename NumericTraits< T >::PrintType ElementPrintType
Definition: itkNumericTraitsArrayPixel.h:36
itk::NumericTraits< Array< T > >::ElementRealType
typename NumericTraits< T >::RealType ElementRealType
Definition: itkNumericTraitsArrayPixel.h:37
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::NumericTraits::GetLength
static unsigned int GetLength()
Definition: itkNumericTraits.h:209
itk::NumericTraits::IsComplex
static constexpr bool IsComplex
Definition: itkNumericTraits.h:144
itk::NumericTraits< Array< T > >::ZeroValue
static const Self ZeroValue(const Self &a)
Definition: itkNumericTraitsArrayPixel.h:90
itk::NumericTraits< Array< T > >::SetLength
static void SetLength(Array< T > &m, const unsigned int s)
Definition: itkNumericTraitsArrayPixel.h:121
itk::Array
Array class with size defined at construction time.
Definition: itkArray.h:47
itkNumericTraits.h
itk::Array::Size
SizeValueType Size() const
Definition: itkArray.h:128
itk::NumericTraits::RealType
double RealType
Definition: itkNumericTraits.h:85
itk::NumericTraits< Array< T > >::max
static const Self max(const Self &a)
Definition: itkNumericTraitsArrayPixel.h:72
AddImageFilter
Definition: itkAddImageFilter.h:81
itk::NumericTraits< Array< T > >::min
static const Self min(const Self &a)
Definition: itkNumericTraitsArrayPixel.h:81
itk::NumericTraits::FloatType
float FloatType
Definition: itkNumericTraits.h:82
itk::NumericTraits< Array< T > >::AssignToArray
static void AssignToArray(const Self &v, MeasurementVectorType &mv)
Definition: itkNumericTraitsArrayPixel.h:136
itk::NumericTraits::AbsType
T AbsType
Definition: itkNumericTraits.h:72
itk::Array::SetSize
void SetSize(SizeValueType sz)
itk::Array::Fill
void Fill(TValue const &v)
Definition: itkArray.h:114