ITK/Examples/SimpleOperations/NumericTraits

From KitwarePublic
< ITK‎ | Examples
Revision as of 17:56, 25 January 2011 by Daviddoria (talk | contribs) (Created page with "==NumericTraits.cxx== <source lang="cpp"> #include "itkNumericTraits.h" int main(int, char* [] ) { std::cout << "Min: " << itk::NumericTraits< float >::min() << std::endl; s...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

NumericTraits.cxx

<source lang="cpp">

  1. include "itkNumericTraits.h"

int main(int, char* [] ) {

 std::cout << "Min: " << itk::NumericTraits< float >::min() << std::endl;
 std::cout << "Max: " << itk::NumericTraits< float >::max() << std::endl;
 std::cout << "Zero: " << itk::NumericTraits< float >::Zero << std::endl;
 std::cout << "Zero: " << itk::NumericTraits< float >::ZeroValue() << std::endl;
 std::cout << "Is -1 negative? " << itk::NumericTraits< float >::IsNegative(-1) << std::endl;
 std::cout << "Is 1 negative? " << itk::NumericTraits< float >::IsNegative(1) << std::endl;
 std::cout << "One: " << itk::NumericTraits< float >::One << std::endl;
 std::cout << "Epsilon: " << itk::NumericTraits< float >::epsilon() << std::endl;
 std::cout << "Infinity: " << itk::NumericTraits< float >::infinity() << std::endl;
 if(0 == itk::NumericTraits< float >::infinity())
   {
   std::cout << " 0 == inf!" << std::endl;
   }
 else
   {
   std::cout << "Good" << std::endl;
   }
   
 return EXIT_SUCCESS;

} </source>

CMakeLists.txt

<source lang="cmake"> cmake_minimum_required(VERSION 2.6)

PROJECT(NumericTraits)

FIND_PACKAGE(ITK REQUIRED) INCLUDE(${ITK_USE_FILE})

ADD_EXECUTABLE(NumericTraits NumericTraits.cxx) TARGET_LINK_LIBRARIES(NumericTraits ITKBasicFilters ITKCommon ITKIO ITKStatistics)

</source>