ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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
24namespace itk
25{
29template <typename T>
31{
32private:
38
39public:
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 return Self(a.Size(), NumericTraits<T>::max());
75 }
76
77 static const Self
78 min(const Self & a)
79 {
80 return Self(a.Size(), NumericTraits<T>::min());
81 }
82
83 static const Self
84 ZeroValue(const Self & a)
85 {
86 return Self(a.Size(), T{});
87 }
88
89 static const Self
90 OneValue(const Self & a)
91 {
93 }
94
95 static const Self
97 {
99 }
100
101 static constexpr bool IsSigned = std::is_signed_v<ValueType>;
102 static constexpr bool IsInteger = std::is_integral_v<ValueType>;
104
106 static void
107 SetLength(Array<T> & m, const unsigned int s)
108 {
109 m.SetSize(s);
110 m.Fill(T{});
111 }
112
114 static size_t
116 {
117 return m.GetSize();
118 }
119
120 static void
122 {
123 mv = v;
124 }
125
126 template <typename TArray>
127 static void
128 AssignToArray(const Self & v, TArray & mv)
129 {
130 for (unsigned int i = 0; i < GetLength(v); ++i)
131 {
132 mv[i] = v[i];
133 }
134 }
135};
136} // end namespace itk
137
138#endif // itkNumericTraitsArrayPixel_h
Array class with size defined at construction time.
Definition itkArray.h:48
SizeValueType Size() const
Definition itkArray.h:130
SizeValueType GetSize() const
Definition itkArray.h:159
void Fill(const TValue &v)
Definition itkArray.h:115
void SetSize(SizeValueType sz)
typename NumericTraits< T >::RealType ElementRealType
Array< ElementAccumulateType > AccumulateType
static const Self NonpositiveMin(const Self &a)
typename NumericTraits< T >::AbsType ElementAbsType
static void SetLength(Array< T > &m, const unsigned int s)
static vcl_size_t GetLength(const Array< T > &m)
static const Self ZeroValue(const Self &a)
static void AssignToArray(const Self &v, MeasurementVectorType &mv)
typename NumericTraits< T >::PrintType ElementPrintType
static void AssignToArray(const Self &v, TArray &mv)
static const Self max(const Self &a)
typename NumericTraits< T >::FloatType ElementFloatType
static const Self min(const Self &a)
typename NumericTraits< T >::AccumulateType ElementAccumulateType
static const Self OneValue(const Self &a)
Define additional traits for native types such as int or float.
static constexpr T NonpositiveMin()
static constexpr T max(const T &)
static constexpr T min(const T &)
static constexpr unsigned int GetLength()
static constexpr bool IsComplex
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....