Chromium Code Reviews| Index: webrtc/modules/audio_processing/beamformer/covariance_matrix_generator.cc |
| diff --git a/webrtc/modules/audio_processing/beamformer/covariance_matrix_generator.cc b/webrtc/modules/audio_processing/beamformer/covariance_matrix_generator.cc |
| index efc5b0f71afd5b04782bd238e26bc78784d38da0..6d64a13be56a0b1a08847a665d79350c48bc7494 100644 |
| --- a/webrtc/modules/audio_processing/beamformer/covariance_matrix_generator.cc |
| +++ b/webrtc/modules/audio_processing/beamformer/covariance_matrix_generator.cc |
| @@ -14,6 +14,7 @@ |
| #include <cmath> |
| +namespace webrtc { |
| namespace { |
| float BesselJ0(float x) { |
| @@ -24,9 +25,19 @@ float BesselJ0(float x) { |
| #endif |
| } |
| -} // namespace |
| +// Calculates the Euclidean norm for a row vector. |
| +float Norm(const ComplexMatrix<float>& x) { |
| + RTC_CHECK_EQ(1, x.num_rows()); |
| + const size_t length = x.num_columns(); |
| + const complex<float>* elems = x.elements()[0]; |
| + float result = 0.f; |
| + for (size_t i = 0u; i < length; ++i) { |
| + result += std::norm(elems[i]); |
| + } |
| + return std::sqrt(result); |
| +} |
| -namespace webrtc { |
| +} // namespace |
| void CovarianceMatrixGenerator::UniformCovarianceMatrix( |
| float wave_number, |
| @@ -69,6 +80,8 @@ void CovarianceMatrixGenerator::AngledCovarianceMatrix( |
| geometry, |
| angle, |
| &interf_cov_vector); |
| + complex<float> norm_factor = Norm(interf_cov_vector); |
|
Andrew MacDonald
2015/10/13 21:55:16
This is only used on the below line. Compute direc
aluebs-webrtc
2015/10/16 16:41:14
Done.
|
| + interf_cov_vector.Scale(1.f / norm_factor); |
| interf_cov_vector_transposed.Transpose(interf_cov_vector); |
| interf_cov_vector.PointwiseConjugate(); |
| mat->Multiply(interf_cov_vector_transposed, interf_cov_vector); |