#include <quantized_vector.h>
Public 型 | |
typedef size_t | size_type |
typedef float | value_type |
typedef uint16_t | storage_type |
Public メソッド | |
QuantizedVector () | |
デフォルトコンストラクタ。空データを作る | |
QuantizedVector (size_t n_values, value_type range_min, value_type range_max) | |
コンストラクタ | |
virtual | ~QuantizedVector () |
仮想デストラクタ。何もしない | |
value_type | rangeMin () const |
取りうる最小値を返す | |
value_type | rangeMax () const |
取りうる最大値を返す | |
bool | setRange (value_type range_min, value_type range_max) |
値の取りうる幅を設定する. | |
bool | setNumberOfValues (size_t n_values) |
何通りの値を取りうるかを設定する。 | |
size_t | numberOfValues () const |
何通りの値を取りうるかを返す | |
size_t | size () const |
データの個数を返す。 | |
void | resize (size_type new_size, value_type x=value_type()) |
データの個数を変更 | |
template<typename InputIterator> | |
void | assign (InputIterator first, InputIterator last) |
値をセットする | |
template<typename OutputIterator> | |
OutputIterator | copy_to (OutputIterator out) const |
内部の値を他のシーケンスにコピーする | |
template<typename OutputIterator> | |
OutputIterator | copy_to (OutputIterator out, OutputIterator oend) const |
内部の値を他のシーケンスにコピーする | |
storage_type | operator[] (size_type index) const |
内部表現を返す添字オペレータ(const) | |
storage_type & | operator[] (size_type index) |
内部表現を返す添字オペレータ(non const) | |
int | writeToXml (std::ostream &os, const std::string &tag) const |
Xmlへの書込みを行う | |
int | readFromXml (std::istream &is, const std::string &tag) |
Xmlからの読み込みを行う | |
Protected 型 | |
typedef std::vector< storage_type > | vector_type |
Protected メソッド | |
storage_type | quantize (value_type v) const |
値を量子化. | |
value_type | dequantize (storage_type s) const |
量子化された値の復元 | |
value_type | step () const |
刻み幅を計算する。 | |
void | pack_to (std::vector< uint8_t > &packed) const |
bit数縮小処理を行う. | |
void | unpack_from (const std::vector< uint8_t > &packed, int n_bits, size_t n_elems) |
bit数縮小された値からの復元処理 | |
Static Protected メソッド | |
static int | bits_necessary_for (size_t n_values) |
取りうる値の数から必要なbit数を計算する | |
Private メソッド | |
BOOST_SERIALIZATION_SPLIT_MEMBER () | |
シリアライズ処理をsave/loadに分けるためのboostマクロ | |
template<class Archive> | |
void | save (Archive &ar, const unsigned int version) const |
シリアライズの際にboostから呼ばれるメンバテンプレート. | |
template<class Archive> | |
void | load (Archive &ar, const unsigned int version) |
デシリアライズの際にboostから呼ばれるメンバテンプレート. | |
Private 変数 | |
std::vector< storage_type > | data_ |
内部表現された値。16bit | |
size_t | n_values_ |
表現可能な値の数(何通りか?) | |
value_type | range_min_ |
表現可能な最小値 | |
value_type | range_max_ |
表現可能な最大値 | |
フレンド | |
class | boost::serialization::access |
float/double値を送信する際の通信データ量を削減するため, 値を量子化して送るためのvectorクラス。
データビット数としては1,2,4,8,16が可能。ただし,使用する際は最小値, 最大値,「取りうる値の数」を設定して用いる。必要なbit数は自動計算さ れ,現在の実装では1, 2, 4, 8, 16のいずれかになる。
typedef size_t QuantizedVector::size_type |
typedef float QuantizedVector::value_type |
typedef uint16_t QuantizedVector::storage_type |
typedef std::vector<storage_type> QuantizedVector::vector_type [protected] |
QuantizedVector::QuantizedVector | ( | ) |
デフォルトコンストラクタ。空データを作る
QuantizedVector::QuantizedVector | ( | size_t | n_values, | |
value_type | range_min, | |||
value_type | range_max | |||
) |
コンストラクタ
[in] | n_values | 取りうる値の数 |
[in] | range_min | 最小値 |
[in] | range_max | 最大値 |
virtual QuantizedVector::~QuantizedVector | ( | ) | [inline, virtual] |
仮想デストラクタ。何もしない
value_type QuantizedVector::rangeMin | ( | ) | const [inline] |
取りうる最小値を返す
value_type QuantizedVector::rangeMax | ( | ) | const [inline] |
取りうる最大値を返す
bool QuantizedVector::setRange | ( | value_type | range_min, | |
value_type | range_max | |||
) |
値の取りうる幅を設定する.
[in] | range_min | 最小値 |
[in] | range_max | 最大値 |
bool QuantizedVector::setNumberOfValues | ( | size_t | n_values | ) |
何通りの値を取りうるかを設定する。
[in] | n_values | 取りうる値の数 |
size_t QuantizedVector::numberOfValues | ( | ) | const [inline] |
何通りの値を取りうるかを返す
size_t QuantizedVector::size | ( | ) | const [inline] |
データの個数を返す。
void QuantizedVector::resize | ( | size_type | new_size, | |
value_type | x = value_type() | |||
) |
データの個数を変更
[in] | new_size | 新しいサイズ |
[in] | x | 個数が増えた場合に,生成された要素にセットされる値 |
void QuantizedVector::assign | ( | InputIterator | first, | |
InputIterator | last | |||
) | [inline] |
値をセットする
[first, last)の範囲を自分に読み込む。読み込む際に量子化を行う
InputIterator | 入力反復子クラス |
[in] | first | 入力範囲の最初 |
[in] | last | 入力範囲の最後の一つ後。逆参照されない。 |
OutputIterator QuantizedVector::copy_to | ( | OutputIterator | out | ) | const [inline] |
内部の値を他のシーケンスにコピーする
OutputIterator | 出力反復子クラス |
[out] | out | 出力先を表す反復子。ここから値を書き始める。 |
OutputIterator QuantizedVector::copy_to | ( | OutputIterator | out, | |
OutputIterator | oend | |||
) | const [inline] |
内部の値を他のシーケンスにコピーする
OutputIterator | 出力反復子クラス |
[out] | out | 出力先を表す反復子。ここから値を書き始める。 |
[out] | oend | 出力先の最後の一つ後を表す反復子。ここには書かない。 |
storage_type QuantizedVector::operator[] | ( | size_type | index | ) | const [inline] |
内部表現を返す添字オペレータ(const)
storage_type& QuantizedVector::operator[] | ( | size_type | index | ) | [inline] |
内部表現を返す添字オペレータ(non const)
int QuantizedVector::writeToXml | ( | std::ostream & | os, | |
const std::string & | tag | |||
) | const |
Xmlへの書込みを行う
os | 書込み先ストリーム | |
[in] | tag | XMLタグ文字列 |
0 | 成功 | |
negative | 失敗 |
int QuantizedVector::readFromXml | ( | std::istream & | is, | |
const std::string & | tag | |||
) |
Xmlからの読み込みを行う
is | 読み込み元ストリーム | |
[in] | tag | XMLタグ文字列 |
0 | 成功 | |
negative | 失敗 |
storage_type QuantizedVector::quantize | ( | value_type | v | ) | const [protected] |
値を量子化.
[in] | v | 量子化前の値 |
value_type QuantizedVector::dequantize | ( | storage_type | s | ) | const [protected] |
量子化された値の復元
[in] | s | 量子化された値 |
value_type QuantizedVector::step | ( | ) | const [inline, protected] |
刻み幅を計算する。
例。
range_min_ = 1.0, range_max_ = 2.0, n_values_ = 3;
+----------+----------+ 1.0 1.5 2.0 元の値(value_type) 0 1 2 エンコードされた値
--> 3通りなので,2bit必要
step = (2.0 - 1.0) / (3 - 1) = 0.5
static int QuantizedVector::bits_necessary_for | ( | size_t | n_values | ) | [static, protected] |
取りうる値の数から必要なbit数を計算する
void QuantizedVector::pack_to | ( | std::vector< uint8_t > & | packed | ) | const [protected] |
bit数縮小処理を行う.
[out] | packed | 縮小された値の書込み先 |
void QuantizedVector::unpack_from | ( | const std::vector< uint8_t > & | packed, | |
int | n_bits, | |||
size_t | n_elems | |||
) | [protected] |
bit数縮小された値からの復元処理
[in] | packed | 縮小された値をここから読む |
[in] | n_bits | bit数 |
[in] | n_elems | 格納された要素数 |
QuantizedVector::BOOST_SERIALIZATION_SPLIT_MEMBER | ( | ) | [private] |
シリアライズ処理をsave/loadに分けるためのboostマクロ
void QuantizedVector::save | ( | Archive & | ar, | |
const unsigned int | version | |||
) | const [inline, private] |
シリアライズの際にboostから呼ばれるメンバテンプレート.
Archive | Boostのアーカイブクラス名 |
[out] | ar | Archive Boostのアーカイブクラスのインスタンス |
[in] | (未使用) | バージョン |
void QuantizedVector::load | ( | Archive & | ar, | |
const unsigned int | version | |||
) | [inline, private] |
デシリアライズの際にboostから呼ばれるメンバテンプレート.
Archive | Boostのアーカイブクラス名 |
[out] | ar | Archive Boostのアーカイブクラスのインスタンス |
[in] | (未使用) | バージョン |
friend class boost::serialization::access [friend] |
std::vector<storage_type> QuantizedVector::data_ [private] |
内部表現された値。16bit
size_t QuantizedVector::n_values_ [private] |
表現可能な値の数(何通りか?)
value_type QuantizedVector::range_min_ [private] |
表現可能な最小値
value_type QuantizedVector::range_max_ [private] |
表現可能な最大値