[Insight-users] numeric traits for the std::complex < >

Suyash P. Awate suyash at cs.utah.edu
Tue May 10 12:32:47 EDT 2005


Well, on closer inspection there is a difference between what I did and 
what you suggested.
I am not inheriting the class from vcl_numeric_limits. I made this class 
after looking at other similar classes in the ITK source files.

Also, when defining the Zero and One for complex numbers we should 
probably give two arguments, for the real and imaginary parts, instead 
of one. So perhaps the files I sent you contain this bug.

Best regards,
Suyash.


Suyash P. Awate wrote:

>
> Hello Jim,
>
> Yes, this is exactly what I did.
> I am attaching the .h and .cxx files for this class in this email.
> It would be great if these can be included in the ITK source.
>
> Thanks.
>
> Best regards,
> Suyash.
>
>
> Miller, James V (Research) wrote:
>
>>Suyash, 
>>
>>I am guessing your solution was to provide a specialization for 
>>NumericTraits<std::complex<double> >.  Something like...
>>
>>template <>
>>class NumericTraits<std::complex<double> > : public vcl_numeric_limits<std::complex<double> > {
>>public:
>>  typedef long std::complex<double> ValueType;
>>  typedef long std::complex<double> PrintType;
>>...
>>};
>>
>>If this was your solution, then if you send us your specialization code, we'll check it into 
>>itk::NumericTraits
>>
>>Jim
>>
>>
>>-----Original Message-----
>>From: insight-users-bounces+millerjv=crd.ge.com at itk.org
>>[mailto:insight-users-bounces+millerjv=crd.ge.com at itk.org]On Behalf Of
>>Suyash P. Awate
>>Sent: Monday, May 09, 2005 3:39 PM
>>To: insight-users at public.kitware.com
>>Subject: [Insight-users] numeric traits for the std::complex < >
>>
>>
>>
>>Hello,
>>
>>I needed to use a vector of std::complex<double> in ITK and had some
>>compilation errors, i.e.
>>---
>>no type named `RealType' in `class
>>itk::NumericTraits<std::complex<double> >'
>>---
>>
>>I solved the problem by writing my own NumericTraits class for this
>>datatype and my program compiles now. However, I was wondering if this
>>was the right way to solve the problem. Also, was there something
>>already existing in ITK that I could was used to obtain a more elegant
>>solution ?
>>
>>I would appreciate any help with this. Thanks.
>>
>>Best regards,
>>Suyash.
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users at itk.org
>>http://www.itk.org/mailman/listinfo/insight-users
>>  
>>
>------------------------------------------------------------------------
>
>/*=========================================================================
>
>  Program:   Insight Segmentation & Registration Toolkit
>  Module:    $RCSfile: itkNumericTraitsComplex.cxx,v $
>  Language:  C++
>  Date:      $Date: 2005/01/09 15:58:08 $
>  Version:   $Revision: 1.3 $
>
>  Copyright (c) Insight Software Consortium. All rights reserved.
>  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
>
>     This software is distributed WITHOUT ANY WARRANTY; without even 
>     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
>     PURPOSE.  See the above copyright notices for more information.
>
>=========================================================================*/
>#include "itkNumericTraitsComplex.h"
>
>namespace itk
>{
>
>const std::complex<double>  NumericTraits<std::complex<double> >::Zero = std::complex<double>( NumericTraits<double>::Zero );
>const std::complex<double>  NumericTraits<std::complex<double> >::One  = std::complex<double>( NumericTraits<double>::One );
> 
>} // end namespace itk
>  
>
>------------------------------------------------------------------------
>
>/*=========================================================================
>
>  Program:   Insight Segmentation & Registration Toolkit
>  Module:    $RCSfile: itkNumericTraitsComplex.h,v $
>  Language:  C++
>  Date:      $Date: 2005/01/09 15:58:08 $
>  Version:   $Revision: 1.6 $
>
>  Copyright (c) Insight Software Consortium. All rights reserved.
>  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
>
>     This software is distributed WITHOUT ANY WARRANTY; without even 
>     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
>     PURPOSE.  See the above copyright notices for more information.
>
>=========================================================================*/
>#ifndef __itkNumericTraitsComplex_h
>#define __itkNumericTraitsComplex_h
>
>#include "itkNumericTraits.h"
>#include <complex>
>
>namespace itk
>{
>
>/** \class NumericTraits<std::complex<double> >
> * \brief Define traits for type std::complex<double>.
> * \ingroup DataRepresentation
> */
>template <>
>class NumericTraits<std::complex<double> > {
>public:
>  typedef std::complex<double> ValueType;
>  typedef std::complex<double> PrintType;
>  typedef std::complex<double> AbsType;
>  typedef std::complex<double> AccumulateType;
>  typedef std::complex<double> RealType;
>  static const std::complex<double> ITKCommon_EXPORT Zero;
>  static const std::complex<double> ITKCommon_EXPORT One;
>  
>};
>
>} // end namespace itk
>
>#endif // __itkNumericTraitscomplex_h
>  
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20050510/cfaf1810/attachment.html


More information about the Insight-users mailing list