Functions
core/vnl/vnl_na.h File Reference

NA (Not Available) is a particular double (or single-precision) NaN to represent missing data. More...

#include <vcl_iosfwd.h>

Go to the source code of this file.

Functions

double vnl_na (double dummy)
 qNaN to indicate value Not Available.
float vnl_na (float dummy)
 qNaN to indicate value Not Available.
bool vnl_na_isna (double)
 True if parameter is specific NA qNaN.
bool vnl_na_isna (float)
 True if parameter is specific NA qNaN.
double vnl_na_nan_to_na (double v)
 Replace NaNs with NA, leave other values alone.
float vnl_na_nan_to_na (float v)
 Replace NaNs with NA, leave other values alone.

Detailed Description

NA (Not Available) is a particular double (or single-precision) NaN to represent missing data.

For example, where a vnl_vector<double> represents a series of samples from an image, NA could be used to represent places where the measurement was taken outside the image.

NA is distinct from the two other standard meanings of NaN - Indeterminate and Error. It is entirely up to each algorithm to treat NA values meaningfully. Unless a function's interpretation of NA is explicitly documented, you should assume that it will be treated similarly to every other NaN. The IEEE754 bit value used to represent NA in double-precision is 0x7ff00000000007a2, the same as used by Octave and R. Initial values of NA are stored as signalling NaNs, but many uses will convert this to the non-signalling variant 0x7ff80000000007a2. vnl_isna() will accept either variant.

The single precision NA is stored as 0x7f8007a2. I cannot find any external support for this or any other value for single precision NA. There is no automatic conversion between the NA values during casting, promotion, etc. If you want to convert a float to double, whilst preserving the NA-ness of the value, you will have to test for and set the new NA value explicitly.

You can read and write floating point values from a stream using standard operators by using a conversion manipulator.

   double x, y;
   is >> vnl_na_stream(x) >> vnl_na_stream(x);
   os << vnl_na_stream(x) << ' ' << vnl_na_stream(x);
   

Definition in file vnl_na.h.


Function Documentation

double vnl_na ( double  )

qNaN to indicate value Not Available.

Don't assume that any VXL functions will do something sensible in the face of NA, unless explicitly documented.

qNaN to indicate value Not Available.

This returns the bit pattern 0x7ff00000000007a2, as used by Octave and R Don't assume that any VXL functions will treat the value as NA rather than NaN, unless explicitly documented.

Definition at line 18 of file vnl_na.cxx.

float vnl_na ( float  )

qNaN to indicate value Not Available.

Don't assume that any VXL functions will do something sensible in the face of NA, unless explicitly documented.

qNaN to indicate value Not Available.

This returns the bit pattern 0x7f8007a2 Don't assume that any VXL functions will treat the value as NA rather than NaN, unless explicitly documented.

Definition at line 45 of file vnl_na.cxx.

bool vnl_na_isna ( double  x)

True if parameter is specific NA qNaN.

Tests for bit pattern 0x7ff00000000007a2, as used by Octave and R

Definition at line 56 of file vnl_na.cxx.

bool vnl_na_isna ( float  x)

True if parameter is specific NA qNaN.

Tests for bit pattern 0x7f8007a2

Tests for bit pattern 0x7F8007a2

Definition at line 69 of file vnl_na.cxx.

double vnl_na_nan_to_na ( double  v)

Replace NaNs with NA, leave other values alone.

Definition at line 78 of file vnl_na.cxx.

float vnl_na_nan_to_na ( float  v)

Replace NaNs with NA, leave other values alone.

Definition at line 84 of file vnl_na.cxx.