Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: webrtc/modules/audio_processing/beamformer/covariance_matrix_generator.cc

Issue 1378973003: Implement new version of the NonlinearBeamformer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix float constant Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/modules/audio_processing/beamformer/covariance_matrix_generator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d0728325fcd93e2426561d8139a43c082fd1ddea 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,7 @@ void CovarianceMatrixGenerator::AngledCovarianceMatrix(
geometry,
angle,
&interf_cov_vector);
+ interf_cov_vector.Scale(1.f / Norm(interf_cov_vector));
interf_cov_vector_transposed.Transpose(interf_cov_vector);
interf_cov_vector.PointwiseConjugate();
mat->Multiply(interf_cov_vector_transposed, interf_cov_vector);
« no previous file with comments | « no previous file | webrtc/modules/audio_processing/beamformer/covariance_matrix_generator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698