86 ValArray(
size_t numRows,
size_t numCols = 1,
size_t numPages = 1);
92 explicit ValArray(
const std::valarray<T>& values);
104 explicit ValArray(
const std::vector<T>& values);
112 ValArray(
size_t numRows,
size_t numCols,
const std::valarray<T>& values);
120 ValArray(
size_t numRows,
size_t numCols, std::valarray<T>&& values);
130 ValArray(
size_t numRows,
size_t numCols,
size_t numPages,
const std::valarray<T>& values);
140 ValArray(
size_t numRows,
size_t numCols,
size_t numPages, std::valarray<T>&& values);
182 T&
operator()(
size_t rowIndex,
size_t colIndex,
size_t pageIndex);
190 const T&
operator()(
size_t rowIndex,
size_t colIndex,
size_t pageIndex)
const;
203 T&
operator()(
size_t rowIndex,
size_t colIndex);
212 const T&
operator()(
size_t rowIndex,
size_t colIndex)
const;
340 const std::valarray<T>&
GetValues()
const;
348 T&
Elem(
size_t row,
size_t col,
size_t page);
356 const T&
Elem(
size_t row,
size_t col,
size_t page)
const;
426 return (*
this)(rowIndex, colIndex, 0);
434 return (*
this)(rowIndex, colIndex, 0);
442 "Invalid index to 1D ValArray. The size of the array should be set through "
446 "Access operator allowed only for 1D ValArray.");
455 "Invalid index to 1D ValArray.The size of the array should be set through "
459 "Access operator allowed only for 1D ValArray.");
542 return (*
this)(index);
549 return (*
this)(index);
553inline const std::valarray<T>&
563 return (*
this)(row, col, page);
570 return (*
this)(row, col, page);
611 std::copy(values.begin(), values.end(), std::begin(
m_values));
622 "Dimensions and the initialization array size do not match.");
632 "Dimensions and the initialization array size do not match.");
640 const std::valarray<T>& values)
647 "Dimensions and the initialization array size do not match.");
657 "Dimensions and the initialization array size do not match.");
673 return !((*this) == rhs);
683 [tol](T lhsValue, T rhsValue) {
684 return lhsValue == rhsValue ||
685 std::abs(lhsValue - rhsValue) <= std::abs(tol);
694 "Dimensions mismatch: "
695 "lhs (rows, cols, pages) = ("
698 "rhs (rows, cols, pages) = ("
716 os <<
"Page " << p <<
":\n";
721 os <<
"\t" << a(i, j, p);
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
ValArray is a class to efficiently store 3D array.
T * GetPagePtr(size_t pageIndex)
Get a data pointer to a specific 2D array for use in linear algebra libraries.
void AssertEqualDims(const ValArray< T > &rhs) const
Function that asserts if the dimensions of lhs and rhs ValArray are not equal and prints a message wi...
T & operator()(size_t rowIndex, size_t colIndex, size_t pageIndex)
Access operator, with bound-checking in debug profile.
T & Elem(size_t row, size_t col, size_t page)
Alternative access operator to access a specific element.
ValArray operator+(const ValArray< T > &rhs) const
operator+ definition for ValArray<T>.
ValArray(const ValArray< T > &)=default
instruct the compiler to generate the implicitly declared copy constructor
ValArray(ValArray< T > &&)=default
instruct the compiler to generate the implicitly declared move constructor
const std::valarray< T > & GetValues() const
Returns underlying values.
ValArray< T > & operator+=(const ValArray< T > &rhs)
operator+= definition for ValArray<T>.
bool IsAlmostEqual(const ValArray< T > &rhs, T tol) const
Compare Valarray up to a given absolute tolerance.
bool operator!=(const ValArray< T > &rhs) const
operator!= definition for ValArray<T>.
ValArray< T > & operator=(ValArray< T > &&)=default
Move assignment operator.
T & operator[](size_t index)
Single-element access operator[] that can be used to access a specific element of 1D ValArray.
bool operator==(const ValArray< T > &rhs) const
operator== definition for ValArray<T>.
size_t GetNumPages() const
ValArray & operator=(const ValArray< T > &)=default
Copy assignment operator.
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.
ValArray< T > & operator-=(const ValArray< T > &rhs)
operator-= definition for ValArray<T>.
size_t GetNumRows() const
size_t m_numRows
The size of the first dimension, i.e., the number of rows of each 2D array.
bool EqualDims(const ValArray< T > &rhs) const
Checks whether rhs and lhs ValArray objects have the same dimensions.
size_t GetNumCols() const
size_t m_numPages
The size of the third dimension, i.e., the number of 2D arrays.
ValArray operator*(const T &rhs) const
Element-wise multiplication with a scalar value.
ValArray operator-() const
unary operator- definition for ValArray<T>.
virtual ~ValArray()=default
instruct the compiler to generate the implicitly declared destructor
#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.
std::ostream & operator<<(std::ostream &os, const Angles &a)
ns3::SimpleRefCount declaration and template implementation.