core/vnl/vnl_rational_traits.h
Go to the documentation of this file.
00001 // This is core/vnl/vnl_rational_traits.h
00002 #ifndef vnl_rational_traits_h_
00003 #define vnl_rational_traits_h_
00004 //:
00005 // \file
00006 // \brief numeric traits for vnl_rational
00007 
00008 #include <vnl/vnl_rational.h>
00009 #include <vnl/vnl_numeric_traits.h>
00010 #include <vcl_iosfwd.h>
00011 
00012 VCL_DEFINE_SPECIALIZATION
00013 class vnl_numeric_traits<vnl_rational>
00014 {
00015  public:
00016   //: Additive identity
00017   static const vnl_rational zero; // = 0L
00018   //: Multiplicative identity
00019   static const vnl_rational one; // = 1L
00020   //: Maximum value which this type can assume
00021   static const vnl_rational maxval; // = vnl_numeric_traits<long>::maxval;
00022   //: Return value of abs()
00023   typedef vnl_rational abs_t;
00024   //: Name of a type twice as long as this one for accumulators and products.
00025   typedef vnl_rational double_t;
00026   //: Name of type which results from multiplying this type with a double.
00027   //  Note that this requires an explicit cast from double to vnl_rational.
00028   //  This must be a built-in type: do not set this to vnl_rational, since
00029   //  that would require std::sqrt(vnl_rational) etc., which is not allowed.
00030   typedef double real_t;
00031 };
00032 
00033 #if !VCL_CANNOT_SPECIALIZE_CV
00034 VCL_DEFINE_SPECIALIZATION
00035 class vnl_numeric_traits<vnl_rational const> : public vnl_numeric_traits<vnl_rational>
00036 {
00037 };
00038 #endif
00039 
00040 vcl_ostream& operator<<(vcl_ostream&, vcl_complex<vnl_rational>);
00041 
00042 VCL_DEFINE_SPECIALIZATION
00043 class vnl_numeric_traits<vcl_complex<vnl_rational> >
00044 {
00045  public:
00046   //: Additive identity
00047   static const vcl_complex<vnl_rational> zero; // = vcl_complex<vnl_rational>(0L,0L)
00048   //: Multiplicative identity
00049   static const vcl_complex<vnl_rational> one; // = vcl_complex<vnl_rational>(1L,0L)
00050   //: Maximum value which this type can assume; makes no sense for this type
00051   static const vcl_complex<vnl_rational> maxval;
00052   //: Return value of abs()
00053   typedef vnl_rational abs_t;
00054   //: Name of a type twice as long as this one for accumulators and products.
00055   typedef vcl_complex<vnl_rational> double_t;
00056   //: Name of type which results from multiplying this type with a double
00057   typedef vcl_complex<vnl_rational> real_t; // should be vcl_complex<double>, but that gives casting problems
00058 };
00059 
00060 #if !VCL_CANNOT_SPECIALIZE_CV
00061 VCL_DEFINE_SPECIALIZATION
00062 class vnl_numeric_traits<vcl_complex<vnl_rational> const> : public vnl_numeric_traits<vcl_complex<vnl_rational> >
00063 {
00064 };
00065 #endif
00066 
00067 vnl_rational vnl_math_squared_magnitude(vcl_complex<vnl_rational> const& );
00068 vnl_rational vnl_math_abs(vcl_complex<vnl_rational> const& );
00069 
00070 #endif // vnl_rational_traits_h_