2525
2626namespace itk
2727{
28- template <typename T, unsigned int VImageDimension>
29- RieszRotationMatrix<T, VImageDimension>::RieszRotationMatrix()
28+ template <unsigned int VImageDimension>
29+ RieszRotationMatrix<VImageDimension>::RieszRotationMatrix()
3030 : Superclass()
3131 , m_SpatialRotationMatrix()
3232 ,
3333
34- m_MaxAbsoluteDifferenceCloseToZero (1 * itk::NumericTraits<ValueType >::epsilon())
34+ m_MaxAbsoluteDifferenceCloseToZero (1 * itk::NumericTraits<RealType >::epsilon())
3535
3636{}
3737
38- template <typename T, unsigned int VImageDimension>
39- RieszRotationMatrix<T, VImageDimension>::RieszRotationMatrix(const Self & rieszMatrix)
38+ template <unsigned int VImageDimension>
39+ RieszRotationMatrix<VImageDimension>::RieszRotationMatrix(const Self & rieszMatrix)
4040 : Superclass(rieszMatrix)
4141 , m_SpatialRotationMatrix(rieszMatrix.GetSpatialRotationMatrix())
4242 , m_Order(rieszMatrix.GetOrder())
4343 , m_Components(rieszMatrix.GetComponents())
44- , m_MaxAbsoluteDifferenceCloseToZero(1 * itk::NumericTraits<ValueType >::epsilon())
44+ , m_MaxAbsoluteDifferenceCloseToZero(1 * itk::NumericTraits<RealType >::epsilon())
4545
4646{}
4747
48- template <typename T, unsigned int VImageDimension>
49- RieszRotationMatrix<T, VImageDimension>::RieszRotationMatrix(const SpatialRotationMatrixType & spatialRotationMatrix,
50- const unsigned int & order)
48+ template <unsigned int VImageDimension>
49+ RieszRotationMatrix<VImageDimension>::RieszRotationMatrix(const SpatialRotationMatrixType & spatialRotationMatrix,
50+ const unsigned int & order)
5151 : Superclass()
5252 , m_SpatialRotationMatrix(spatialRotationMatrix)
53- , m_MaxAbsoluteDifferenceCloseToZero(1 * itk::NumericTraits<ValueType >::epsilon())
53+ , m_MaxAbsoluteDifferenceCloseToZero(1 * itk::NumericTraits<RealType >::epsilon())
5454
5555{
5656 this ->SetOrder (order);
5757 this ->ComputeSteerableMatrix ();
5858}
5959
60- template <typename T, unsigned int VImageDimension>
60+ template <unsigned int VImageDimension>
6161template <typename TInputValue>
6262std::vector<TInputValue>
63- RieszRotationMatrix<T, VImageDimension>::MultiplyWithVector(const std::vector<TInputValue> & vect) const
63+ RieszRotationMatrix<VImageDimension>::MultiplyWithVector(const std::vector<TInputValue> & vect) const
6464{
6565 unsigned int rows = this ->Rows ();
6666 unsigned int cols = this ->Cols ();
@@ -76,10 +76,10 @@ RieszRotationMatrix<T, VImageDimension>::MultiplyWithVector(const std::vector<TI
7676 return resultVector;
7777}
7878
79- template <typename T, unsigned int VImageDimension>
79+ template <unsigned int VImageDimension>
8080template <typename TInputValue>
8181itk::VariableSizeMatrix<TInputValue>
82- RieszRotationMatrix<T, VImageDimension>::MultiplyWithColumnMatrix(
82+ RieszRotationMatrix<VImageDimension>::MultiplyWithColumnMatrix(
8383 const itk::VariableSizeMatrix<TInputValue> & inputColumn) const
8484{
8585 unsigned int rows = this ->Rows ();
@@ -100,10 +100,10 @@ RieszRotationMatrix<T, VImageDimension>::MultiplyWithColumnMatrix(
100100 return columnMatrix;
101101}
102102
103- template <typename T, unsigned int VImageDimension>
103+ template <unsigned int VImageDimension>
104104template <typename TImage>
105105std::vector<typename TImage::Pointer>
106- RieszRotationMatrix<T, VImageDimension>::MultiplyWithVectorOfImages(
106+ RieszRotationMatrix<VImageDimension>::MultiplyWithVectorOfImages(
107107 const std::vector<typename TImage::Pointer> & vect) const
108108{
109109 unsigned int rows = this ->Rows ();
@@ -148,9 +148,9 @@ RieszRotationMatrix<T, VImageDimension>::MultiplyWithVectorOfImages(
148148 return result;
149149}
150150
151- template <typename T, unsigned int VImageDimension>
152- typename RieszRotationMatrix<T, VImageDimension>::IndicesMatrix
153- RieszRotationMatrix<T, VImageDimension>::GenerateIndicesMatrix()
151+ template <unsigned int VImageDimension>
152+ typename RieszRotationMatrix<VImageDimension>::IndicesMatrix
153+ RieszRotationMatrix<VImageDimension>::GenerateIndicesMatrix()
154154{
155155 using LocalIndicesArrayType = std::vector<unsigned int >;
156156 using LocalIndicesVector = std::vector<LocalIndicesArrayType>;
@@ -185,9 +185,9 @@ RieszRotationMatrix<T, VImageDimension>::GenerateIndicesMatrix()
185185 return allIndicesPairs;
186186}
187187
188- template <typename T, unsigned int VImageDimension>
189- const typename RieszRotationMatrix<T, VImageDimension>::InternalMatrixType &
190- RieszRotationMatrix<T, VImageDimension>::ComputeSteerableMatrix()
188+ template <unsigned int VImageDimension>
189+ const typename RieszRotationMatrix<VImageDimension>::InternalMatrixType &
190+ RieszRotationMatrix<VImageDimension>::ComputeSteerableMatrix()
191191{
192192 // precondition
193193 if (this ->m_Order == 0 )
@@ -198,7 +198,13 @@ RieszRotationMatrix<T, VImageDimension>::ComputeSteerableMatrix()
198198 InternalMatrixType & S = this ->GetVnlMatrix ();
199199 if (this ->m_Order == 1 )
200200 {
201- S = this ->GetSpatialRotationMatrix ().GetVnlMatrix ().as_matrix ();
201+ for (unsigned int i = 0 ; i < this ->m_Components ; ++i)
202+ {
203+ for (unsigned int j = 0 ; j < this ->m_Components ; ++j)
204+ {
205+ S.put (i, j, static_cast <ValueType>(m_SpatialRotationMatrix.GetVnlMatrix ().get (i, j)));
206+ }
207+ }
202208 return this ->GetVnlMatrix ();
203209 }
204210
@@ -291,19 +297,19 @@ RieszRotationMatrix<T, VImageDimension>::ComputeSteerableMatrix()
291297 // matrix R = [r1,...,rd], where r_i are columns of the rotation matrix.
292298 // we sum and normalize them.
293299 S[i][j] = 0 ;
294- long double result = 0 ;
295- long nFactorial = 1 ;
296- long mFactorial = 1 ;
300+ ResultValueType result = 0 ;
301+ long nFactorial = 1 ;
302+ long mFactorial = 1 ;
297303 for (unsigned int dim = 0 ; dim < VImageDimension; ++dim)
298304 {
299305 nFactorial *= itk::utils::Factorial (n[dim]);
300306 mFactorial *= itk::utils::Factorial (m[dim]);
301307 }
302- auto nFactorialReal = static_cast <double >(nFactorial);
308+ auto nFactorialReal = static_cast <RealType >(nFactorial);
303309 for (auto & kValidIndex : kValidIndices )
304310 {
305- long double rotationFactor = 1 ;
306- long kFactorialMultiplication = 1 ;
311+ ValueType rotationFactor = 1 ;
312+ long kFactorialMultiplication = 1 ;
307313 // There are always VImageDimension indices. (k1,k2,...,kd)
308314 for (unsigned int kIndex = 0 ; kIndex < VImageDimension; ++kIndex )
309315 {
@@ -335,12 +341,19 @@ RieszRotationMatrix<T, VImageDimension>::ComputeSteerableMatrix()
335341 result *= sqrt (mFactorial / nFactorialReal);
336342 S[i][j] = static_cast <ValueType>(result);
337343 // Try to fix close to zero float errors
338- if (itk::Math::FloatAlmostEqual (S[i][j],
339- static_cast <ValueType>(0 ),
344+ if (itk::Math::FloatAlmostEqual (S[i][j].real (),
345+ static_cast <typename ValueType::value_type>(0 ),
346+ 4 , // default maxULPS from Math::AlmostFloatEqual
347+ this ->m_MaxAbsoluteDifferenceCloseToZero ))
348+ {
349+ S[i][j].real (0 );
350+ }
351+ if (itk::Math::FloatAlmostEqual (S[i][j].imag (),
352+ static_cast <typename ValueType::value_type>(0 ),
340353 4 , // default maxULPS from Math::AlmostFloatEqual
341354 this ->m_MaxAbsoluteDifferenceCloseToZero ))
342355 {
343- S[i][j] = 0 ;
356+ S[i][j]. imag ( 0 ) ;
344357 }
345358
346359 if (this ->GetDebug ())
0 commit comments