21 #include "ns3/matrix-array.h"
82 void DoRun()
override;
103 for (
auto i = 0; i <
m1.GetNumRows(); ++i)
105 for (
auto j = 0; j <
m1.GetNumCols(); ++j)
117 "The number of rows in resulting matrix is not correct");
120 "The number of cols in resulting matrix is not correct");
123 "The number of rows and cols should be equal");
130 "The element value should be " <<
m1.GetNumCols());
142 "The values are not equal");
164 "The number of rows in resulting matrix is not correct");
167 "The number of cols in resulting matrix is not correct");
170 "The number of rows and cols should be equal");
180 "The element value should be " << m5.
GetNumCols());
199 "Creation of vector is not correct.");
220 std::valarray<int> a{0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5};
221 std::valarray<int> b{0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1};
222 std::valarray<int> c{2, 3, 4, 6, 2, 3, 4, 6};
223 std::valarray<T> aCasted(a.size());
224 std::valarray<T> bCasted(b.size());
225 std::valarray<T> cCasted(c.size());
227 for (
size_t i = 0; i < a.size(); ++i)
229 aCasted[i] =
static_cast<T
>(a[i]);
231 for (
size_t i = 0; i < b.size(); ++i)
233 bCasted[i] =
static_cast<T
>(b[i]);
235 for (
size_t i = 0; i < c.size(); ++i)
237 cCasted[i] =
static_cast<T
>(c[i]);
245 "The number of columns is not as expected.");
248 "The number of rows is not as expected.");
252 NS_LOG_INFO(
"m13 = matrixArrayA * matrixArrayB:" << m13);
255 std::valarray<int> d{1, 1, 1};
256 std::valarray<int> e{1, 1};
257 std::valarray<int>
f{1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3};
258 std::valarray<int> g{12, 12};
259 std::valarray<T> dCasted(d.size());
260 std::valarray<T> eCasted(e.size());
261 std::valarray<T> fCasted(
f.size());
262 std::valarray<T> gCasted(g.size());
263 for (
size_t i = 0; i < d.size(); ++i)
265 dCasted[i] =
static_cast<T
>(d[i]);
267 for (
size_t i = 0; i < e.size(); ++i)
269 eCasted[i] =
static_cast<T
>(e[i]);
271 for (
size_t i = 0; i <
f.size(); ++i)
273 fCasted[i] =
static_cast<T
>(
f[i]);
275 for (
size_t i = 0; i < g.size(); ++i)
277 gCasted[i] =
static_cast<T
>(g[i]);
287 std::valarray<int> h{1, 3, 2, 2, 4, 0};
288 std::valarray<int> j{2, 2, 3, 4, 1, 3, 0, 5};
289 std::valarray<int>
k{1, 2, 0, 0, 2, 3, 4, 1, 2, 3, 4, 1, 1, 2, 0, 0, 2, 3, 4, 1, 2, 3, 4, 1};
290 std::valarray<int> l{144, 132, 128, 104, 144, 132, 128, 104};
291 std::valarray<T> hCasted(h.size());
292 std::valarray<T> jCasted(j.size());
293 std::valarray<T> kCasted(
k.size());
294 std::valarray<T> lCasted(l.size());
295 for (
size_t i = 0; i < h.size(); ++i)
297 hCasted[i] =
static_cast<T
>(h[i]);
299 for (
size_t i = 0; i < j.size(); ++i)
301 jCasted[i] =
static_cast<T
>(j[i]);
303 for (
size_t i = 0; i <
k.size(); ++i)
305 kCasted[i] =
static_cast<T
>(
k[i]);
307 for (
size_t i = 0; i < l.size(); ++i)
309 lCasted[i] =
static_cast<T
>(l[i]);
323 NS_LOG_INFO(
"size() of lCasted before move: " << lCasted.size());
325 NS_LOG_INFO(
"size() of lCasted after move: " << lCasted.size());
329 NS_LOG_INFO(
"size() of hCasted before move: " << hCasted.size());
331 NS_LOG_INFO(
"size() of hCasted after move: " << hCasted.size());
335 NS_LOG_INFO(
"size() of jCasted before move: " << jCasted.size());
337 NS_LOG_INFO(
"size() of jCasted after move: " << jCasted.size());
double f(double x, void *params)
MatrixArray class inherits ValArray class and provides additional interfaces to ValArray which enable...
MatrixArray< T > Transpose() const
This operator interprets the 3D array as an array of matrices, and performs a linear algebra operatio...
MatrixArray< T > MultiplyByLeftAndRightMatrix(const MatrixArray< T > &lMatrix, const MatrixArray< T > &rMatrix) const
Multiply each matrix in the array by the left and the right matrix.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
uint16_t GetNumRows() const
uint16_t GetNumCols() const
const std::valarray< T > & GetValues() const
Returns underlying values.
uint16_t GetNumPages() const
MatrixArray test for testing constructors.
MatrixArrayTestCase< T > & operator=(const MatrixArrayTestCase< T > &)=default
Copy assignment operator.
MatrixArrayTestCase()=default
MatrixArrayTestCase< T > & operator=(MatrixArrayTestCase< T > &&)=default
Move assignment operator.
void DoRun() override
Implementation to actually run this TestCase.
MatrixArrayTestSuite()
Constructor.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
const double m1
First component modulus, 232 - 209.
const double m2
Second component modulus, 232 - 22853.
static MatrixArrayTestSuite g_matrixArrayTestSuite
MatrixArrayTestSuite instance variable.
Every class exported by the ns3 library is enclosed in the ns3 namespace.