From: Takenori Y. <tak...@us...> - 2016-12-20 08:23:44
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv23561 Modified Files: Makefile input_source_from_array.h input_source_from_vector.h Added Files: input_source_from_matrix.cc input_source_from_matrix.h Log Message: add InputSourceFromMatrix class --- NEW FILE: input_source_from_matrix.cc --- // ----------------------------------------------------------------- // // The Speech Signal Processing Toolkit (SPTK) // // developed by SPTK Working Group // // http://sp-tk.sourceforge.net/ // // ----------------------------------------------------------------- // // // // Copyright (c) 1984-2007 Tokyo Institute of Technology // // Interdisciplinary Graduate School of // // Science and Engineering // // // // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // // All rights reserved. // // // // Redistribution and use in source and binary forms, with or // // without modification, are permitted provided that the following // // conditions are met: // // // // - Redistributions of source code must retain the above copyright // // notice, this list of conditions and the following disclaimer. // // - Redistributions in binary form must reproduce the above // // copyright notice, this list of conditions and the following // // disclaimer in the documentation and/or other materials provided // // with the distribution. // // - Neither the name of the SPTK working group nor the names of its // // contributors may be used to endorse or promote products derived // // from this software without specific prior written permission. // // // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND // // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, // // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS // // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON // // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // // POSSIBILITY OF SUCH DAMAGE. // // ----------------------------------------------------------------- // #include "input_source_from_matrix.h" #include <algorithm> // std::copy #include <cstddef> // std::size_t namespace sptk { bool InputSourceFromMatrix::Get(std::vector<double>* buffer) { if (NULL == buffer || !is_valid_ || col_size_ <= col_position_) { return false; } if (buffer->size() < static_cast<std::size_t>(row_size_)) { buffer->resize(row_size_); } std::copy(&(input_matrix_[col_position_][0]), &(input_matrix_[col_position_][row_size_]), buffer->begin()); ++col_position_; return true; } } // namespace sptk --- NEW FILE: input_source_from_matrix.h --- // ----------------------------------------------------------------- // // The Speech Signal Processing Toolkit (SPTK) // // developed by SPTK Working Group // // http://sp-tk.sourceforge.net/ // // ----------------------------------------------------------------- // // // // Copyright (c) 1984-2007 Tokyo Institute of Technology // // Interdisciplinary Graduate School of // // Science and Engineering // // // // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // // All rights reserved. // // // // Redistribution and use in source and binary forms, with or // // without modification, are permitted provided that the following // // conditions are met: // // // // - Redistributions of source code must retain the above copyright // // notice, this list of conditions and the following disclaimer. // // - Redistributions in binary form must reproduce the above // // copyright notice, this list of conditions and the following // // disclaimer in the documentation and/or other materials provided // // with the distribution. // // - Neither the name of the SPTK working group nor the names of its // // contributors may be used to endorse or promote products derived // // from this software without specific prior written permission. // // // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND // // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, // // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS // // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON // // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // // POSSIBILITY OF SUCH DAMAGE. // // ----------------------------------------------------------------- // #ifndef SPTK_SRC_INPUT_SOURCE_FROM_MATRIX_H_ #define SPTK_SRC_INPUT_SOURCE_FROM_MATRIX_H_ #include <vector> // std::vector #include "input_source_interface.h" #include "sptk_utils.h" namespace sptk { class InputSourceFromMatrix : public InputSourceInterface { public: // InputSourceFromMatrix(int row_size, int col_size, double** input_matrix) : row_size_(row_size), col_size_(col_size), input_matrix_(input_matrix), col_position_(0), is_valid_(true) { if (row_size <= 0 || col_size <= 0 || NULL == input_matrix) { is_valid_ = false; } } // virtual ~InputSourceFromMatrix() { } // virtual int GetSize() const { return row_size_; } // int GetRowSize() const { return row_size_; } // int GetColSize() const { return col_size_; } // virtual bool IsValid() const { return is_valid_; } // virtual bool Get(std::vector<double>* buffer); private: // const int row_size_; // const int col_size_; // double** input_matrix_; // int col_position_; // bool is_valid_; // DISALLOW_COPY_AND_ASSIGN(InputSourceFromMatrix); }; } // namespace sptk #endif // SPTK_SRC_INPUT_SOURCE_FROM_MATRIX_H_ Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Makefile 30 Nov 2016 04:23:27 -0000 1.20 --- Makefile 20 Dec 2016 08:23:42 -0000 1.21 *************** *** 57,60 **** --- 57,61 ---- generalized_cepstrum_transform.cc \ input_source_from_array.cc \ + input_source_from_matrix.cc \ input_source_from_stream.cc \ input_source_from_vector.cc \ Index: input_source_from_array.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_from_array.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** input_source_from_array.h 30 Nov 2016 04:23:28 -0000 1.1 --- input_source_from_array.h 20 Dec 2016 08:23:42 -0000 1.2 *************** *** 46,50 **** #define SPTK_SRC_INPUT_SOURCE_FROM_ARRAY_H_ - #include <istream> // std::istream #include <vector> // std::vector --- 46,49 ---- Index: input_source_from_vector.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_from_vector.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** input_source_from_vector.h 30 Nov 2016 04:23:28 -0000 1.1 --- input_source_from_vector.h 20 Dec 2016 08:23:42 -0000 1.2 *************** *** 46,50 **** #define SPTK_SRC_INPUT_SOURCE_FROM_VECTOR_H_ - #include <istream> // std::istream #include <vector> // std::vector --- 46,49 ---- |