Implement fixed size options for rotgen containers
See merge request oss/rotgen!11
This commit is contained in:
parent
8e545dd51a
commit
2084874b1b
39 changed files with 1247 additions and 323 deletions
|
|
@ -6,40 +6,42 @@
|
|||
*/
|
||||
//==================================================================================================
|
||||
#include "unit/tests.hpp"
|
||||
#include <rotgen/block.hpp>
|
||||
#include <rotgen/matrix.hpp>
|
||||
#include <rotgen/rotgen.hpp>
|
||||
|
||||
void test_size(const auto& matrix, std::size_t rows, std::size_t cols)
|
||||
void test_size(const auto& matrix, rotgen::Index rows, rotgen::Index cols)
|
||||
{
|
||||
TTS_EQUAL(matrix.rows(), rows);
|
||||
TTS_EQUAL(matrix.cols(), cols);
|
||||
TTS_EQUAL(matrix.size(), rows*cols);
|
||||
}
|
||||
|
||||
void test_value(const auto& matrix, std::size_t rows, std::size_t cols, auto constant)
|
||||
void test_value(const auto& matrix, rotgen::Index rows, rotgen::Index cols, auto constant)
|
||||
{
|
||||
TTS_EXPECT(verify_rotgen_reentrance(matrix));
|
||||
test_size(matrix, rows, cols);
|
||||
for(std::size_t r=0;r<rows;++r)
|
||||
for(std::size_t c=0;c<cols;++c)
|
||||
for(rotgen::Index r=0;r<rows;++r)
|
||||
for(rotgen::Index c=0;c<cols;++c)
|
||||
TTS_EQUAL(matrix(r, c), constant);
|
||||
}
|
||||
|
||||
void test_random(const auto& matrix, std::size_t rows, std::size_t cols)
|
||||
void test_random(const auto& matrix, rotgen::Index rows, rotgen::Index cols)
|
||||
{
|
||||
TTS_EXPECT(verify_rotgen_reentrance(matrix));
|
||||
test_size(matrix, rows, cols);
|
||||
for(std::size_t r=0;r<rows;++r)
|
||||
for(std::size_t c=0;c<cols;++c)
|
||||
for(rotgen::Index r=0;r<rows;++r)
|
||||
for(rotgen::Index c=0;c<cols;++c)
|
||||
{
|
||||
TTS_GREATER_EQUAL(matrix(r, c), -1.0);
|
||||
TTS_LESS_EQUAL(matrix(r, c), 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
void test_identity(const auto& matrix, std::size_t rows, std::size_t cols)
|
||||
void test_identity(const auto& matrix, rotgen::Index rows, rotgen::Index cols)
|
||||
{
|
||||
TTS_EXPECT(verify_rotgen_reentrance(matrix));
|
||||
test_size(matrix, rows, cols);
|
||||
for(std::size_t r=0;r<rows;++r)
|
||||
for(std::size_t c=0;c<cols;++c)
|
||||
for(rotgen::Index r=0;r<rows;++r)
|
||||
for(rotgen::Index c=0;c<cols;++c)
|
||||
TTS_EQUAL(matrix(r, c), r==c ? 1 : 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue