Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
takenori-y committed Jul 23, 2021
1 parent cf0c28c commit 9777d6a
Show file tree
Hide file tree
Showing 11 changed files with 431 additions and 128 deletions.
26 changes: 1 addition & 25 deletions doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -875,31 +875,7 @@ INPUT = \
../include/SPTK/conversion/waveform_to_autocorrelation.h \
../include/SPTK/filter \
../include/SPTK/generation \
../include/SPTK/math/discrete_cosine_transform.h \
../include/SPTK/math/distance_calculation.h \
../include/SPTK/math/entropy_calculation.h \
../include/SPTK/math/durand_kerner_method.h \
../include/SPTK/math/dynamic_time_warping.h \
../include/SPTK/math/fast_fourier_transform.h \
../include/SPTK/math/frequency_transform.h \
../include/SPTK/math/gaussian_mixture_modeling.h \
../include/SPTK/math/gaussian_mixture_model_based_conversion.h \
../include/SPTK/math/histogram_calculation.h \
../include/SPTK/math/inverse_discrete_cosine_transform.h \
../include/SPTK/math/inverse_fast_fourier_transform.h \
../include/SPTK/math/levinson_durbin_recursion.h \
../include/SPTK/math/minmax_accumulation.h \
../include/SPTK/math/principal_component_analysis.h \
../include/SPTK/math/real_valued_fast_fourier_transform.h \
../include/SPTK/math/real_valued_inverse_fast_fourier_transform.h \
../include/SPTK/math/reverse_levinson_durbin_recursion.h \
../include/SPTK/math/scalar_operation.h \
../include/SPTK/math/statistics_accumulation.h \
../include/SPTK/math/toeplitz_plus_hankel_system_solver.h \
../include/SPTK/math/two_dimensional_fast_fourier_transform.h \
../include/SPTK/math/two_dimensional_inverse_fast_fourier_transform.h \
../include/SPTK/math/two_dimensional_real_valued_fast_fourier_transform.h \
../include/SPTK/math/vandermonde_system_solver.h \
../include/SPTK/math \
../include/SPTK/utils/data_symmetrizing.h \
../include/SPTK/utils/misc_utils.h \
../include/SPTK/window/data_windowing.h \
Expand Down
12 changes: 12 additions & 0 deletions doc/utils/math.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
math
====

.. doxygenclass:: sptk::Matrix
:members:

.. doxygenclass:: sptk::Matrix2D
:members:

.. doxygenclass:: sptk::SymmetricMatrix
:members:

.. doxygenclass:: sptk::SymmetricSystemSolver
:members:

.. doxygenclass:: sptk::ToeplitzPlusHankelSystemSolver
:members:

