1 // This is core/vil/vil_na.h
2 #ifndef vil_na_h_
3 #define vil_na_h_
4 
5 //:
6 // \file
7 // \brief NA (Not Available) is a particular double NaN to represent missing data.
8 // For example, where a vnl_vector<double> represents a series of samples from an image,
9 // NA could be used to represent places where the measurement was taken outside the image.
10 //
11 // NA is distinct for the two other standard meanings of NaN - Indeterminate and Error.
12 // It is entirely up to each algorithm to treat NA values meaningfully. Unless
13 // a function's interpretation of NA is explicitly documented, you should assume that
14 // it will be treated similarly to every other NaN.
15 // The IEEE754 bit value used to represent NA in double-precision is 0x7ff00000000007a2, the
16 // same as used by Octave and R. Initial values of NA are stored as signalling NaNs, but
17 // many uses will convert this to the non-signalling variant 0x7ff80000000007a2. vil_na_isna()
18 // will accept either variant.
19 //
20 // The single precision NA is stored as 0x7f8007a2. I cannot find any external support for
21 // this or any other value for single precision NA. There is no automatic conversion between
22 // the NA values during casting, promotion, etc. If you want to convert a float to double,
23 // whilst preserving the NA-ness of the value, you will have to test for and set the new NA
24 // value explicitly.
25 //
26 // This file is a cut-and-paste of the essential sections of vnl_na, since vil is not
27 // allowed to depend upon vnl
28 
29 
30 
31 
32 //: qNaN to indicate value Not Available.
33 // Don't assume that any VXL functions will do something sensible in the face of NA, unless
34 // explicitly documented.
35 double   vil_na(double dummy);
36 
37 //: qNaN to indicate value Not Available.
38 // Don't assume that any VXL functions will do something sensible in the face of NA, unless
39 // explicitly documented.
40 float   vil_na(float dummy);
41 
42 //: True if parameter is specific NA qNaN.
43 // Tests for bit pattern 0x7ff00000000007a2, as used by Octave and R
44 bool vil_na_isna(double);
45 
46 //: True if parameter is specific NA qNaN.
47 // Tests for bit pattern 0x7f8007a2
48 bool vil_na_isna(float);
49 
50 
51 #endif // vil_na_h_
52