diff --git a/src/core/model/matrix-array.cc b/src/core/model/matrix-array.cc index 4c33a758a..72ec3f99a 100644 --- a/src/core/model/matrix-array.cc +++ b/src/core/model/matrix-array.cc @@ -34,7 +34,7 @@ using ConstEigenMatrix = Eigen::Map -MatrixArray::MatrixArray(uint16_t numRows, uint16_t numCols, uint16_t numPages) +MatrixArray::MatrixArray(size_t numRows, size_t numCols, size_t numPages) : ValArray(numRows, numCols, numPages) { } @@ -58,30 +58,30 @@ MatrixArray::MatrixArray(const std::vector& values) } template -MatrixArray::MatrixArray(uint16_t numRows, uint16_t numCols, const std::valarray& values) +MatrixArray::MatrixArray(size_t numRows, size_t numCols, const std::valarray& values) : ValArray(numRows, numCols, values) { } template -MatrixArray::MatrixArray(uint16_t numRows, uint16_t numCols, std::valarray&& values) +MatrixArray::MatrixArray(size_t numRows, size_t numCols, std::valarray&& values) : ValArray(numRows, numCols, std::move(values)) { } template -MatrixArray::MatrixArray(uint16_t numRows, - uint16_t numCols, - uint16_t numPages, +MatrixArray::MatrixArray(size_t numRows, + size_t numCols, + size_t numPages, const std::valarray& values) : ValArray(numRows, numCols, numPages, values) { } template -MatrixArray::MatrixArray(uint16_t numRows, - uint16_t numCols, - uint16_t numPages, +MatrixArray::MatrixArray(size_t numRows, + size_t numCols, + size_t numPages, std::valarray&& values) : ValArray(numRows, numCols, numPages, std::move(values)) { @@ -96,7 +96,7 @@ MatrixArray::operator*(const MatrixArray& rhs) const MatrixArray res{m_numRows, rhs.m_numCols, m_numPages}; - for (uint16_t page = 0; page < res.m_numPages; ++page) + for (size_t page = 0; page < res.m_numPages; ++page) { #ifdef HAVE_EIGEN3 // Eigen found and enabled Eigen optimizations @@ -109,9 +109,9 @@ MatrixArray::operator*(const MatrixArray& rhs) const size_t matrixOffset = page * m_numRows * m_numCols; size_t rhsMatrixOffset = page * rhs.m_numRows * rhs.m_numCols; - for (uint16_t i = 0; i < res.m_numRows; ++i) + for (size_t i = 0; i < res.m_numRows; ++i) { - for (uint16_t j = 0; j < res.m_numCols; ++j) + for (size_t j = 0; j < res.m_numCols; ++j) { res(i, j, page) = (m_values[std::slice(matrixOffset + i, m_numCols, m_numRows)] * rhs.m_values[std::slice(rhsMatrixOffset + j * rhs.m_numRows, @@ -134,7 +134,7 @@ MatrixArray::Transpose() const // m_numPages = this.m_numPages MatrixArray res{m_numCols, m_numRows, m_numPages}; - for (uint16_t page = 0; page < m_numPages; ++page) + for (size_t page = 0; page < m_numPages; ++page) { #ifdef HAVE_EIGEN3 // Eigen found and Eigen optimizations enabled @@ -145,7 +145,7 @@ MatrixArray::Transpose() const #else // Eigen not found or Eigen optimizations not enabled size_t matrixIndex = page * m_numRows * m_numCols; - for (uint16_t i = 0; i < m_numRows; ++i) + for (size_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)]; @@ -176,7 +176,7 @@ MatrixArray::MultiplyByLeftAndRightMatrix(const MatrixArray& lMatrix, ConstEigenMatrix rMatrixEigen(rMatrix.GetPagePtr(0), rMatrix.m_numRows, rMatrix.m_numCols); #endif - for (uint16_t page = 0; page < m_numPages; ++page) + for (size_t page = 0; page < m_numPages; ++page) { #ifdef HAVE_EIGEN3 // Eigen found and Eigen optimizations enabled @@ -188,14 +188,14 @@ MatrixArray::MultiplyByLeftAndRightMatrix(const MatrixArray& lMatrix, #else // Eigen not found or Eigen optimizations not enabled size_t matrixOffset = page * m_numRows * m_numCols; - for (uint16_t resRow = 0; resRow < res.m_numRows; ++resRow) + for (size_t resRow = 0; resRow < res.m_numRows; ++resRow) { - for (uint16_t resCol = 0; resCol < res.m_numCols; ++resCol) + for (size_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 interRes(m_numCols); - for (uint16_t thisCol = 0; thisCol < m_numCols; ++thisCol) + for (size_t thisCol = 0; thisCol < m_numCols; ++thisCol) { interRes[thisCol] = (lMatrix diff --git a/src/core/model/matrix-array.h b/src/core/model/matrix-array.h index 24534d6a0..2dbf6a9c9 100644 --- a/src/core/model/matrix-array.h +++ b/src/core/model/matrix-array.h @@ -92,7 +92,7 @@ class MatrixArray : public ValArray * \param numCols the number of columns * \param numPages the number of pages */ - MatrixArray(uint16_t numRows, uint16_t numCols = 1, uint16_t numPages = 1); + MatrixArray(size_t numRows, size_t numCols = 1, size_t numPages = 1); /** * \brief Constructor creates a single array of values.size () elements and 1 column, * and uses std::valarray values to initialize the elements. @@ -118,7 +118,7 @@ class MatrixArray : public ValArray * \param numCols the number of columns * \param values std::valarray that will be used to initialize elements of 3D array */ - MatrixArray(uint16_t numRows, uint16_t numCols, const std::valarray& values); + MatrixArray(size_t numRows, size_t numCols, const std::valarray& values); /** * \brief Constructor creates a single matrix of numRows and numCols, and moves * std::valarray values to initialize the elements. @@ -126,7 +126,7 @@ class MatrixArray : public ValArray * \param numCols the number of columns * \param values std::valarray that will be moved to initialize elements of 3D array */ - MatrixArray(uint16_t numRows, uint16_t numCols, std::valarray&& values); + MatrixArray(size_t numRows, size_t numCols, std::valarray&& values); /** * \brief Constructor creates the array of numPages matrices of numRows x numCols dimensions, * and uses std::valarray values to initialize all the elements. @@ -135,10 +135,7 @@ class MatrixArray : public ValArray * \param numPages the number of pages * \param values std::valarray that will be used to initialize elements of 3D array */ - MatrixArray(uint16_t numRows, - uint16_t numCols, - uint16_t numPages, - const std::valarray& values); + MatrixArray(size_t numRows, size_t numCols, size_t numPages, const std::valarray& values); /** * \brief Constructor creates the array of numPages matrices of numRows x numCols dimensions, * and moves std::valarray values to initialize all the elements. @@ -147,10 +144,7 @@ class MatrixArray : public ValArray * \param numPages the number of pages * \param values std::valarray that will be used to initialize elements of 3D array */ - MatrixArray(uint16_t numRows, - uint16_t numCols, - uint16_t numPages, - std::valarray&& values); + MatrixArray(size_t numRows, size_t numCols, size_t numPages, std::valarray&& values); /** instruct the compiler to generate the implicitly declared destructor*/ ~MatrixArray() override = default; /** instruct the compiler to generate the implicitly declared copy constructor*/ diff --git a/src/core/model/val-array.h b/src/core/model/val-array.h index d09edac82..609400c7a 100644 --- a/src/core/model/val-array.h +++ b/src/core/model/val-array.h @@ -89,7 +89,7 @@ class ValArray : public SimpleRefCount> * \param numCols the number of columns * \param numPages the number of pages */ - ValArray(uint16_t numRows, uint16_t numCols = 1, uint16_t numPages = 1); + ValArray(size_t numRows, size_t numCols = 1, size_t numPages = 1); /** * \brief Constructor creates a single 1D array of values.size () elements and 1 column, * and uses std::valarray values to initialize the elements. @@ -115,7 +115,7 @@ class ValArray : public SimpleRefCount> * \param numCols the number of columns * \param values valarray that will be used to initialize elements of 3D array */ - ValArray(uint16_t numRows, uint16_t numCols, const std::valarray& values); + ValArray(size_t numRows, size_t numCols, const std::valarray& values); /** * \brief Constructor creates a single 2D array of numRows and numCols, and moves * std::valarray values to initialize the elements. @@ -123,7 +123,7 @@ class ValArray : public SimpleRefCount> * \param numCols the number of columns * \param values valarray that will be used to initialize elements of 3D array */ - ValArray(uint16_t numRows, uint16_t numCols, std::valarray&& values); + ValArray(size_t numRows, size_t numCols, std::valarray&& values); /** * \brief Constructor creates the 3D array of numRows x numCols x numPages dimensions, * and uses std::valarray values to initialize all the 2D arrays, where first @@ -133,10 +133,7 @@ class ValArray : public SimpleRefCount> * \param numPages the number of pages * \param values valarray that will be used to initialize elements of 3D array */ - ValArray(uint16_t numRows, - uint16_t numCols, - uint16_t numPages, - const std::valarray& values); + ValArray(size_t numRows, size_t numCols, size_t numPages, const std::valarray& values); /** * \brief Constructor creates the 3D array of numRows x numCols x numPages dimensions, * and moves std::valarray values to initialize all the 2D arrays, where first @@ -146,7 +143,7 @@ class ValArray : public SimpleRefCount> * \param numPages the number of pages * \param values valarray that will be used to initialize elements of 3D array */ - ValArray(uint16_t numRows, uint16_t numCols, uint16_t numPages, std::valarray&& values); + ValArray(size_t numRows, size_t numCols, size_t numPages, std::valarray&& values); /** instruct the compiler to generate the implicitly declared destructor*/ virtual ~ValArray() = default; /** instruct the compiler to generate the implicitly declared copy constructor*/ @@ -168,15 +165,15 @@ class ValArray : public SimpleRefCount> /** * \returns Number of rows */ - uint16_t GetNumRows() const; + size_t GetNumRows() const; /** * \returns Number of columns */ - uint16_t GetNumCols() const; + size_t GetNumCols() const; /** * \returns Number of pages, i.e., the number of 2D arrays */ - uint16_t GetNumPages() const; + size_t GetNumPages() const; /** * \returns Total number of elements */ @@ -188,7 +185,7 @@ class ValArray : public SimpleRefCount> * \param pageIndex The index of the page * \returns A const reference to the element with with rowIndex, colIndex and pageIndex indices. */ - T& operator()(uint16_t rowIndex, uint16_t colIndex, uint16_t pageIndex); + T& operator()(size_t rowIndex, size_t colIndex, size_t pageIndex); /** * \brief Const access operator, with bound-checking in debug profile * \param rowIndex The index of the row @@ -196,7 +193,7 @@ class ValArray : public SimpleRefCount> * \param pageIndex The index of the page * \returns A const reference to the element with with rowIndex, colIndex and pageIndex indices. */ - const T& operator()(uint16_t rowIndex, uint16_t colIndex, uint16_t pageIndex) const; + const T& operator()(size_t rowIndex, size_t colIndex, size_t pageIndex) const; /** * \brief Access operator for 2D ValArrays. * Assuming that the third dimension is equal to 1, e.g. ValArray contains @@ -209,7 +206,7 @@ class ValArray : public SimpleRefCount> * \param colIndex The index of the column * \returns A reference to the element with the specified indices */ - T& operator()(uint16_t rowIndex, uint16_t colIndex); + T& operator()(size_t rowIndex, size_t colIndex); /** * \brief Const access operator for 2D ValArrays. * Assuming that the third dimension is equal to 1, e.g. ValArray contains @@ -218,7 +215,7 @@ class ValArray : public SimpleRefCount> * \param colIndex column index * \returns a Const reference to the value with the specified row and column index. */ - const T& operator()(uint16_t rowIndex, uint16_t colIndex) const; + const T& operator()(size_t rowIndex, size_t colIndex) const; /** * \brief Single-element access operator() for 1D ValArrays. * Assuming that the number of columns and pages is equal to 1, e.g. ValArray @@ -230,13 +227,13 @@ class ValArray : public SimpleRefCount> * \param index The index of the 1D ValArray. * \returns A reference to the value with the specified index. */ - T& operator()(uint16_t index); + T& operator()(size_t index); /** * \brief Single-element access operator() for 1D ValArrays. * \param index The index of the 1D ValArray. * \returns The const reference to the values with the specified index. */ - const T& operator()(uint16_t index) const; + const T& operator()(size_t index) const; /** * \brief Element-wise multiplication with a scalar value. * \param rhs A scalar value of type T @@ -302,14 +299,14 @@ class ValArray : public SimpleRefCount> * \param pageIndex The index of the desired 2D array * \returns a pointer to the data elements of the 2D array */ - T* GetPagePtr(uint16_t pageIndex); + T* GetPagePtr(size_t pageIndex); /** * \brief Get a data pointer to a specific 2D array for use in linear * algebra libraries * \param pageIndex An index of the desired 2D array * \returns a pointer to the data elements of the 2D array */ - const T* GetPagePtr(uint16_t pageIndex) const; + const T* GetPagePtr(size_t pageIndex) const; /** * \brief Checks whether rhs and lhs ValArray objects have the same dimensions. * \param rhs The rhs ValArray @@ -365,11 +362,11 @@ class ValArray : public SimpleRefCount> const T& Elem(size_t row, size_t col, size_t page) const; protected: - uint16_t m_numRows = + size_t m_numRows = 0; //!< The size of the first dimension, i.e., the number of rows of each 2D array - uint16_t m_numCols = + size_t m_numCols = 0; //!< The size of the second dimension, i.e., the number of columns of each 2D array - uint16_t m_numPages = 0; //!< The size of the third dimension, i.e., the number of 2D arrays + size_t m_numPages = 0; //!< The size of the third dimension, i.e., the number of 2D arrays std::valarray m_values; //!< The data values }; @@ -378,21 +375,21 @@ class ValArray : public SimpleRefCount> ************************************************/ template -inline uint16_t +inline size_t ValArray::GetNumRows() const { return m_numRows; }; template -inline uint16_t +inline size_t ValArray::GetNumCols() const { return m_numCols; }; template -inline uint16_t +inline size_t ValArray::GetNumPages() const { return m_numPages; @@ -407,7 +404,7 @@ ValArray::GetSize() const template inline T& -ValArray::operator()(uint16_t rowIndex, uint16_t colIndex, uint16_t pageIndex) +ValArray::operator()(size_t rowIndex, size_t colIndex, size_t pageIndex) { NS_ASSERT_MSG(rowIndex < m_numRows, "Row index out of bounds"); NS_ASSERT_MSG(colIndex < m_numCols, "Column index out of bounds"); @@ -418,7 +415,7 @@ ValArray::operator()(uint16_t rowIndex, uint16_t colIndex, uint16_t pageIndex template inline const T& -ValArray::operator()(uint16_t rowIndex, uint16_t colIndex, uint16_t pageIndex) const +ValArray::operator()(size_t rowIndex, size_t colIndex, size_t pageIndex) const { NS_ASSERT_MSG(rowIndex < m_numRows, "Row index out of bounds"); NS_ASSERT_MSG(colIndex < m_numCols, "Column index out of bounds"); @@ -429,7 +426,7 @@ ValArray::operator()(uint16_t rowIndex, uint16_t colIndex, uint16_t pageIndex template inline T& -ValArray::operator()(uint16_t rowIndex, uint16_t colIndex) +ValArray::operator()(size_t rowIndex, size_t colIndex) { NS_ASSERT_MSG(m_numPages == 1, "Cannot use 2D access operator for 3D ValArray."); return (*this)(rowIndex, colIndex, 0); @@ -437,7 +434,7 @@ ValArray::operator()(uint16_t rowIndex, uint16_t colIndex) template inline const T& -ValArray::operator()(uint16_t rowIndex, uint16_t colIndex) const +ValArray::operator()(size_t rowIndex, size_t colIndex) const { NS_ASSERT_MSG(m_numPages == 1, "Cannot use 2D access operator for 3D ValArray."); return (*this)(rowIndex, colIndex, 0); @@ -445,7 +442,7 @@ ValArray::operator()(uint16_t rowIndex, uint16_t colIndex) const template inline T& -ValArray::operator()(uint16_t index) +ValArray::operator()(size_t index) { NS_ASSERT_MSG(index < m_values.size(), "Invalid index to 1D ValArray. The size of the array should be set through " @@ -458,7 +455,7 @@ ValArray::operator()(uint16_t index) template inline const T& -ValArray::operator()(uint16_t index) const +ValArray::operator()(size_t index) const { NS_ASSERT_MSG(index < m_values.size(), "Invalid index to 1D ValArray.The size of the array should be set through " @@ -522,7 +519,7 @@ ValArray::operator-=(const ValArray& rhs) template inline T* -ValArray::GetPagePtr(uint16_t pageIndex) +ValArray::GetPagePtr(size_t pageIndex) { NS_ASSERT_MSG(pageIndex < m_numPages, "Invalid page index."); return &(m_values[m_numRows * m_numCols * pageIndex]); @@ -530,7 +527,7 @@ ValArray::GetPagePtr(uint16_t pageIndex) template inline const T* -ValArray::GetPagePtr(uint16_t pageIndex) const +ValArray::GetPagePtr(size_t pageIndex) const { NS_ASSERT_MSG(pageIndex < m_numPages, "Invalid page index."); return &(m_values[m_numRows * m_numCols * pageIndex]); @@ -584,7 +581,7 @@ ValArray::Elem(size_t row, size_t col, size_t page) const ************************************************/ template -ValArray::ValArray(uint16_t numRows, uint16_t numCols, uint16_t numPages) +ValArray::ValArray(size_t numRows, size_t numCols, size_t numPages) : m_numRows{numRows}, m_numCols{numCols}, m_numPages{numPages} @@ -594,7 +591,7 @@ ValArray::ValArray(uint16_t numRows, uint16_t numCols, uint16_t numPages) template ValArray::ValArray(const std::valarray& values) - : m_numRows{(uint16_t)values.size()}, + : m_numRows{values.size()}, m_numCols{1}, m_numPages{1}, m_values{values} @@ -603,7 +600,7 @@ ValArray::ValArray(const std::valarray& values) template ValArray::ValArray(std::valarray&& values) - : m_numRows{(uint16_t)values.size()}, + : m_numRows{values.size()}, m_numCols{1}, m_numPages{1}, m_values{std::move(values)} @@ -612,7 +609,7 @@ ValArray::ValArray(std::valarray&& values) template ValArray::ValArray(const std::vector& values) - : m_numRows{(uint16_t)values.size()}, + : m_numRows{values.size()}, m_numCols{1}, m_numPages{1} { @@ -621,7 +618,7 @@ ValArray::ValArray(const std::vector& values) } template -ValArray::ValArray(uint16_t numRows, uint16_t numCols, const std::valarray& values) +ValArray::ValArray(size_t numRows, size_t numCols, const std::valarray& values) : m_numRows{numRows}, m_numCols{numCols}, m_numPages{1}, @@ -632,7 +629,7 @@ ValArray::ValArray(uint16_t numRows, uint16_t numCols, const std::valarray }; template -ValArray::ValArray(uint16_t numRows, uint16_t numCols, std::valarray&& values) +ValArray::ValArray(size_t numRows, size_t numCols, std::valarray&& values) : m_numRows{numRows}, m_numCols{numCols}, m_numPages{1} @@ -643,9 +640,9 @@ ValArray::ValArray(uint16_t numRows, uint16_t numCols, std::valarray&& val }; template -ValArray::ValArray(uint16_t numRows, - uint16_t numCols, - uint16_t numPages, +ValArray::ValArray(size_t numRows, + size_t numCols, + size_t numPages, const std::valarray& values) : m_numRows{numRows}, m_numCols{numCols}, @@ -657,10 +654,7 @@ ValArray::ValArray(uint16_t numRows, }; template -ValArray::ValArray(uint16_t numRows, - uint16_t numCols, - uint16_t numPages, - std::valarray&& values) +ValArray::ValArray(size_t numRows, size_t numCols, size_t numPages, std::valarray&& values) : m_numRows{numRows}, m_numCols{numCols}, m_numPages{numPages} @@ -723,12 +717,12 @@ std::ostream& operator<<(std::ostream& os, const ValArray& a) { os << "\n"; - for (auto p = 0; p != a.GetNumPages(); ++p) + for (size_t p = 0; p != a.GetNumPages(); ++p) { os << "Page " << p << ":\n"; - for (auto i = 0; i != a.GetNumRows(); ++i) + for (size_t i = 0; i != a.GetNumRows(); ++i) { - for (auto j = 0; j != a.GetNumCols(); ++j) + for (size_t j = 0; j != a.GetNumCols(); ++j) { os << "\t" << a(i, j, p); } diff --git a/src/core/test/matrix-array-test-suite.cc b/src/core/test/matrix-array-test-suite.cc index afd2b43cd..100be2ed9 100644 --- a/src/core/test/matrix-array-test-suite.cc +++ b/src/core/test/matrix-array-test-suite.cc @@ -38,7 +38,7 @@ NS_LOG_COMPONENT_DEFINE("MatrixArrayTest"); /** * \ingroup matrixArray-tests - * MatrixArray test for testing constructors + * MatrixArray test case for testing constructors, operators and other functions */ template class MatrixArrayTestCase : public TestCase @@ -100,9 +100,9 @@ MatrixArrayTestCase::DoRun() // test multiplication of matrices (MatrixArray containing only 1 matrix) MatrixArray m1 = MatrixArray(2, 3); MatrixArray m2 = MatrixArray(m1.GetNumCols(), m1.GetNumRows()); - for (auto i = 0; i < m1.GetNumRows(); ++i) + for (size_t i = 0; i < m1.GetNumRows(); ++i) { - for (auto j = 0; j < m1.GetNumCols(); ++j) + for (size_t j = 0; j < m1.GetNumCols(); ++j) { m1(i, j) = 1; m2(j, i) = 1; @@ -121,9 +121,9 @@ MatrixArrayTestCase::DoRun() NS_TEST_ASSERT_MSG_EQ(m3.GetNumRows(), m3.GetNumCols(), "The number of rows and cols should be equal"); - for (auto i = 0; i < m3.GetNumCols(); ++i) + for (size_t i = 0; i < m3.GetNumCols(); ++i) { - for (auto j = 0; j < m3.GetNumRows(); ++j) + for (size_t j = 0; j < m3.GetNumRows(); ++j) { NS_TEST_ASSERT_MSG_EQ(std::real(m3(i, j)), m1.GetNumCols(), @@ -133,9 +133,9 @@ MatrixArrayTestCase::DoRun() // multiplication with a scalar value MatrixArray m4 = m3 * (static_cast(5.0)); - for (auto i = 0; i < m4.GetNumCols(); ++i) + for (size_t i = 0; i < m4.GetNumCols(); ++i) { - for (auto j = 0; j < m4.GetNumRows(); ++j) + for (size_t j = 0; j < m4.GetNumRows(); ++j) { NS_TEST_ASSERT_MSG_EQ(m3(i, j) * (static_cast(5.0)), m4(i, j), @@ -147,11 +147,11 @@ MatrixArrayTestCase::DoRun() // test multiplication of arrays of matrices MatrixArray m5 = MatrixArray(2, 3, 2); MatrixArray m6 = MatrixArray(m5.GetNumCols(), m5.GetNumRows(), m5.GetNumPages()); - for (auto p = 0; p < m5.GetNumPages(); ++p) + for (size_t p = 0; p < m5.GetNumPages(); ++p) { - for (auto i = 0; i < m5.GetNumRows(); ++i) + for (size_t i = 0; i < m5.GetNumRows(); ++i) { - for (auto j = 0; j < m5.GetNumCols(); ++j) + for (size_t j = 0; j < m5.GetNumCols(); ++j) { m5(i, j, p) = 1; m6(j, i, p) = 1; @@ -169,11 +169,11 @@ MatrixArrayTestCase::DoRun() m7.GetNumCols(), "The number of rows and cols should be equal"); - for (auto p = 0; p < m7.GetNumPages(); ++p) + for (size_t p = 0; p < m7.GetNumPages(); ++p) { - for (auto i = 0; i < m7.GetNumCols(); ++i) + for (size_t i = 0; i < m7.GetNumCols(); ++i) { - for (auto j = 0; j < m7.GetNumRows(); ++j) + for (size_t j = 0; j < m7.GetNumRows(); ++j) { NS_TEST_ASSERT_MSG_EQ(std::real(m7(i, j, p)), m5.GetNumCols(), diff --git a/src/core/test/val-array-test-suite.cc b/src/core/test/val-array-test-suite.cc index 7da8eed07..44369c278 100644 --- a/src/core/test/val-array-test-suite.cc +++ b/src/core/test/val-array-test-suite.cc @@ -95,9 +95,9 @@ void ValArrayTestCase::DoRun() { ValArray v1 = ValArray(2, 3); - for (uint16_t i = 0; i < v1.GetNumRows(); ++i) + for (size_t i = 0; i < v1.GetNumRows(); ++i) { - for (uint16_t j = 0; j < v1.GetNumCols(); ++j) + for (size_t j = 0; j < v1.GetNumCols(); ++j) { v1(i, j) = 1; } @@ -108,9 +108,9 @@ ValArrayTestCase::DoRun() NS_TEST_ASSERT_MSG_EQ(v1.GetNumCols(), v2.GetNumCols(), "The number of cols are not equal."); // test copy constructor - for (uint16_t i = 0; i < v1.GetNumRows(); ++i) + for (size_t i = 0; i < v1.GetNumRows(); ++i) { - for (uint16_t j = 0; j < v1.GetNumCols(); ++j) + for (size_t j = 0; j < v1.GetNumCols(); ++j) { NS_TEST_ASSERT_MSG_EQ(v1(i, j), v2(i, j), "The elements are not equal."); } @@ -120,9 +120,9 @@ ValArrayTestCase::DoRun() ValArray 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 (uint16_t i = 0; i < v1.GetNumRows(); ++i) + for (size_t i = 0; i < v1.GetNumRows(); ++i) { - for (uint16_t j = 0; j < v1.GetNumCols(); ++j) + for (size_t j = 0; j < v1.GetNumCols(); ++j) { NS_TEST_ASSERT_MSG_EQ(v1(i, j), v2(i, j), "The elements are not equal."); } @@ -136,9 +136,9 @@ ValArrayTestCase::DoRun() v4 = std::move(v1); NS_LOG_INFO("v4 size after move: " << v4.GetSize()); NS_TEST_ASSERT_MSG_EQ(v1size, v4.GetSize(), "The number of elements are not equal."); - for (uint16_t i = 0; i < v4.GetNumRows(); ++i) + for (size_t i = 0; i < v4.GetNumRows(); ++i) { - for (uint16_t j = 0; j < v4.GetNumCols(); ++j) + for (size_t j = 0; j < v4.GetNumCols(); ++j) { // Use v3 for comparison since it hasn't moved NS_TEST_ASSERT_MSG_EQ(v3(i, j), v4(i, j), "The elements are not equal."); @@ -150,9 +150,9 @@ ValArrayTestCase::DoRun() size_t v3size = v3.GetSize(); ValArray v5(std::move(v3)); NS_TEST_ASSERT_MSG_EQ(v3size, v5.GetSize(), "The number of elements are not equal."); - for (uint16_t i = 0; i < v5.GetNumRows(); ++i) + for (size_t i = 0; i < v5.GetNumRows(); ++i) { - for (uint16_t j = 0; j < v5.GetNumCols(); ++j) + for (size_t j = 0; j < v5.GetNumCols(); ++j) { // Use v4 for comparison since it hasn't moved NS_TEST_ASSERT_MSG_EQ(v4(i, j), v5(i, j), "The elements are not equal."); @@ -177,10 +177,10 @@ ValArrayTestCase::DoRun() // test whether column-major order was respected during the initialization and // also in the access operator if we iterate over rows first we should find 0, 2, 4, 6, ... std::valarray initArray2{0, 2, 4, 6, 1, 3, 5, 7}; - auto testIndex = 0; - for (uint16_t i = 0; i < v6.GetNumRows(); ++i) + size_t testIndex = 0; + for (size_t i = 0; i < v6.GetNumRows(); ++i) { - for (uint16_t j = 0; j < v6.GetNumCols(); ++j) + for (size_t j = 0; j < v6.GetNumCols(); ++j) { NS_TEST_ASSERT_MSG_EQ(v6(i, j), static_cast(initArray2[testIndex]), @@ -203,11 +203,11 @@ ValArrayTestCase::DoRun() // if we iterate over rows first we should find 0, 2, 4, 6, ... std::valarray initArray4{0, 2, 4, 6, 1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7}; testIndex = 0; - for (uint16_t p = 0; p < v7.GetNumPages(); ++p) + for (size_t p = 0; p < v7.GetNumPages(); ++p) { - for (uint16_t i = 0; i < v7.GetNumRows(); ++i) + for (size_t i = 0; i < v7.GetNumRows(); ++i) { - for (uint16_t j = 0; j < v7.GetNumCols(); ++j) + for (size_t j = 0; j < v7.GetNumCols(); ++j) { NS_TEST_ASSERT_MSG_EQ(v7(i, j, p), static_cast(initArray4[testIndex]), @@ -219,11 +219,11 @@ ValArrayTestCase::DoRun() // multiplication with a scalar value with 3D array ValArray v8 = v7 * (static_cast(5.0)); - for (uint16_t p = 0; p < v8.GetNumPages(); ++p) + for (size_t p = 0; p < v8.GetNumPages(); ++p) { - for (uint16_t i = 0; i < v8.GetNumRows(); ++i) + for (size_t i = 0; i < v8.GetNumRows(); ++i) { - for (uint16_t j = 0; j < v8.GetNumCols(); ++j) + for (size_t j = 0; j < v8.GetNumCols(); ++j) { NS_TEST_ASSERT_MSG_EQ(v7(i, j, p) * (static_cast(5.0)), v8(i, j, p),