#include <point.h>
The size of the vector is determined at construction and can not be changed. The elements in the vector and weight are mutable.
Public Member Functions | |
Point (int dim) | |
Initially sets all elements in the vector to 0 and the weight to 1. | |
Point (const Point &other) | |
virtual | ~Point () |
virtual void | CopyFrom (const Point &other) |
int | size () const |
Returns the size of the vector. | |
int | point_dim () const |
Same as size(). | |
float | feature (int index) const |
Returns the <index>th element with bounds checking. | |
void | set_feature (int index, float value) |
Sets the <index>th element to value, with bounds checking. | |
float | weight () const |
void | set_weight (float new_weight) |
float & | operator[] (int index) |
Returns a reference to the specified index. No bounds checking. | |
float | operator[] (int index) const |
Returns a reference to the specified index. No bounds checking. | |
virtual void | WriteToStream (ostream &output_stream) const |
Serialize to a stream. | |
virtual void | ReadFromStream (istream &input_stream) |
Read a vector of <dim> floats from a stream. | |
Protected Attributes | |
float | weight_ |
vector< float > | features_ |
Point | ( | int | dim | ) |
Initially sets all elements in the vector to 0 and the weight to 1.
virtual ~Point | ( | ) | [inline, virtual] |
void CopyFrom | ( | const Point & | other | ) | [virtual] |
int size | ( | ) | const [inline] |
Returns the size of the vector.
int point_dim | ( | ) | const [inline] |
Same as size().
float feature | ( | int | index | ) | const |
Returns the <index>th element with bounds checking.
void set_feature | ( | int | index, | |
float | value | |||
) |
Sets the <index>th element to value, with bounds checking.
float weight | ( | ) | const [inline] |
void set_weight | ( | float | new_weight | ) | [inline] |
float & operator[] | ( | int | index | ) |
Returns a reference to the specified index. No bounds checking.
float operator[] | ( | int | index | ) | const |
Returns a reference to the specified index. No bounds checking.
void WriteToStream | ( | ostream & | output_stream | ) | const [virtual] |
Serialize to a stream.
Simply writes the vector of floats to a stream. Note that this does NOT write the weight or the feature dim. Writing the weights and feature dim are handled by PointSetList. When overriding this in your own Point classes, you should do it such that you write all of the data except the weight or feature dim. It's OK to include them if you want, but it will be redundant.
void ReadFromStream | ( | istream & | input_stream | ) | [virtual] |
Read a vector of <dim> floats from a stream.
float weight_ [protected] |
vector<float> features_ [protected] |