datapoint< FEATURE_SIZE > Struct Template Reference

List of all members.


Detailed Description

template<int FEATURE_SIZE>
struct datapoint< FEATURE_SIZE >

This structure represents a datapoint.

A datapoint is a group of pixels with ternary values (much brighter than the centre, much darker than the centre or similar to the centre pixel). In addition to the feature descriptor, the class and number of instances is also stored.

The maximum feature vector size is determined by the template parameter. This allows the ternary vector to be stored in a bitset. This keeps the struct a fixed size and removes the need for dynamic allocation.

Definition at line 146 of file learn_fast_tree.cc.


Public Member Functions

 datapoint (const string &s, unsigned long c, bool is)
 datapoint ()
Ternary get_trit (unsigned int tnum) const

Public Attributes

unsigned long count
bool is_a_corner

Static Public Attributes

static const unsigned int max_size = FEATURE_SIZE

Private Member Functions

void pack_trits (const string &unpacked)
void set_trit (unsigned int tnum, Ternary val)

Private Attributes

bitset< max_size *2 > tests

Constructor & Destructor Documentation

template<int FEATURE_SIZE>
datapoint< FEATURE_SIZE >::datapoint ( const string &  s,
unsigned long  c,
bool  is 
) [inline]

Construct a datapoint.

Parameters:
s The feature vector in string form
c The number of instances
is The class

Definition at line 152 of file learn_fast_tree.cc.

References datapoint< FEATURE_SIZE >::pack_trits().

00153     :count(c),is_a_corner(is)
00154     {
00155         pack_trits(s);
00156     }

template<int FEATURE_SIZE>
datapoint< FEATURE_SIZE >::datapoint (  )  [inline]

Default constructor allows for storage in a std::vector.

Definition at line 160 of file learn_fast_tree.cc.

00161     {}


Member Function Documentation

template<int FEATURE_SIZE>
Ternary datapoint< FEATURE_SIZE >::get_trit ( unsigned int  tnum  )  const [inline]

Extract a trit (ternary bit) from the feture vector.

Parameters:
tnum Number of the bit to extract
Returns:
The trit.

Definition at line 172 of file learn_fast_tree.cc.

References Brighter, Darker, datapoint< FEATURE_SIZE >::max_size, Similar, and datapoint< FEATURE_SIZE >::tests.

00173     {
00174         assert(tnum < size);
00175         if(tests[tnum] == 1)
00176             return Brighter;
00177         else if(tests[tnum + max_size] == 1)
00178             return Darker;
00179         else
00180             return Similar;
00181     }

template<int FEATURE_SIZE>
void datapoint< FEATURE_SIZE >::pack_trits ( const string &  unpacked  )  [inline, private]

This code reads a stringified representation of the feature vector and converts it in to the internal representation.

The string represents one feature per character, using "b", "d" and "s".

Parameters:
unpacked String to parse.

Definition at line 203 of file learn_fast_tree.cc.

References Brighter, Darker, fatal, datapoint< FEATURE_SIZE >::set_trit(), Similar, and datapoint< FEATURE_SIZE >::tests.

Referenced by datapoint< FEATURE_SIZE >::datapoint().

00204         {
00205             tests = 0;
00206             for(unsigned int i=0;i < unpacked.size(); i++)
00207             {
00208                 if(unpacked[i] == 'b')
00209                     set_trit(i, Brighter);
00210                 else if(unpacked[i] == 'd')
00211                     set_trit(i, Darker);
00212                 else if(unpacked[i] == 's')
00213                     set_trit(i, Similar);
00214                 else
00215                     fatal(2, "Bad char while packing datapoint: %s", unpacked);
00216             }
00217         }

template<int FEATURE_SIZE>
void datapoint< FEATURE_SIZE >::set_trit ( unsigned int  tnum,
Ternary  val 
) [inline, private]

Set a ternary digit.

Parameters:
tnum Digit to set
val Value to set it to.

Definition at line 222 of file learn_fast_tree.cc.

References Brighter, Darker, datapoint< FEATURE_SIZE >::max_size, Similar, and datapoint< FEATURE_SIZE >::tests.

Referenced by datapoint< FEATURE_SIZE >::pack_trits().

00223         {
00224             assert(val == Brighter || val == Darker || val == Similar);
00225             assert(tnum < max_size);
00226 
00227             if(val == Brighter)
00228                 tests[tnum] = 1;
00229             else if(val == Darker)
00230                 tests[tnum + max_size] = 1;
00231         }


Member Data Documentation

template<int FEATURE_SIZE>
unsigned long datapoint< FEATURE_SIZE >::count

Number of instances.

Definition at line 163 of file learn_fast_tree.cc.

template<int FEATURE_SIZE>
bool datapoint< FEATURE_SIZE >::is_a_corner

Class.

Definition at line 164 of file learn_fast_tree.cc.

template<int FEATURE_SIZE>
const unsigned int datapoint< FEATURE_SIZE >::max_size = FEATURE_SIZE [static]

Maximum number of features representable.

Definition at line 166 of file learn_fast_tree.cc.

Referenced by datapoint< FEATURE_SIZE >::get_trit(), and datapoint< FEATURE_SIZE >::set_trit().

template<int FEATURE_SIZE>
bitset<max_size*2> datapoint< FEATURE_SIZE >::tests [private]

Used to store the ternary vector Ternary bits are stored using 3 out of the 4 values storable by two bits.

Trit n is stored using the bits n and n + max_size, with bit n being the most significant bit.

The values are

Definition at line 185 of file learn_fast_tree.cc.

Referenced by datapoint< FEATURE_SIZE >::get_trit(), datapoint< FEATURE_SIZE >::pack_trits(), and datapoint< FEATURE_SIZE >::set_trit().


The documentation for this struct was generated from the following file:
Generated on Mon Mar 2 12:47:12 2009 for FAST-ER by  doxygen 1.5.3