antenna, core: Fix coding style, formatting and typos
This commit is contained in:
@@ -61,7 +61,7 @@ class PhasedArrayModel : public Object
|
||||
* \param complexVector on which to calculate Frobenius norm
|
||||
* \return the Frobenius norm of the complex vector
|
||||
*/
|
||||
double norm(ComplexVector& complexVector) const
|
||||
double norm(const ComplexVector& complexVector) const
|
||||
{
|
||||
double norm = 0;
|
||||
for (size_t i = 0; i < complexVector.GetSize(); i++)
|
||||
|
||||
@@ -35,7 +35,9 @@ using ConstEigenMatrix = Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, Eigen
|
||||
|
||||
template <class T>
|
||||
MatrixArray<T>::MatrixArray(uint16_t numRows, uint16_t numCols, uint16_t numPages)
|
||||
: ValArray<T>(numRows, numCols, numPages){};
|
||||
: ValArray<T>(numRows, numCols, numPages)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
MatrixArray<T>::MatrixArray(const std::valarray<T>& values)
|
||||
@@ -57,25 +59,33 @@ MatrixArray<T>::MatrixArray(const std::vector<T>& values)
|
||||
|
||||
template <class T>
|
||||
MatrixArray<T>::MatrixArray(uint16_t numRows, uint16_t numCols, const std::valarray<T>& values)
|
||||
: ValArray<T>(numRows, numCols, values){};
|
||||
: ValArray<T>(numRows, numCols, values)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
MatrixArray<T>::MatrixArray(uint16_t numRows, uint16_t numCols, std::valarray<T>&& values)
|
||||
: ValArray<T>(numRows, numCols, std::move(values)){};
|
||||
: ValArray<T>(numRows, numCols, std::move(values))
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
MatrixArray<T>::MatrixArray(uint16_t numRows,
|
||||
uint16_t numCols,
|
||||
uint16_t numPages,
|
||||
const std::valarray<T>& values)
|
||||
: ValArray<T>(numRows, numCols, numPages, values){};
|
||||
: ValArray<T>(numRows, numCols, numPages, values)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
MatrixArray<T>::MatrixArray(uint16_t numRows,
|
||||
uint16_t numCols,
|
||||
uint16_t numPages,
|
||||
std::valarray<T>&& values)
|
||||
: ValArray<T>(numRows, numCols, numPages, std::move(values)){};
|
||||
: ValArray<T>(numRows, numCols, numPages, std::move(values))
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
MatrixArray<T>
|
||||
@@ -86,7 +96,7 @@ MatrixArray<T>::operator*(const MatrixArray<T>& rhs) const
|
||||
|
||||
MatrixArray<T> res{m_numRows, rhs.m_numCols, m_numPages};
|
||||
|
||||
for (auto page = 0; page < res.m_numPages; ++page)
|
||||
for (uint16_t page = 0; page < res.m_numPages; ++page)
|
||||
{
|
||||
#ifdef HAVE_EIGEN3 // Eigen found and enabled Eigen optimizations
|
||||
|
||||
@@ -98,9 +108,9 @@ MatrixArray<T>::operator*(const MatrixArray<T>& rhs) const
|
||||
#else // Eigen not found or Eigen optimizations not enabled
|
||||
|
||||
size_t matrixOffset = page * m_numRows * m_numCols;
|
||||
for (auto i = 0; i < res.m_numRows; ++i)
|
||||
for (uint16_t i = 0; i < res.m_numRows; ++i)
|
||||
{
|
||||
for (auto j = 0; j < res.m_numCols; ++j)
|
||||
for (uint16_t j = 0; j < res.m_numCols; ++j)
|
||||
{
|
||||
res(i, j, page) =
|
||||
(m_values[std::slice(matrixOffset + i, m_numCols, m_numRows)] *
|
||||
@@ -118,12 +128,11 @@ template <class T>
|
||||
MatrixArray<T>
|
||||
MatrixArray<T>::Transpose() const
|
||||
{
|
||||
MatrixArray<T> res{m_numCols,
|
||||
m_numRows,
|
||||
m_numPages}; // create the matrix where m_numRows = this.m_numCols, m_numCols
|
||||
// = this.m_numRows, m_numPages = this.m_numPages
|
||||
// Create the matrix where m_numRows = this.m_numCols, m_numCols = this.m_numRows,
|
||||
// m_numPages = this.m_numPages
|
||||
MatrixArray<T> res{m_numCols, m_numRows, m_numPages};
|
||||
|
||||
for (auto page = 0; page < m_numPages; ++page)
|
||||
for (uint16_t page = 0; page < m_numPages; ++page)
|
||||
{
|
||||
#ifdef HAVE_EIGEN3 // Eigen found and Eigen optimizations enabled
|
||||
|
||||
@@ -134,7 +143,7 @@ MatrixArray<T>::Transpose() const
|
||||
#else // Eigen not found or Eigen optimizations not enabled
|
||||
|
||||
size_t matrixIndex = page * m_numRows * m_numCols;
|
||||
for (auto i = 0; i < m_numRows; ++i)
|
||||
for (uint16_t i = 0; i < m_numRows; ++i)
|
||||
{
|
||||
res.m_values[std::slice(matrixIndex + i * res.m_numRows, res.m_numRows, 1)] =
|
||||
m_values[std::slice(matrixIndex + i, m_numCols, m_numRows)];
|
||||
@@ -165,7 +174,7 @@ MatrixArray<T>::MultiplyByLeftAndRightMatrix(const MatrixArray<T>& lMatrix,
|
||||
ConstEigenMatrix<T> rMatrixEigen(rMatrix.GetPagePtr(0), rMatrix.m_numRows, rMatrix.m_numCols);
|
||||
#endif
|
||||
|
||||
for (auto page = 0; page < m_numPages; ++page)
|
||||
for (uint16_t page = 0; page < m_numPages; ++page)
|
||||
{
|
||||
#ifdef HAVE_EIGEN3 // Eigen found and Eigen optimizations enabled
|
||||
|
||||
@@ -177,14 +186,14 @@ MatrixArray<T>::MultiplyByLeftAndRightMatrix(const MatrixArray<T>& lMatrix,
|
||||
#else // Eigen not found or Eigen optimizations not enabled
|
||||
|
||||
size_t matrixOffset = page * m_numRows * m_numCols;
|
||||
for (auto resRow = 0; resRow < res.m_numRows; ++resRow)
|
||||
for (uint16_t resRow = 0; resRow < res.m_numRows; ++resRow)
|
||||
{
|
||||
for (auto resCol = 0; resCol < res.m_numCols; ++resCol)
|
||||
for (uint16_t resCol = 0; resCol < res.m_numCols; ++resCol)
|
||||
{
|
||||
// create intermediate row result, a multiply of resRow row of lMatrix and each
|
||||
// column of this matrix
|
||||
std::valarray<T> interRes(m_numCols);
|
||||
for (auto thisCol = 0; thisCol < m_numCols; ++thisCol)
|
||||
for (uint16_t thisCol = 0; thisCol < m_numCols; ++thisCol)
|
||||
{
|
||||
interRes[thisCol] =
|
||||
(lMatrix
|
||||
|
||||
@@ -261,11 +261,14 @@ class MatrixArray : public ValArray<T>
|
||||
using ValArray<T>::m_values;
|
||||
};
|
||||
|
||||
using IntMatrixArray = MatrixArray<int>; //!< Create an alias for MatrixArray using int type
|
||||
using DoubleMatrixArray =
|
||||
MatrixArray<double>; //!< Create an alias for MatrixArray using double type
|
||||
using ComplexMatrixArray =
|
||||
MatrixArray<std::complex<double>>; //!< Create an alias for MatrixArray using complex type
|
||||
/// Create an alias for MatrixArray using int type
|
||||
using IntMatrixArray = MatrixArray<int>;
|
||||
|
||||
/// Create an alias for MatrixArray using double type
|
||||
using DoubleMatrixArray = MatrixArray<double>;
|
||||
|
||||
/// Create an alias for MatrixArray using complex type
|
||||
using ComplexMatrixArray = MatrixArray<std::complex<double>>;
|
||||
|
||||
/*************************************************
|
||||
** Class MatrixArray inline implementations
|
||||
|
||||
@@ -75,7 +75,6 @@ class ValArrayTestCase : public TestCase
|
||||
*/
|
||||
ValArrayTestCase<T>& operator=(ValArrayTestCase<T>&&) noexcept = default;
|
||||
|
||||
protected:
|
||||
private:
|
||||
void DoRun() override;
|
||||
};
|
||||
@@ -96,9 +95,9 @@ void
|
||||
ValArrayTestCase<T>::DoRun()
|
||||
{
|
||||
ValArray<T> v1 = ValArray<T>(2, 3);
|
||||
for (auto i = 0; i < v1.GetNumRows(); ++i)
|
||||
for (uint16_t i = 0; i < v1.GetNumRows(); ++i)
|
||||
{
|
||||
for (auto j = 0; j < v1.GetNumCols(); ++j)
|
||||
for (uint16_t j = 0; j < v1.GetNumCols(); ++j)
|
||||
{
|
||||
v1(i, j) = 1;
|
||||
}
|
||||
@@ -109,9 +108,9 @@ ValArrayTestCase<T>::DoRun()
|
||||
NS_TEST_ASSERT_MSG_EQ(v1.GetNumCols(), v2.GetNumCols(), "The number of cols are not equal.");
|
||||
|
||||
// test copy constructor
|
||||
for (auto i = 0; i < v1.GetNumRows(); ++i)
|
||||
for (uint16_t i = 0; i < v1.GetNumRows(); ++i)
|
||||
{
|
||||
for (auto j = 0; j < v1.GetNumCols(); ++j)
|
||||
for (uint16_t j = 0; j < v1.GetNumCols(); ++j)
|
||||
{
|
||||
NS_TEST_ASSERT_MSG_EQ(v1(i, j), v2(i, j), "The elements are not equal.");
|
||||
}
|
||||
@@ -121,9 +120,9 @@ ValArrayTestCase<T>::DoRun()
|
||||
ValArray<T> v3 = v1;
|
||||
NS_TEST_ASSERT_MSG_EQ(v1.GetNumRows(), v3.GetNumRows(), "The number of rows are not equal.");
|
||||
NS_TEST_ASSERT_MSG_EQ(v1.GetNumCols(), v3.GetNumCols(), "The number of cols are not equal.");
|
||||
for (auto i = 0; i < v1.GetNumRows(); ++i)
|
||||
for (uint16_t i = 0; i < v1.GetNumRows(); ++i)
|
||||
{
|
||||
for (auto j = 0; j < v1.GetNumCols(); ++j)
|
||||
for (uint16_t j = 0; j < v1.GetNumCols(); ++j)
|
||||
{
|
||||
NS_TEST_ASSERT_MSG_EQ(v1(i, j), v2(i, j), "The elements are not equal.");
|
||||
}
|
||||
@@ -153,7 +152,7 @@ ValArrayTestCase<T>::DoRun()
|
||||
}
|
||||
ValArray<T> v6 = ValArray<T>(2, 4, valArray1);
|
||||
|
||||
// test constructro that moves valArray
|
||||
// test constructor that moves valArray
|
||||
NS_LOG_INFO("valarray1 size before move: " << valArray1.size());
|
||||
ValArray<T> v11 = ValArray<T>(2, 4, std::move(valArray1));
|
||||
NS_LOG_INFO("valarray1 size after move: " << valArray1.size());
|
||||
@@ -163,9 +162,9 @@ ValArrayTestCase<T>::DoRun()
|
||||
// also in the access operator if we iterate over rows first we should find 0, 2, 4, 6, ...
|
||||
std::valarray<int> initArray2{0, 2, 4, 6, 1, 3, 5, 7};
|
||||
auto testIndex = 0;
|
||||
for (auto i = 0; i < v6.GetNumRows(); ++i)
|
||||
for (uint16_t i = 0; i < v6.GetNumRows(); ++i)
|
||||
{
|
||||
for (auto j = 0; j < v6.GetNumCols(); ++j)
|
||||
for (uint16_t j = 0; j < v6.GetNumCols(); ++j)
|
||||
{
|
||||
NS_TEST_ASSERT_MSG_EQ(v6(i, j),
|
||||
static_cast<T>(initArray2[testIndex]),
|
||||
@@ -188,11 +187,11 @@ ValArrayTestCase<T>::DoRun()
|
||||
// if we iterate over rows first we should find 0, 2, 4, 6, ...
|
||||
std::valarray<int> initArray4{0, 2, 4, 6, 1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7};
|
||||
testIndex = 0;
|
||||
for (auto p = 0; p < v7.GetNumPages(); ++p)
|
||||
for (uint16_t p = 0; p < v7.GetNumPages(); ++p)
|
||||
{
|
||||
for (auto i = 0; i < v7.GetNumRows(); ++i)
|
||||
for (uint16_t i = 0; i < v7.GetNumRows(); ++i)
|
||||
{
|
||||
for (auto j = 0; j < v7.GetNumCols(); ++j)
|
||||
for (uint16_t j = 0; j < v7.GetNumCols(); ++j)
|
||||
{
|
||||
NS_TEST_ASSERT_MSG_EQ(v7(i, j, p),
|
||||
static_cast<T>(initArray4[testIndex]),
|
||||
@@ -204,11 +203,11 @@ ValArrayTestCase<T>::DoRun()
|
||||
|
||||
// multiplication with a scalar value with 3D array
|
||||
ValArray<T> v8 = v7 * (static_cast<T>(5.0));
|
||||
for (auto p = 0; p < v8.GetNumPages(); ++p)
|
||||
for (uint16_t p = 0; p < v8.GetNumPages(); ++p)
|
||||
{
|
||||
for (auto i = 0; i < v8.GetNumRows(); ++i)
|
||||
for (uint16_t i = 0; i < v8.GetNumRows(); ++i)
|
||||
{
|
||||
for (auto j = 0; j < v8.GetNumCols(); ++j)
|
||||
for (uint16_t j = 0; j < v8.GetNumCols(); ++j)
|
||||
{
|
||||
NS_TEST_ASSERT_MSG_EQ(v7(i, j, p) * (static_cast<T>(5.0)),
|
||||
v8(i, j, p),
|
||||
@@ -246,7 +245,7 @@ ValArrayTestCase<T>::DoRun()
|
||||
true,
|
||||
"Matrices should be almost equal, but not equal.");
|
||||
|
||||
// test the inicialization with std::vector
|
||||
// test the initialization with std::vector
|
||||
ValArray<T> v12 = ValArray(std::vector<T>({1, 2, 3}));
|
||||
NS_LOG_INFO("v12:" << v12);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user