msvq

Functions

int main(int argc, char *argv[])

msvq [ option ] [ infile ]

  • -l int

    • length of vector \((1 \le M + 1)\)

  • -m int

    • order of vector \((0 \le M)\)

  • -s str

    • codebook file

  • infile str

    • double-type vector to be quantized

  • stdout

    • int-type codebook index

The below example quantizes and reconstructs vectors in data.d.

msvq -s cbfile < data.d | imsvq -s cbfile > data.q
Parameters:
  • argc[in] Number of arguments.

  • argv[in] Argument vector.

Returns:

0 on success, 1 on failure.

See also

imsvq lbg

class MultistageVectorQuantization

Perform multistage vector quantization.

The input is the \(M\)-th order vector:

\[ \begin{array}{cccc} x(0), & x(1), & \ldots, & x(M), \end{array} \]
and the \(M\)-th order \(N \times I\) codebook vectors, \(\left\{ c_i^{(n)}(m) \right\}\). The output is the \(N\) codebook indices:
\[ \begin{array}{cccc} i(1), & i(2), & \ldots, & i(N), \end{array} \]
where
\[ i(n) = \mathop{\mathrm{argmin}}_j \sum_{j=0}^{I-1} \sum_{m=0}^M (e^{(n)}(m) - c_j^{(n)}(m))^2, \]
and the quantization error is
\[\begin{split} e^{(n)}(m) = \left\{ \begin{array}{ll} x(m), & n = 1 \\ e^{(n-1)}(m) - c_j^{(n-1)}(m). & n > 1 \\ \end{array} \right. \end{split}\]

Public Functions

MultistageVectorQuantization(int num_order, int num_stage)
Parameters:
  • num_order[in] Order of vector, \(M\).

  • num_stage[in] Number of quantization stages, \(N\).

inline int GetNumOrder() const
Returns:

Order of vector.

inline int GetNumStage() const
Returns:

Number of stages.

inline bool IsValid() const
Returns:

True if this object is valid.

bool Run(const std::vector<double> &input_vector, const std::vector<std::vector<std::vector<double>>> &codebook_vectors, std::vector<int> *codebook_indices, MultistageVectorQuantization::Buffer *buffer) const
Parameters:
  • input_vector[in] \(M\)-th order input vector.

  • codebook_vectors[in] \(M\)-th order \(I\) codebook vectors. The shape is \([N, I, M+1]\).

  • codebook_indices[out] \(N\) codebook indices.

  • buffer[out] Buffer.

Returns:

True on success, false on failure.

class Buffer

Buffer for MultistageVectorQuantization class.

class VectorQuantization

Perform vector quantization.

The input is the \(M\)-th order vector:

\[ \begin{array}{cccc} x(0), & x(1), & \ldots, & x(M), \end{array} \]
and the \(M\)-th order codebook vectors:
\[ \begin{array}{cccc} \boldsymbol{c}_0, & \boldsymbol{c}_1, & \ldots, & \boldsymbol{c}_{I-1}. \end{array} \]
The output is the index of the codebook vector that minimizes the distance between the input vector and the codebook vector in an Euclidean sense:
\[ \mathop{\mathrm{argmin}}_i \sum_{i=0}^{I-1} \sum_{m=0}^M (x(m) - c_i(m))^2. \]

Public Functions

explicit VectorQuantization(int num_order)
Parameters:

num_order[in] Order of vector, \(M\).

inline int GetNumOrder() const
Returns:

Order of vector.

inline bool IsValid() const
Returns:

True if this object is valid.

bool Run(const std::vector<double> &input_vector, const std::vector<std::vector<double>> &codebook_vectors, int *codebook_index) const
Parameters:
  • input_vector[in] \(M\)-th order input vector.

  • codebook_vectors[in] \(M\)-th order \(I\) codebook vectors. The shape is \([I, M+1]\).

  • codebook_index[out] Codebook index.

Returns:

True on success, false on failure.