13#if defined(__GNUC__) && !defined(__clang__)
14#pragma GCC diagnostic push
15#pragma GCC diagnostic ignored "-Wclass-memaccess"
16#pragma GCC diagnostic ignored "-Wunused-variable"
19#pragma clang diagnostic push
20#pragma clang diagnostic ignored "-Wdeprecated-declarations"
26#pragma clang diagnostic pop
28#if defined(__GNUC__) && !defined(__clang__)
29#pragma GCC diagnostic pop
38using EigenMatrix = Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>>;
40using ConstEigenMatrix = Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>>;
45 :
ValArray<T>(numRows, numCols, numPages)
69 :
ValArray<T>(numRows, numCols, values)
83 const std::valarray<T>& values)
84 :
ValArray<T>(numRows, numCols, numPages, values)
92 std::valarray<T>&& values)
93 :
ValArray<T>(numRows, numCols, numPages,
std::move(values))
106 for (
size_t page = 0; page < res.m_numPages; ++page)
112 EigenMatrix<T> resEigenMatrix(res.GetPagePtr(page), res.m_numRows, res.m_numCols);
113 resEigenMatrix = lhsEigenMatrix * rhsEigenMatrix;
119 for (
size_t i = 0; i < res.m_numRows; ++i)
121 for (
size_t j = 0; j < res.m_numCols; ++j)
144 for (
size_t page = 0; page <
m_numPages; ++page)
149 EigenMatrix<T> resEigenMatrix(res.GetPagePtr(page), res.m_numRows, res.m_numCols);
150 resEigenMatrix = thisMatrix.transpose();
157 res.m_values[std::slice(matrixIndex + i * res.m_numRows, res.m_numRows, 1)] =
178 for (
size_t page = 0; page < m_numPages; ++page)
186 res(0, 0, page) = pageValues[0] * pageValues[3] - pageValues[1] * pageValues[2];
189 for (
size_t detN = 0; detN < m_numRows; detN++)
191 auto partDetP = T{0} + 1.0;
192 auto partDetN = T{0} + 1.0;
193 for (
size_t row = 0; row <
m_numRows; row++)
198 partDetP *= pageValues[row *
m_numCols + col];
202 partDetN *= pageValues[row *
m_numCols + col];
204 res(0, 0, page) += partDetP - partDetN;
215 for (
size_t page = 0; page <
m_numPages; ++page)
222 auto absVal = std::abs(pagePtr[i]);
223 res[page] += absVal * absVal;
225 res[page] = sqrt(res[page]);
236 "The left and right MatrixArray should have only one page.");
238 "Left vector numCols and this MatrixArray numRows mismatch.");
240 "Right vector numRows and this MatrixArray numCols mismatch.");
250 for (
size_t page = 0; page <
m_numPages; ++page)
255 EigenMatrix<T> resEigenMap(res.GetPagePtr(page), res.m_numRows, res.m_numCols);
257 resEigenMap = lMatrixEigen * matrixEigen * rMatrixEigen;
262 for (
size_t resRow = 0; resRow < res.m_numRows; ++resRow)
264 for (
size_t resCol = 0; resCol < res.m_numCols; ++resCol)
269 for (
size_t thisCol = 0; thisCol <
m_numCols; ++thisCol)
278 res(resRow, resCol, page) =
290template <
bool EnableBool,
typename>
296 for (
size_t index = 0; index < this->
GetSize(); ++index)
309 for (
size_t copy = 0; copy < nCopies; copy++)
313 copiedMatrix.GetPagePtr(copy)[i] =
m_values[i];
328 extractedPage.m_values[i] =
GetPagePtr(page)[i];
330 return extractedPage;
338 MatrixArray<T>{pages.front().GetNumRows(), pages.front().GetNumCols(), pages.size()};
339 for (
size_t page = 0; page < jointMatrix.GetNumPages(); page++)
342 "All page matrices should have the same number of rows");
344 "All page matrices should have the same number of columns");
346 "All page matrices should have a single page");
351 jointMatrix.GetPagePtr(page)[i] = a;
363 for (std::size_t page = 0; page < pages; page++)
365 for (std::size_t i = 0; i < size; i++)
367 identityMatrix(i, i, page) = 1.0;
370 return identityMatrix;
MatrixArray class inherits ValArray class and provides additional interfaces to ValArray which enable...
MatrixArray< T > HermitianTranspose() const
Function that performs the Hermitian transpose of this MatrixArray and returns a new matrix that is t...
MatrixArray operator*(const T &rhs) const
Element-wise multiplication with a scalar value.
MatrixArray Determinant() const
This operator calculates a vector o determinants, one for each page.
static MatrixArray< T > IdentityMatrix(const size_t size, const size_t pages=1)
Function produces an identity MatrixArray with the specified size.
static MatrixArray< T > JoinPages(const std::vector< MatrixArray< T > > &pages)
Function joins multiple pages into a single MatrixArray.
MatrixArray Transpose() const
This operator interprets the 3D array as an array of matrices, and performs a linear algebra operatio...
MatrixArray< T > MakeNCopies(size_t nCopies) const
Function that copies the current 1-page matrix into a new matrix with n copies of the original matrix...
MatrixArray< T > ExtractPage(size_t page) const
Function extracts a page from a MatrixArray.
MatrixArray MultiplyByLeftAndRightMatrix(const MatrixArray< T > &lMatrix, const MatrixArray< T > &rMatrix) const
Multiply each matrix in the array by the left and the right matrix.
MatrixArray FrobeniusNorm() const
This operator calculates a vector of Frobenius norm, one for each page.
T * GetPagePtr(size_t pageIndex)
Get a data pointer to a specific 2D array for use in linear algebra libraries.
const std::valarray< T > & GetValues() const
Returns underlying values.
size_t GetNumPages() const
size_t m_numCols
The size of the second dimension, i.e., the number of columns of each 2D array.
std::valarray< T > m_values
The data values.
size_t GetNumRows() const
size_t m_numRows
The size of the first dimension, i.e., the number of rows of each 2D array.
size_t GetNumCols() const
size_t m_numPages
The size of the third dimension, i.e., the number of 2D arrays.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t GetSize(Ptr< const Packet > packet, const WifiMacHeader *hdr, bool isAmpdu)
Return the total size of the packet after WifiMacHeader and FCS trailer have been added.