21#include "ns3/matrix-array.h"
86 void DoRun()
override;
107 for (
size_t i = 0; i <
m1.GetNumRows(); ++i)
109 for (
size_t j = 0; j <
m1.GetNumCols(); ++j)
121 "The number of rows in resulting matrix is not correct");
124 "The number of cols in resulting matrix is not correct");
127 "The number of rows and cols should be equal");
134 "The element value should be " <<
m1.GetNumCols());
146 "The values are not equal");
168 "The number of rows in resulting matrix is not correct");
171 "The number of cols in resulting matrix is not correct");
174 "The number of rows and cols should be equal");
184 "The element value should be " << m5.
GetNumCols());
199 std::valarray<int> a{0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4};
200 std::valarray<int> b{0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4};
201 std::valarray<T> aCasted(a.size());
202 std::valarray<T> bCasted(b.size());
203 for (
size_t i = 0; i < a.size(); ++i)
205 aCasted[i] =
static_cast<T
>(a[i]);
207 for (
size_t i = 0; i < b.size(); ++i)
209 bCasted[i] =
static_cast<T
>(b[i]);
217 NS_LOG_INFO(
"m8 (5, 3, 1) = m5.Transpose ()" << m8);
224 "Creation of vector is not correct.");
247 a = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5};
248 b = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1};
249 std::valarray<int> c{2, 3, 4, 6, 2, 3, 4, 6};
250 aCasted = std::valarray<T>(a.size());
251 bCasted = std::valarray<T>(b.size());
252 std::valarray<T> cCasted = std::valarray<T>(c.size());
254 for (
size_t i = 0; i < a.size(); ++i)
256 aCasted[i] =
static_cast<T
>(a[i]);
258 for (
size_t i = 0; i < b.size(); ++i)
260 bCasted[i] =
static_cast<T
>(b[i]);
262 for (
size_t i = 0; i < c.size(); ++i)
264 cCasted[i] =
static_cast<T
>(c[i]);
272 "The number of columns is not as expected.");
275 "The number of rows is not as expected.");
285 a = std::valarray<int>(
286 {0, 1, 0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 0, 1, 0, 1, 2, 3, 2, 3, 4, 5, 4, 5});
287 b = std::valarray<int>({0, 1, 0, 1, 0, 1, 0, 10, 0, 10, 0, 10});
288 c = std::valarray<int>({2, 3, 2, 3, 4, 6, 4, 6, 20, 30, 20, 30, 40, 60, 40, 60});
289 aCasted = std::valarray<T>(a.size());
290 bCasted = std::valarray<T>(b.size());
291 cCasted = std::valarray<T>(c.size());
293 for (
size_t i = 0; i < a.size(); ++i)
295 aCasted[i] =
static_cast<T
>(a[i]);
297 for (
size_t i = 0; i < b.size(); ++i)
299 bCasted[i] =
static_cast<T
>(b[i]);
301 for (
size_t i = 0; i < c.size(); ++i)
303 cCasted[i] =
static_cast<T
>(c[i]);
312 "The number of columns is not as expected.");
315 "The number of rows is not as expected.");
325 a = std::valarray<int>({5, 4, 5, 5, 4, 5});
326 b = std::valarray<int>({0, 1, 0, 1, 0, 1, 1, 2, 3, 10, 100, 1000});
327 c = std::valarray<int>({4, 10, 28, 5450});
328 aCasted = std::valarray<T>(a.size());
329 bCasted = std::valarray<T>(b.size());
330 cCasted = std::valarray<T>(c.size());
332 for (
size_t i = 0; i < a.size(); ++i)
334 aCasted[i] =
static_cast<T
>(a[i]);
336 for (
size_t i = 0; i < b.size(); ++i)
338 bCasted[i] =
static_cast<T
>(b[i]);
340 for (
size_t i = 0; i < c.size(); ++i)
342 cCasted[i] =
static_cast<T
>(c[i]);
351 "The number of columns is not as expected.");
354 "The number of rows is not as expected.");
361 std::valarray<int> d{1, 1, 1};
362 std::valarray<int> e{1, 1};
363 std::valarray<int> f{1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3};
364 std::valarray<int> g{12, 12};
365 std::valarray<T> dCasted(d.size());
366 std::valarray<T> eCasted(e.size());
367 std::valarray<T> fCasted(f.size());
368 std::valarray<T> gCasted(g.size());
369 for (
size_t i = 0; i < d.size(); ++i)
371 dCasted[i] =
static_cast<T
>(d[i]);
373 for (
size_t i = 0; i < e.size(); ++i)
375 eCasted[i] =
static_cast<T
>(e[i]);
377 for (
size_t i = 0; i < f.size(); ++i)
379 fCasted[i] =
static_cast<T
>(f[i]);
381 for (
size_t i = 0; i < g.size(); ++i)
383 gCasted[i] =
static_cast<T
>(g[i]);
393 std::valarray<int> h{1, 3, 2, 2, 4, 0};
394 std::valarray<int> j{2, 2, 3, 4, 1, 3, 0, 5};
395 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};
396 std::valarray<int> l{144, 132, 128, 104, 144, 132, 128, 104};
397 std::valarray<T> hCasted(h.size());
398 std::valarray<T> jCasted(j.size());
399 std::valarray<T> kCasted(k.size());
400 std::valarray<T> lCasted(l.size());
401 for (
size_t i = 0; i < h.size(); ++i)
403 hCasted[i] =
static_cast<T
>(h[i]);
405 for (
size_t i = 0; i < j.size(); ++i)
407 jCasted[i] =
static_cast<T
>(j[i]);
409 for (
size_t i = 0; i < k.size(); ++i)
411 kCasted[i] =
static_cast<T
>(k[i]);
413 for (
size_t i = 0; i < l.size(); ++i)
415 lCasted[i] =
static_cast<T
>(l[i]);
429 size_t lCastedSize = lCasted.size();
430 NS_LOG_INFO(
"size() of lCasted before move: " << lCasted.size());
435 size_t hCastedSize = hCasted.size();
436 NS_LOG_INFO(
"size() of hCasted before move: " << hCasted.size());
441 size_t jCastedSize = jCasted.size();
442 NS_LOG_INFO(
"size() of jCasted before move: " << jCasted.size());
468 void DoRun()
override;
472 :
TestCase(
"ComplexMatrixArrayTestCase")
488 std::valarray<std::complex<double>> complexValarray1 = {
502 std::valarray<std::complex<double>> complexValarray2 = {
MatrixArray class inherits ValArray class and provides additional interfaces to ValArray which enable...
MatrixArray Transpose() const
This operator interprets the 3D array as an array of matrices, and performs a linear algebra operatio...
MatrixArray 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, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
const std::valarray< T > & GetValues() const
Returns underlying values.
size_t GetNumPages() const
size_t GetNumRows() const
size_t GetNumCols() const
Test for testing functions that apply to MatrixArrays that use complex numbers, such as HermitianTran...
~ComplexMatrixArrayTestCase() override
Destructor.
ComplexMatrixArrayTestCase()
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
MatrixArray test case for testing constructors, operators and other functions.
MatrixArrayTestCase(MatrixArrayTestCase< T > &&)=default
Move constructor.
MatrixArrayTestCase< T > & operator=(const MatrixArrayTestCase< T > &)=default
Copy assignment operator.
MatrixArrayTestCase()=default
~MatrixArrayTestCase() override
Destructor.
MatrixArrayTestCase(const MatrixArrayTestCase< T > &)=default
Copy constructor.
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.
static MatrixArrayTestSuite g_matrixArrayTestSuite
MatrixArrayTestSuite instance variable.
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
MatrixArray< std::complex< double > > ComplexMatrixArray
Create an alias for MatrixArray using complex type.