[Insight-users] Error in vnl_sse template specializations (and fix)

Shashwath T.R. trshash at gmail.com
Tue May 17 04:28:56 EDT 2011


Hi all,

While compiling ITK master, I ran into this error:

1>D:\itk\ITK\Modules\ThirdParty\VNL\src\vxl\core\vnl/vnl_c_vector.txx(261) :
error C2039: 'arg_max' : is not a member of 'vnl_sse<double>'
1>        D:\itk\ITK\Modules\ThirdParty\VNL\src\vxl\core\vnl/vnl_sse.h(261)
: see declaration of 'vnl_sse<double>'
1>
D:\itk\ITK\Modules\ThirdParty\VNL\src\vxl\core\vnl/vnl_c_vector.txx(259) :
while compiling class template member function 'unsigned int
vnl_c_vector<T>::arg_max(const T *,unsigned int)'
1>        with
1>        [
1>            T=double
1>        ]
1>
..\..\..\..\..\..\..\..\ITK\Modules\ThirdParty\VNL\src\vxl\core\vnl\Templates\vnl_c_vector+double-.cxx(3)
: see reference to class template instantiation 'vnl_c_vector<T>' being
compiled
1>        with
1>        [
1>            T=double
1>        ]

Apparently, vnl_sse<float> and vnl_sse<double> are missing the methods
arg_min and arg_max. Adding them proved to be very simple - I simply copied
over the generic implementation and specialized it. I'm attaching my patch
below.

Could someone take a look and see if this is OK?

Regards,
Shash

diff --git a/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_sse.h
b/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_sse.h
index 5af0f7c..94138a5 100644
-- a/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_sse.h
++ b/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_sse.h
@@ -543,6 +543,27 @@ class vnl_sse<double>
    _mm_store_sd(&ret,min);
    return ret;
  }
 static VNL_SSE_FORCE_INLINE unsigned arg_max(const double* v, unsigned n)
 {
   if (n==0) return unsigned(-1); // the maximum of an empty set is
undefined
   double tmp = *v;
   unsigned idx = 0;
   for (unsigned i=1; i<n; ++i)
     if (*++v > tmp)
       tmp = *v, idx = i;
   return idx;
 }

 static VNL_SSE_FORCE_INLINE unsigned arg_min(const double* v, unsigned n)
 {
   if (n==0) return unsigned(-1); // the minimum of an empty set is
undefined
   double tmp = *v;
   unsigned idx = 0;
   for (unsigned i=1; i<n; ++i)
     if (*++v < tmp)
       tmp = *v, idx = i;
   return idx;
 }
};

//: SSE2 implementation for single precision floating point (32 bit)
@@ -880,6 +901,27 @@ class vnl_sse<float>

    return ret;
  }
static VNL_SSE_FORCE_INLINE unsigned arg_max(const float* v, unsigned n)
 {
   if (n==0) return unsigned(-1); // the maximum of an empty set is
undefined
   float tmp = *v;
   unsigned idx = 0;
   for (unsigned i=1; i<n; ++i)
     if (*++v > tmp)
       tmp = *v, idx = i;
   return idx;
 }

 static VNL_SSE_FORCE_INLINE unsigned arg_min(const float* v, unsigned n)
 {
   if (n==0) return unsigned(-1); // the minimum of an empty set is
undefined
   float tmp = *v;
   unsigned idx = 0;
   for (unsigned i=1; i<n; ++i)
     if (*++v < tmp)
       tmp = *v, idx = i;
   return idx;
 }
};

#endif // VNL_CONFIG_ENABLE_SSE2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110517/545f6d49/attachment.htm>


More information about the Insight-users mailing list