Expand Down
1 change: 1 addition & 0 deletions include/SPTK/math/distance_calculation.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class DistanceCalculation {
* @param[in] vector1 @f$M@f$-th order vector.
* @param[in] vector2 @f$M@f$-th order vector.
* @param[out] distance Distance between the two vectors.
* @return True on success, false on failure.
*/
bool Run(const std::vector<double>& vector1,
const std::vector<double>& vector2, double* distance) const;
Expand Down
49 changes: 47 additions & 2 deletions include/SPTK/math/fourier_transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,40 +51,80 @@

namespace sptk {

/**
* Fourier transform wrapper.
*/
class FourierTransform {
public:
/**
* Inteface of Fourier transform.
*/
class FourierTransformInterface {
public:
virtual ~FourierTransformInterface() {
}

/**
* @return DFT length.
*/
virtual int GetLength() const = 0;

/**
* @return True if this object is valid.
*/
virtual bool IsValid() const = 0;

/**
* @param[in] real_part_input @f$L@f$-length real part of input.
* @param[in] imag_part_input @f$L@f$-length imaginary part of input.
* @param[out] real_part_output @f$L@f$-length real part of output.
* @param[out] imag_part_output @f$L@f$-length imaginary part of output.
* @return True on success, false on failure.
*/
virtual bool Run(const std::vector<double>& real_part_input,
const std::vector<double>& imag_part_input,
std::vector<double>* real_part_output,
std::vector<double>* imag_part_output) const = 0;

virtual bool Run(std::vector<double>* real_part_output,
std::vector<double>* imag_part_output) const = 0;
/**
* @param[in,out] real_part Real part.
* @param[in,out] imag_part Imaginary part.
* @return True on success, false on failure.
*/
virtual bool Run(std::vector<double>* real_part,
std::vector<double>* imag_part) const = 0;
};

/**
* @param[in] length DFT length, @f$L@f$.
*/
explicit FourierTransform(int length);

~FourierTransform() {
delete fourier_transform_;
}

/**
* @return DFT length.
*/
int GetLength() const {
return fourier_transform_->GetLength();
}

/**
* @return True if this object is valid.
*/
bool IsValid() const {
return fourier_transform_->IsValid();
}

/**
* @param[in] real_part_input @f$L@f$-length real part of input.
* @param[in] imag_part_input @f$L@f$-length imaginary part of input.
* @param[out] real_part_output @f$L@f$-length real part of output.
* @param[out] imag_part_output @f$L@f$-length imaginary part of output.
* @return True on success, false on failure.
*/
bool Run(const std::vector<double>& real_part_input,
const std::vector<double>& imag_part_input,
std::vector<double>* real_part_output,
Expand All @@ -93,6 +133,11 @@ class FourierTransform {
real_part_output, imag_part_output);
}

/**
* @param[in,out] real_part Real part.
* @param[in,out] imag_part Imaginary part.
* @return True on success, false on failure.
*/
bool Run(std::vector<double>* real_part,
std::vector<double>* imag_part) const {
return fourier_transform_->Run(real_part, imag_part);
Expand Down
147 changes: 115 additions & 32 deletions include/SPTK/math/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// Interdisciplinary Graduate School of //
// Science and Engineering //
// //
// 1996-2019 Nagoya Institute of Technology //
// 1996-2020 Nagoya Institute of Technology //
// Department of Computer Science //
// //
// All rights reserved. //
Expand Down Expand Up @@ -49,104 +49,187 @@

namespace sptk {

/**
* Matrix.
*/
class Matrix {
public:
//
/**
* @param[in] num_row Number of rows.
* @param[in] num_column Number of columns.
*/
explicit Matrix(int num_row = 0, int num_column = 0);

//
/**
* @param[in] num_row Number of rows.
* @param[in] num_column Number of columns.
* @param[in] vector Diagonal elements.
*/
Matrix(int num_row, int num_column, const std::vector<double>& vector);

//
/**
* @param[in] matrix Matrix.
*/
Matrix(const Matrix& matrix);

//
/**
* @param[in] matrix Matrix.
*/
Matrix& operator=(const Matrix& matrix);

//
virtual ~Matrix() {
}

//
/**
* @return Number of rows.
*/
int GetNumRow() const {
return num_row_;
}

//
/**
* @return Number of columns.
*/
int GetNumColumn() const {
return num_column_;
}

//
/**
* Resize matrix.
*
* @param[in] num_row Number of rows.
* @param[in] num_column Number of columns.
*/
void Resize(int num_row, int num_column);

//
/**
* @param[in] row Row.
*/
double* operator[](int row) {
return index_[row];
}

//
/**
* @param[in] row Row.
*/
const double* operator[](int row) const {
return index_[row];
}

//
/**
* Get element.
*
* @param[in] row i.
* @param[in] column j.
* @return (i, j)-th element.
*/
double& At(int row, int column);

//
/**
* Get element.
*
* @param[in] row i.
* @param[in] column j.
* @return (i, j)-th element.
*/
const double& At(int row, int column) const;

//
/**
* @param[in] matrix Addend.
* @return Sum.
*/
Matrix& operator+=(const Matrix& matrix);

//
/**
* @param[in] matrix Subtrahend.
* @return Difference.
*/
Matrix& operator-=(const Matrix& matrix);

//
/**
* @param[in] matrix Multiplicand.
* @return Product.
*/
Matrix& operator*=(const Matrix& matrix);

//
/**
* @param[in] matrix Addend.
* @return Sum.
*/
Matrix operator+(const Matrix& matrix) const;

//
/**
* @param[in] matrix Subtrahend.
* @return Difference.
*/
Matrix operator-(const Matrix& matrix) const;

//
/**
* @param[in] matrix Multiplicand.
* @return Product.
*/
Matrix operator*(const Matrix& matrix) const;

//
/**
* Negate.
*
* @return Negated matrix.
*/
Matrix operator-() const;

//
/**
* Overwrite all elements with a value.
*
* @param[in] value Value.
*/
void Fill(double value);

//
/**
* Overwrite diagonal elements with a value.
*
* @param[in] value Diagonal value.
*/
void FillDiagonal(double value);

//
/**
* Negate all elements of matrix.
*/
void Negate();

//
/**
* Transpose matrix.
*
* @param[out] transposed_matrix Transposed matrix.
* @return True on success, false on failure.
*/
bool Transpose(Matrix* transposed_matrix) const;

//
/**
* Get submatrix.
*
* @param[in] row_offset Offset of row.
* @param[in] num_row_of_submatrix Number of rows of submatrix.
* @param[in] column_offset Offset of column.
* @param[in] num_column_of_submatrix Number of columns of submatrix.
* @param[out] submatrix Submatrix.
* @return True on success, false on failure.
*/
bool GetSubmatrix(int row_offset, int num_row_of_submatrix, int column_offset,
int num_column_of_submatrix, Matrix* submatrix) const;

//
/**
* Compute determinant.
*
* @param[out] determinant Determinant.
* @return True on success, false on failure.
*/
bool GetDeterminant(double* determinant) const;

private:
//
int num_row_;

//
int num_column_;

//
std::vector<double> data_;

//
std::vector<double*> index_;
};

Expand Down
Loading

0 comments on commit 9777d6a

Please sign in to comment.