21 #include "ns3/matrix-array.h"
82 void DoRun()
override;
103 for (
size_t i = 0; i <
m1.GetNumRows(); ++i)
105 for (
size_t 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());
195 std::valarray<int> a{0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4};
196 std::valarray<int> b{0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4};
197 std::valarray<T> aCasted(a.size());
198 std::valarray<T> bCasted(b.size());
199 for (
size_t i = 0; i < a.size(); ++i)
201 aCasted[i] =
static_cast<T
>(a[i]);
203 for (
size_t i = 0; i < b.size(); ++i)
205 bCasted[i] =
static_cast<T
>(b[i]);
213 NS_LOG_INFO(
"m8 (5, 3, 1) = m5.Transpose ()" << m8);
220 "Creation of vector is not correct.");
243 a = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5};
244 b = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1};
245 std::valarray<int> c{2, 3, 4, 6, 2, 3, 4, 6};
246 aCasted = std::valarray<T>(a.size());
247 bCasted = std::valarray<T>(b.size());
248 std::valarray<T> cCasted = std::valarray<T>(c.size());
250 for (
size_t i = 0; i < a.size(); ++i)
252 aCasted[i] =
static_cast<T
>(a[i]);
254 for (
size_t i = 0; i < b.size(); ++i)
256 bCasted[i] =
static_cast<T
>(b[i]);
258 for (
size_t i = 0; i < c.size(); ++i)
260 cCasted[i] =
static_cast<T
>(c[i]);
268 "The number of columns is not as expected.");
271 "The number of rows is not as expected.");
281 a = std::valarray<int>(
282 {0, 1, 0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 0, 1, 0, 1, 2, 3, 2, 3, 4, 5, 4, 5});
283 b = std::valarray<int>({0, 1, 0, 1, 0, 1, 0, 10, 0, 10, 0, 10});
284 c = std::valarray<int>({2, 3, 2, 3, 4, 6, 4, 6, 20, 30, 20, 30, 40, 60, 40, 60});
285 aCasted = std::valarray<T>(a.size());
286 bCasted = std::valarray<T>(b.size());
287 cCasted = std::valarray<T>(c.size());
289 for (
size_t i = 0; i < a.size(); ++i)
291 aCasted[i] =
static_cast<T
>(a[i]);
293 for (
size_t i = 0; i < b.size(); ++i)
295 bCasted[i] =
static_cast<T
>(b[i]);
297 for (
size_t i = 0; i < c.size(); ++i)
299 cCasted[i] =
static_cast<T
>(c[i]);
308 "The number of columns is not as expected.");
311 "The number of rows is not as expected.");
321 a = std::valarray<int>({5, 4, 5, 5, 4, 5});
322 b = std::valarray<int>({0, 1, 0, 1, 0, 1, 1, 2, 3, 10, 100, 1000});
323 c = std::valarray<int>({4, 10, 28, 5450});
324 aCasted = std::valarray<T>(a.size());
325 bCasted = std::valarray<T>(b.size());
326 cCasted = std::valarray<T>(c.size());
328 for (
size_t i = 0; i < a.size(); ++i)
330 aCasted[i] =
static_cast<T
>(a[i]);
332 for (
size_t i = 0; i < b.size(); ++i)
334 bCasted[i] =
static_cast<T
>(b[i]);
336 for (
size_t i = 0; i < c.size(); ++i)
338 cCasted[i] =
static_cast<T
>(c[i]);
347 "The number of columns is not as expected.");
350 "The number of rows is not as expected.");
357 std::valarray<int> d{1, 1, 1};
358 std::valarray<int> e{1, 1};
359 std::valarray<int>
f{1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3};
360 std::valarray<int> g{12, 12};
361 std::valarray<T> dCasted(d.size());
362 std::valarray<T> eCasted(e.size());
363 std::valarray<T> fCasted(
f.size());
364 std::valarray<T> gCasted(g.size());
365 for (
size_t i = 0; i < d.size(); ++i)
367 dCasted[i] =
static_cast<T
>(d[i]);
369 for (
size_t i = 0; i < e.size(); ++i)
371 eCasted[i] =
static_cast<T
>(e[i]);
373 for (
size_t i = 0; i <
f.size(); ++i)
375 fCasted[i] =
static_cast<T
>(
f[i]);
377 for (
size_t i = 0; i < g.size(); ++i)
379 gCasted[i] =
static_cast<T
>(g[i]);
389 std::valarray<int> h{1, 3, 2, 2, 4, 0};
390 std::valarray<int> j{2, 2, 3, 4, 1, 3, 0, 5};
391 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};
392 std::valarray<int> l{144, 132, 128, 104, 144, 132, 128, 104};
393 std::valarray<T> hCasted(h.size());
394 std::valarray<T> jCasted(j.size());
395 std::valarray<T> kCasted(
k.size());
396 std::valarray<T> lCasted(l.size());
397 for (
size_t i = 0; i < h.size(); ++i)
399 hCasted[i] =
static_cast<T
>(h[i]);
401 for (
size_t i = 0; i < j.size(); ++i)
403 jCasted[i] =
static_cast<T
>(j[i]);
405 for (
size_t i = 0; i <
k.size(); ++i)
407 kCasted[i] =
static_cast<T
>(
k[i]);
409 for (
size_t i = 0; i < l.size(); ++i)
411 lCasted[i] =
static_cast<T
>(l[i]);
425 size_t lCastedSize = lCasted.size();
426 NS_LOG_INFO(
"size() of lCasted before move: " << lCasted.size());
431 size_t hCastedSize = hCasted.size();
432 NS_LOG_INFO(
"size() of hCasted before move: " << hCasted.size());
437 size_t jCastedSize = jCasted.size();
438 NS_LOG_INFO(
"size() of jCasted before move: " << jCasted.size());
464 void DoRun()
override;
468 :
TestCase(
"ComplexMatrixArrayTestCase")
484 std::valarray<std::complex<double>> complexValarray1 = {
498 std::valarray<std::complex<double>> complexValarray2 = {
double f(double x, void *params)
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, TestDuration 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< T > & operator=(const MatrixArrayTestCase< T > &)=default
Copy assignment operator.
MatrixArrayTestCase(MatrixArrayTestCase< T > &&)=default
Move constructor.
MatrixArrayTestCase()=default
MatrixArrayTestCase< T > & operator=(MatrixArrayTestCase< T > &&)=default
Move assignment operator.
~MatrixArrayTestCase() override
Destructor.
MatrixArrayTestCase(const MatrixArrayTestCase< T > &)=default
Copy constructor.
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.
MatrixArray< std::complex< double > > ComplexMatrixArray
Create an alias for MatrixArray using complex type.