File: vnl_rational_traits.h

package info (click to toggle)
insighttoolkit 3.20.1%2Bgit20120521-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 80,652 kB
  • sloc: cpp: 458,133; ansic: 196,223; fortran: 28,000; python: 3,839; tcl: 1,811; sh: 1,184; java: 583; makefile: 430; csh: 220; perl: 193; xml: 20
file content (70 lines) | stat: -rw-r--r-- 2,474 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// This is core/vnl/vnl_rational_traits.h
#ifndef vnl_rational_traits_h_
#define vnl_rational_traits_h_
//:
// \file
// \brief numeric traits for vnl_rational

#include <vnl/vnl_rational.h>
#include <vnl/vnl_numeric_traits.h>
#include <vcl_iosfwd.h>

VCL_DEFINE_SPECIALIZATION
class vnl_numeric_traits<vnl_rational>
{
 public:
  //: Additive identity
  static const vnl_rational zero; // = 0L
  //: Multiplicative identity
  static const vnl_rational one; // = 1L
  //: Maximum value which this type can assume
  static const vnl_rational maxval; // = vnl_numeric_traits<long>::maxval;
  //: Return value of abs()
  typedef vnl_rational abs_t;
  //: Name of a type twice as long as this one for accumulators and products.
  typedef vnl_rational double_t;
  //: Name of type which results from multiplying this type with a double.
  //  Note that this requires an explicit cast from double to vnl_rational.
  //  This must be a built-in type: do not set this to vnl_rational, since
  //  that would require std::sqrt(vnl_rational) etc., which is not allowed.
  typedef double real_t;
};

#if !VCL_CANNOT_SPECIALIZE_CV
VCL_DEFINE_SPECIALIZATION
class vnl_numeric_traits<vnl_rational const> : public vnl_numeric_traits<vnl_rational>
{
};
#endif

vcl_ostream& operator<<(vcl_ostream&, vcl_complex<vnl_rational>);

VCL_DEFINE_SPECIALIZATION
class vnl_numeric_traits<vcl_complex<vnl_rational> >
{
 public:
  //: Additive identity
  static const vcl_complex<vnl_rational> zero; // = vcl_complex<vnl_rational>(0L,0L)
  //: Multiplicative identity
  static const vcl_complex<vnl_rational> one; // = vcl_complex<vnl_rational>(1L,0L)
  //: Maximum value which this type can assume; makes no sense for this type
  static const vcl_complex<vnl_rational> maxval;
  //: Return value of abs()
  typedef vnl_rational abs_t;
  //: Name of a type twice as long as this one for accumulators and products.
  typedef vcl_complex<vnl_rational> double_t;
  //: Name of type which results from multiplying this type with a double
  typedef vcl_complex<vnl_rational> real_t; // should be vcl_complex<double>, but that gives casting problems
};

#if !VCL_CANNOT_SPECIALIZE_CV
VCL_DEFINE_SPECIALIZATION
class vnl_numeric_traits<vcl_complex<vnl_rational> const> : public vnl_numeric_traits<vcl_complex<vnl_rational> >
{
};
#endif

vnl_rational vnl_math_squared_magnitude(vcl_complex<vnl_rational> const& );
vnl_rational vnl_math_abs(vcl_complex<vnl_rational> const& );

#endif // vnl_rational_traits_h_