OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 class MatrixTestHelpers { | 27 class MatrixTestHelpers { |
28 public: | 28 public: |
29 template <typename T> | 29 template <typename T> |
30 static void ValidateMatrixEquality(const Matrix<T>& expected, | 30 static void ValidateMatrixEquality(const Matrix<T>& expected, |
31 const Matrix<T>& actual) { | 31 const Matrix<T>& actual) { |
32 EXPECT_EQ(expected.num_rows(), actual.num_rows()); | 32 EXPECT_EQ(expected.num_rows(), actual.num_rows()); |
33 EXPECT_EQ(expected.num_columns(), actual.num_columns()); | 33 EXPECT_EQ(expected.num_columns(), actual.num_columns()); |
34 | 34 |
35 const T* const* expected_elements = expected.elements(); | 35 const T* const* expected_elements = expected.elements(); |
36 const T* const* actual_elements = actual.elements(); | 36 const T* const* actual_elements = actual.elements(); |
37 for (int i = 0; i < expected.num_rows(); ++i) { | 37 for (size_t i = 0; i < expected.num_rows(); ++i) { |
38 for (int j = 0; j < expected.num_columns(); ++j) { | 38 for (size_t j = 0; j < expected.num_columns(); ++j) { |
39 EXPECT_EQ(expected_elements[i][j], actual_elements[i][j]); | 39 EXPECT_EQ(expected_elements[i][j], actual_elements[i][j]); |
40 } | 40 } |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 static void ValidateMatrixEqualityFloat(const Matrix<float>& expected, | 44 static void ValidateMatrixEqualityFloat(const Matrix<float>& expected, |
45 const Matrix<float>& actual) { | 45 const Matrix<float>& actual) { |
46 EXPECT_EQ(expected.num_rows(), actual.num_rows()); | 46 EXPECT_EQ(expected.num_rows(), actual.num_rows()); |
47 EXPECT_EQ(expected.num_columns(), actual.num_columns()); | 47 EXPECT_EQ(expected.num_columns(), actual.num_columns()); |
48 | 48 |
49 const float* const* expected_elements = expected.elements(); | 49 const float* const* expected_elements = expected.elements(); |
50 const float* const* actual_elements = actual.elements(); | 50 const float* const* actual_elements = actual.elements(); |
51 for (int i = 0; i < expected.num_rows(); ++i) { | 51 for (size_t i = 0; i < expected.num_rows(); ++i) { |
52 for (int j = 0; j < expected.num_columns(); ++j) { | 52 for (size_t j = 0; j < expected.num_columns(); ++j) { |
53 EXPECT_NEAR(expected_elements[i][j], actual_elements[i][j], kTolerance); | 53 EXPECT_NEAR(expected_elements[i][j], actual_elements[i][j], kTolerance); |
54 } | 54 } |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 static void ValidateMatrixEqualityComplexFloat( | 58 static void ValidateMatrixEqualityComplexFloat( |
59 const Matrix<complex<float> >& expected, | 59 const Matrix<complex<float> >& expected, |
60 const Matrix<complex<float> >& actual) { | 60 const Matrix<complex<float> >& actual) { |
61 EXPECT_EQ(expected.num_rows(), actual.num_rows()); | 61 EXPECT_EQ(expected.num_rows(), actual.num_rows()); |
62 EXPECT_EQ(expected.num_columns(), actual.num_columns()); | 62 EXPECT_EQ(expected.num_columns(), actual.num_columns()); |
63 | 63 |
64 const complex<float>* const* expected_elements = expected.elements(); | 64 const complex<float>* const* expected_elements = expected.elements(); |
65 const complex<float>* const* actual_elements = actual.elements(); | 65 const complex<float>* const* actual_elements = actual.elements(); |
66 for (int i = 0; i < expected.num_rows(); ++i) { | 66 for (size_t i = 0; i < expected.num_rows(); ++i) { |
67 for (int j = 0; j < expected.num_columns(); ++j) { | 67 for (size_t j = 0; j < expected.num_columns(); ++j) { |
68 EXPECT_NEAR(expected_elements[i][j].real(), | 68 EXPECT_NEAR(expected_elements[i][j].real(), |
69 actual_elements[i][j].real(), | 69 actual_elements[i][j].real(), |
70 kTolerance); | 70 kTolerance); |
71 EXPECT_NEAR(expected_elements[i][j].imag(), | 71 EXPECT_NEAR(expected_elements[i][j].imag(), |
72 actual_elements[i][j].imag(), | 72 actual_elements[i][j].imag(), |
73 kTolerance); | 73 kTolerance); |
74 } | 74 } |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 static void ValidateMatrixNearEqualityComplexFloat( | 78 static void ValidateMatrixNearEqualityComplexFloat( |
79 const Matrix<complex<float> >& expected, | 79 const Matrix<complex<float> >& expected, |
80 const Matrix<complex<float> >& actual, | 80 const Matrix<complex<float> >& actual, |
81 float tolerance) { | 81 float tolerance) { |
82 EXPECT_EQ(expected.num_rows(), actual.num_rows()); | 82 EXPECT_EQ(expected.num_rows(), actual.num_rows()); |
83 EXPECT_EQ(expected.num_columns(), actual.num_columns()); | 83 EXPECT_EQ(expected.num_columns(), actual.num_columns()); |
84 | 84 |
85 const complex<float>* const* expected_elements = expected.elements(); | 85 const complex<float>* const* expected_elements = expected.elements(); |
86 const complex<float>* const* actual_elements = actual.elements(); | 86 const complex<float>* const* actual_elements = actual.elements(); |
87 for (int i = 0; i < expected.num_rows(); ++i) { | 87 for (size_t i = 0; i < expected.num_rows(); ++i) { |
88 for (int j = 0; j < expected.num_columns(); ++j) { | 88 for (size_t j = 0; j < expected.num_columns(); ++j) { |
89 EXPECT_NEAR(expected_elements[i][j].real(), | 89 EXPECT_NEAR(expected_elements[i][j].real(), |
90 actual_elements[i][j].real(), | 90 actual_elements[i][j].real(), |
91 tolerance); | 91 tolerance); |
92 EXPECT_NEAR(expected_elements[i][j].imag(), | 92 EXPECT_NEAR(expected_elements[i][j].imag(), |
93 actual_elements[i][j].imag(), | 93 actual_elements[i][j].imag(), |
94 tolerance); | 94 tolerance); |
95 } | 95 } |
96 } | 96 } |
97 } | 97 } |
98 }; | 98 }; |
99 | 99 |
100 } // namespace webrtc | 100 } // namespace webrtc |
101 | 101 |
102 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_MATRIX_TEST_HELPERS_H_ | 102 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_MATRIX_TEST_HELPERS_H_ |
OLD | NEW |