matrix-functions-inl.h
Go to the documentation of this file.
1 // matrix/matrix-functions-inl.h
2 
3 // Copyright 2009-2011 Microsoft Corporation
4 //
5 // See ../../COPYING for clarification regarding multiple authors
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16 // MERCHANTABLITY OR NON-INFRINGEMENT.
17 // See the Apache 2 License for the specific language governing permissions and
18 // limitations under the License.
19 //
20 // (*) incorporates, with permission, FFT code from his book
21 // "Signal Processing with Lapped Transforms", Artech, 1992.
22 
23 
24 
25 #ifndef KALDI_MATRIX_MATRIX_FUNCTIONS_INL_H_
26 #define KALDI_MATRIX_MATRIX_FUNCTIONS_INL_H_
27 
28 namespace kaldi {
29 
31 template<typename Real> inline void ComplexMul(const Real &a_re, const Real &a_im,
32  Real *b_re, Real *b_im) {
33  Real tmp_re = (*b_re * a_re) - (*b_im * a_im);
34  *b_im = *b_re * a_im + *b_im * a_re;
35  *b_re = tmp_re;
36 }
37 
38 template<typename Real> inline void ComplexAddProduct(const Real &a_re, const Real &a_im,
39  const Real &b_re, const Real &b_im,
40  Real *c_re, Real *c_im) {
41  *c_re += b_re*a_re - b_im*a_im;
42  *c_im += b_re*a_im + b_im*a_re;
43 }
44 
45 
46 template<typename Real> inline void ComplexImExp(Real x, Real *a_re, Real *a_im) {
47  *a_re = std::cos(x);
48  *a_im = std::sin(x);
49 }
50 
51 
52 } // end namespace kaldi
53 
54 
55 #endif // KALDI_MATRIX_MATRIX_FUNCTIONS_INL_H_
56 
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
void ComplexAddProduct(const Real &a_re, const Real &a_im, const Real &b_re, const Real &b_im, Real *c_re, Real *c_im)
ComplexMul implements, inline, the complex operation c += (a * b).
void ComplexMul(const Real &a_re, const Real &a_im, Real *b_re, Real *b_im)
ComplexMul implements, inline, the complex multiplication b *= a.
void ComplexImExp(Real x, Real *a_re, Real *a_im)
ComplexImExp implements a <– exp(i x), inline.