A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::ValArray< T > Class Template Reference

ValArray is a class to efficiently store 3D array. More...

#include "val-array.h"

+ Inheritance diagram for ns3::ValArray< T >:
+ Collaboration diagram for ns3::ValArray< T >:

Public Member Functions

 ValArray ()=default
 
 ValArray (const std::valarray< T > &values)
 Constructor creates a single 1D array of values.size () elements and 1 column, and uses std::valarray<T> values to initialize the elements.
 
 ValArray (const std::vector< T > &values)
 Constructor creates a single 1D array of values.size () elements and 1 column, and uses values std::vector<T> to initialize the elements.
 
 ValArray (const ValArray< T > &)=default
 instruct the compiler to generate the implicitly declared copy constructor
 
 ValArray (size_t numRows, size_t numCols, const std::valarray< T > &values)
 Constructor creates a single 2D array of numRows and numCols, and uses std::valarray<T> values to initialize the elements.
 
 ValArray (size_t numRows, size_t numCols, size_t numPages, const std::valarray< T > &values)
 Constructor creates the 3D array of numRows x numCols x numPages dimensions, and uses std::valarray<T> values to initialize all the 2D arrays, where first numRows*numCols elements will belong to the first 2D array.
 
 ValArray (size_t numRows, size_t numCols, size_t numPages, std::valarray< T > &&values)
 Constructor creates the 3D array of numRows x numCols x numPages dimensions, and moves std::valarray<T> values to initialize all the 2D arrays, where first numRows*numCols elements will belong to the first 2D array.
 
 ValArray (size_t numRows, size_t numCols, std::valarray< T > &&values)
 Constructor creates a single 2D array of numRows and numCols, and moves std::valarray<T> values to initialize the elements.
 
 ValArray (size_t numRows, size_t numCols=1, size_t numPages=1)
 Constructor that creates "numPages" number of 2D arrays that are of dimensions "numRows"x"numCols", and are initialized with all-zero elements.
 
 ValArray (std::valarray< T > &&values)
 Constructor creates a single 1D array of values.size () elements and 1 column, and moves std::valarray<T> values to initialize the elements.
 
 ValArray (ValArray< T > &&)=default
 instruct the compiler to generate the implicitly declared move constructor
 
virtual ~ValArray ()=default
 instruct the compiler to generate the implicitly declared destructor
 
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 with the matrices dimensions.
 
T & Elem (size_t row, size_t col, size_t page)
 Alternative access operator to access a specific element.
 
const T & Elem (size_t row, size_t col, size_t page) const
 Alternative const access operator to access a specific element.
 
bool EqualDims (const ValArray< T > &rhs) const
 Checks whether rhs and lhs ValArray objects have the same dimensions.
 
size_t GetNumCols () const
 
size_t GetNumPages () const
 
size_t GetNumRows () const
 
T * GetPagePtr (size_t pageIndex)
 Get a data pointer to a specific 2D array for use in linear algebra libraries.
 
const T * GetPagePtr (size_t pageIndex) const
 Get a data pointer to a specific 2D array for use in linear algebra libraries.
 
size_t GetSize () const
 
const std::valarray< T > & GetValues () const
 Returns underlying values.
 
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>.
 
T & operator() (size_t index)
 Single-element access operator() for 1D ValArrays.
 
const T & operator() (size_t index) const
 Single-element access operator() for 1D ValArrays.
 
T & operator() (size_t rowIndex, size_t colIndex)
 Access operator for 2D ValArrays.
 
const T & operator() (size_t rowIndex, size_t colIndex) const
 Const access operator for 2D ValArrays.
 
T & operator() (size_t rowIndex, size_t colIndex, size_t pageIndex)
 Access operator, with bound-checking in debug profile.
 
const T & operator() (size_t rowIndex, size_t colIndex, size_t pageIndex) const
 Const access operator, with bound-checking in debug profile.
 
ValArray< T > operator* (const T &rhs) const
 Element-wise multiplication with a scalar value.
 
ValArray< T > operator+ (const ValArray< T > &rhs) const
 operator+ definition for ValArray<T>.
 
ValArray< T > & operator+= (const ValArray< T > &rhs)
 operator+= definition for ValArray<T>.
 
ValArray< T > operator- () const
 unary operator- definition for ValArray<T>.
 
ValArray< T > operator- (const ValArray< T > &rhs) const
 binary operator- definition for ValArray<T>.
 
ValArray< T > & operator-= (const ValArray< T > &rhs)
 operator-= definition for ValArray<T>.
 
ValArray< T > & operator= (const ValArray< T > &)=default
 Copy assignment operator.
 
ValArray< T > & operator= (ValArray< T > &&)=default
 Move assignment operator.
 
bool operator== (const ValArray< T > &rhs) const
 operator== definition for ValArray<T>.
 
T & operator[] (size_t index)
 Single-element access operator[] that can be used to access a specific element of 1D ValArray.
 
const T & operator[] (size_t index) const
 Const access operator that can be used to access a specific element of 1D ValArray.
 
- Public Member Functions inherited from ns3::SimpleRefCount< ValArray< T > >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 

Protected Attributes

size_t m_numCols
 The size of the second dimension, i.e., the number of columns of each 2D array.
 
size_t m_numPages = 0
 The size of the third dimension, i.e., the number of 2D arrays.
 
size_t m_numRows
 The size of the first dimension, i.e., the number of rows of each 2D array.
 
std::valarray< T > m_values
 The data values.
 

Detailed Description

template<class T>
class ns3::ValArray< T >

ValArray is a class to efficiently store 3D array.

The class is general enough to represent 1D array or 2D arrays. ValArray also provides basic algebra element-wise operations over the whole array (1D, 2D, 3D).

Main characteristics of ValArray are the following:

  • ValArray uses std::valarray to efficiently store data.
  • In general, the elements are stored in memory as a sequence of consecutive 2D arrays. The dimensions of 2D arrays are defined by numRows and numCols, while the number of 2D arrays is defined by numPages. Notice that if we set the number of pages to 1, we will have only a single 2D array. If we additionally set numRows or numCols to 1, we will have 1D array.
  • All 2D arrays have the same dimensions, i.e. numRows and numCols.
  • 2D arrays are stored in column-major order, which is the default order in Eigen and Armadillo libraries, which allows a straightforward mapping of any page (2D array) within ValArray to Eigen or Armadillo matrices.

Examples of column-major order:

a) in the case of a 2D array, we will have in memory the following order of elements, assuming that the indexes are rowIndex, colIndex, pageIndex:

a000 a100 a010 a110 a020 a120.

b) in the case of a 3D array, e.g, if there are two 2D arrays of 2x3 dimensions we will have in memory the following order of elements, assuming that the indexes are rowIndex, colIndex, pageIndex:

a000 a100 a010 a110 a020 a120 a001 a101 a011 a111 a021 a121.

  • The access to the elements is implemented in operators:
  • operator (rowIndex) and operator[] (rowIndex) for 1D array (assuming colIndex=0, pageIndex=0),
  • operator (rowIndex,colIndex) for 2D array (assuming pageIndex=0) and
  • operator(rowIndex, colIndex, pageIndex) for 3D array.

Definition of ValArray as a template class allows using different numerical types as the elements of the vectors/matrices, e.g., complex numbers, double, int, etc.

Definition at line 79 of file val-array.h.

Constructor & Destructor Documentation

◆ ValArray() [1/11]

template<class T >
ns3::ValArray< T >::ValArray ( )
default

◆ ValArray() [2/11]

template<class T >
ns3::ValArray< T >::ValArray ( size_t  numRows,
size_t  numCols = 1,
size_t  numPages = 1 
)

Constructor that creates "numPages" number of 2D arrays that are of dimensions "numRows"x"numCols", and are initialized with all-zero elements.

If only 1 parameter, numRows, is provided then a single 1D array is being created.

Parameters
numRowsthe number of rows
numColsthe number of columns
numPagesthe number of pages

Definition at line 584 of file val-array.h.

References ns3::ValArray< T >::m_numCols, ns3::ValArray< T >::m_numPages, ns3::ValArray< T >::m_numRows, and ns3::ValArray< T >::m_values.

◆ ValArray() [3/11]

template<class T >
ns3::ValArray< T >::ValArray ( const std::valarray< T > &  values)
explicit

Constructor creates a single 1D array of values.size () elements and 1 column, and uses std::valarray<T> values to initialize the elements.

Parameters
valuesstd::valarray<T> that will be used to initialize elements of 1D array

Definition at line 593 of file val-array.h.

◆ ValArray() [4/11]

template<class T >
ns3::ValArray< T >::ValArray ( std::valarray< T > &&  values)

Constructor creates a single 1D array of values.size () elements and 1 column, and moves std::valarray<T> values to initialize the elements.

Parameters
valuesstd::valarray<T> that will be moved to initialize elements of 1D array

Definition at line 602 of file val-array.h.

◆ ValArray() [5/11]

template<class T >
ns3::ValArray< T >::ValArray ( const std::vector< T > &  values)
explicit

Constructor creates a single 1D array of values.size () elements and 1 column, and uses values std::vector<T> to initialize the elements.

Parameters
valuesstd::vector<T> that will be used to initialize elements of 1D array

Definition at line 611 of file val-array.h.

References ns3::ValArray< T >::m_values.

◆ ValArray() [6/11]

template<class T >
ns3::ValArray< T >::ValArray ( size_t  numRows,
size_t  numCols,
const std::valarray< T > &  values 
)

Constructor creates a single 2D array of numRows and numCols, and uses std::valarray<T> values to initialize the elements.

Parameters
numRowsthe number of rows
numColsthe number of columns
valuesvalarray<T> that will be used to initialize elements of 3D array

Definition at line 621 of file val-array.h.

References ns3::ValArray< T >::m_numCols, ns3::ValArray< T >::m_numRows, and NS_ASSERT_MSG.

◆ ValArray() [7/11]

template<class T >
ns3::ValArray< T >::ValArray ( size_t  numRows,
size_t  numCols,
std::valarray< T > &&  values 
)

Constructor creates a single 2D array of numRows and numCols, and moves std::valarray<T> values to initialize the elements.

Parameters
numRowsthe number of rows
numColsthe number of columns
valuesvalarray<T> that will be used to initialize elements of 3D array

Definition at line 632 of file val-array.h.

References ns3::ValArray< T >::m_numCols, ns3::ValArray< T >::m_numRows, ns3::ValArray< T >::m_values, and NS_ASSERT_MSG.

◆ ValArray() [8/11]

template<class T >
ns3::ValArray< T >::ValArray ( size_t  numRows,
size_t  numCols,
size_t  numPages,
const std::valarray< T > &  values 
)

Constructor creates the 3D array of numRows x numCols x numPages dimensions, and uses std::valarray<T> values to initialize all the 2D arrays, where first numRows*numCols elements will belong to the first 2D array.

Parameters
numRowsthe number of rows
numColsthe number of columns
numPagesthe number of pages
valuesvalarray<T> that will be used to initialize elements of 3D array

Definition at line 643 of file val-array.h.

References ns3::ValArray< T >::m_numCols, ns3::ValArray< T >::m_numPages, ns3::ValArray< T >::m_numRows, and NS_ASSERT_MSG.

◆ ValArray() [9/11]

template<class T >
ns3::ValArray< T >::ValArray ( size_t  numRows,
size_t  numCols,
size_t  numPages,
std::valarray< T > &&  values 
)

Constructor creates the 3D array of numRows x numCols x numPages dimensions, and moves std::valarray<T> values to initialize all the 2D arrays, where first numRows*numCols elements will belong to the first 2D array.

Parameters
numRowsthe number of rows
numColsthe number of columns
numPagesthe number of pages
valuesvalarray<T> that will be used to initialize elements of 3D array

Definition at line 657 of file val-array.h.

References ns3::ValArray< T >::m_numCols, ns3::ValArray< T >::m_numPages, ns3::ValArray< T >::m_numRows, ns3::ValArray< T >::m_values, and NS_ASSERT_MSG.

◆ ~ValArray()

template<class T >
virtual ns3::ValArray< T >::~ValArray ( )
virtualdefault

instruct the compiler to generate the implicitly declared destructor

◆ ValArray() [10/11]

template<class T >
ns3::ValArray< T >::ValArray ( const ValArray< T > &  )
default

instruct the compiler to generate the implicitly declared copy constructor

◆ ValArray() [11/11]

template<class T >
ns3::ValArray< T >::ValArray ( ValArray< T > &&  )
default

instruct the compiler to generate the implicitly declared move constructor

Member Function Documentation

◆ AssertEqualDims()

template<class T >
void ns3::ValArray< T >::AssertEqualDims ( const ValArray< T > &  rhs) const

Function that asserts if the dimensions of lhs and rhs ValArray are not equal and prints a message with the matrices dimensions.

Parameters
rhsthe rhs ValArray

Definition at line 697 of file val-array.h.

References ns3::ValArray< T >::m_numCols, ns3::ValArray< T >::m_numPages, ns3::ValArray< T >::m_numRows, and NS_ASSERT_MSG.

◆ Elem() [1/2]

template<class T >
T & ns3::ValArray< T >::Elem ( size_t  row,
size_t  col,
size_t  page 
)
inline

Alternative access operator to access a specific element.

Parameters
rowthe row index of the element to be obtained
colthe col index of the element to be obtained
pagethe page index of the element to be obtained
Returns
a reference to the element of this ValArray

Definition at line 567 of file val-array.h.

◆ Elem() [2/2]

template<class T >
const T & ns3::ValArray< T >::Elem ( size_t  row,
size_t  col,
size_t  page 
) const
inline

Alternative const access operator to access a specific element.

Parameters
rowthe row index of the element to be obtained
colthe column index of the element to be obtained
pagethe page index of the element to be obtained
Returns
a const reference to the element of this ValArray

Definition at line 574 of file val-array.h.

◆ EqualDims()

template<class T >
bool ns3::ValArray< T >::EqualDims ( const ValArray< T > &  rhs) const
inline

Checks whether rhs and lhs ValArray objects have the same dimensions.

Parameters
rhsThe rhs ValArray
Returns
true if the dimensions of lhs and rhs are equal, otherwise it returns false

Definition at line 538 of file val-array.h.

References ns3::ValArray< T >::m_numCols, ns3::ValArray< T >::m_numPages, and ns3::ValArray< T >::m_numRows.

◆ GetNumCols()

template<class T >
size_t ns3::ValArray< T >::GetNumCols
inline
Returns
Number of columns

Definition at line 386 of file val-array.h.

Referenced by ns3::ValArray< T >::ValArray(), ns3::tests::MatrixArrayTestCase< T >::DoRun(), and ns3::tests::ValArrayTestCase< T >::DoRun().

+ Here is the caller graph for this function:

◆ GetNumPages()

template<class T >
size_t ns3::ValArray< T >::GetNumPages
inline
Returns
Number of pages, i.e., the number of 2D arrays

Definition at line 393 of file val-array.h.

Referenced by ns3::ValArray< T >::ValArray(), ns3::tests::MatrixArrayTestCase< T >::DoRun(), and ns3::tests::ValArrayTestCase< T >::DoRun().

+ Here is the caller graph for this function:

◆ GetNumRows()

template<class T >
size_t ns3::ValArray< T >::GetNumRows
inline
Returns
Number of rows

Definition at line 379 of file val-array.h.

Referenced by ns3::ValArray< T >::ValArray(), ns3::tests::MatrixArrayTestCase< T >::DoRun(), and ns3::tests::ValArrayTestCase< T >::DoRun().

+ Here is the caller graph for this function:

◆ GetPagePtr() [1/2]

template<class T >
T * ns3::ValArray< T >::GetPagePtr ( size_t  pageIndex)
inline

Get a data pointer to a specific 2D array for use in linear algebra libraries.

Parameters
pageIndexThe index of the desired 2D array
Returns
a pointer to the data elements of the 2D array

Definition at line 522 of file val-array.h.

References NS_ASSERT_MSG.

Referenced by ns3::MatrixArray< T >::MultiplyByLeftAndRightMatrix(), and ns3::MatrixArray< T >::operator*().

+ Here is the caller graph for this function:

◆ GetPagePtr() [2/2]

template<class T >
const T * ns3::ValArray< T >::GetPagePtr ( size_t  pageIndex) const
inline

Get a data pointer to a specific 2D array for use in linear algebra libraries.

Parameters
pageIndexAn index of the desired 2D array
Returns
a pointer to the data elements of the 2D array

Definition at line 530 of file val-array.h.

References NS_ASSERT_MSG.

◆ GetSize()

◆ GetValues()

template<class T >
const std::valarray< T > & ns3::ValArray< T >::GetValues
inline

Returns underlying values.

This function allows to directly work with the underlying values, which can be faster then using access operators.

Returns
A const reference to the underlying std::valarray<T>.

Definition at line 560 of file val-array.h.

Referenced by ns3::tests::MatrixArrayTestCase< T >::DoRun().

+ Here is the caller graph for this function:

◆ IsAlmostEqual()

template<class T >
bool ns3::ValArray< T >::IsAlmostEqual ( const ValArray< T > &  rhs,
tol 
) const

Compare Valarray up to a given absolute tolerance.

This operation is element-wise operation, i.e., the elements with the same indices from the lhs and rhs ValArray are being compared, allowing the tolerance defined byt "tol" parameter.

Parameters
rhsThe rhs ValArray
tolThe absolute tolerance
Returns
true if the differences in each element-wise comparison is less or equal to tol.

Definition at line 684 of file val-array.h.

References ns3::ValArray< T >::m_values.

Referenced by ns3::tests::ValArrayTestCase< T >::DoRun().

+ Here is the caller graph for this function:

◆ operator!=()

template<class T >
bool ns3::ValArray< T >::operator!= ( const ValArray< T > &  rhs) const

operator!= definition for ValArray<T>.

Parameters
rhsThe ValArray instance to be compared with lhs ValArray instance
Returns
true if rhs ValArray is not equal to this ValArray, otherwise it returns true

Definition at line 677 of file val-array.h.

◆ operator()() [1/6]

template<class T >
T & ns3::ValArray< T >::operator() ( size_t  index)
inline

Single-element access operator() for 1D ValArrays.

Assuming that the number of columns and pages is equal to 1, e.g. ValArray contains a single column or a single row.

Note: intentionally not implemented through three parameters access operator, to avoid accidental mistakes by user, e.g., providing 1 parameters when 2 or 3 are necessary.

Parameters
indexThe index of the 1D ValArray.
Returns
A reference to the value with the specified index.

Definition at line 445 of file val-array.h.

References NS_ASSERT_MSG.

◆ operator()() [2/6]

template<class T >
const T & ns3::ValArray< T >::operator() ( size_t  index) const
inline

Single-element access operator() for 1D ValArrays.

Parameters
indexThe index of the 1D ValArray.
Returns
The const reference to the values with the specified index.

Definition at line 458 of file val-array.h.

References NS_ASSERT_MSG.

◆ operator()() [3/6]

template<class T >
T & ns3::ValArray< T >::operator() ( size_t  rowIndex,
size_t  colIndex 
)
inline

Access operator for 2D ValArrays.

Assuming that the third dimension is equal to 1, e.g. ValArray contains a single 2D array. Note: intentionally not implemented through three parameters access operator, to avoid accidental mistakes by user, e.g., providing 2 parameters when 3 are necessary, but access operator would return valid value if default value of pages provided is 0.

Parameters
rowIndexThe index of the row
colIndexThe index of the column
Returns
A reference to the element with the specified indices

Definition at line 429 of file val-array.h.

References NS_ASSERT_MSG.

◆ operator()() [4/6]

template<class T >
const T & ns3::ValArray< T >::operator() ( size_t  rowIndex,
size_t  colIndex 
) const
inline

Const access operator for 2D ValArrays.

Assuming that the third dimension is equal to 1, e.g. ValArray contains a single 2D array.

Parameters
rowIndexrow index
colIndexcolumn index
Returns
a Const reference to the value with the specified row and column index.

Definition at line 437 of file val-array.h.

References NS_ASSERT_MSG.

◆ operator()() [5/6]

template<class T >
T & ns3::ValArray< T >::operator() ( size_t  rowIndex,
size_t  colIndex,
size_t  pageIndex 
)
inline

Access operator, with bound-checking in debug profile.

Parameters
rowIndexThe index of the row
colIndexThe index of the column
pageIndexThe index of the page
Returns
A const reference to the element with with rowIndex, colIndex and pageIndex indices.

Definition at line 407 of file val-array.h.

References NS_ASSERT_MSG.

◆ operator()() [6/6]

template<class T >
const T & ns3::ValArray< T >::operator() ( size_t  rowIndex,
size_t  colIndex,
size_t  pageIndex 
) const
inline

Const access operator, with bound-checking in debug profile.

Parameters
rowIndexThe index of the row
colIndexThe index of the column
pageIndexThe index of the page
Returns
A const reference to the element with with rowIndex, colIndex and pageIndex indices.

Definition at line 418 of file val-array.h.

References NS_ASSERT_MSG.

◆ operator*()

template<class T >
ValArray< T > ns3::ValArray< T >::operator* ( const T &  rhs) const
inline

Element-wise multiplication with a scalar value.

Parameters
rhsA scalar value of type T
Returns
ValArray in which each element has been multiplied by the given scalar value.

Definition at line 471 of file val-array.h.

◆ operator+()

template<class T >
ValArray< T > ns3::ValArray< T >::operator+ ( const ValArray< T > &  rhs) const
inline

operator+ definition for ValArray<T>.

Parameters
rhsThe rhs ValArray to be added to this ValArray.
Returns
the ValArray instance that holds the results of the operator+

Definition at line 481 of file val-array.h.

References ns3::ValArray< T >::m_values.

◆ operator+=()

template<class T >
ValArray< T > & ns3::ValArray< T >::operator+= ( const ValArray< T > &  rhs)
inline

operator+= definition for ValArray<T>.

Parameters
rhsThe rhs ValArray to be added to this ValArray.
Returns
a reference to this ValArray instance

Definition at line 504 of file val-array.h.

References ns3::ValArray< T >::m_values.

◆ operator-() [1/2]

template<class T >
ValArray< T > ns3::ValArray< T >::operator-
inline

unary operator- definition for ValArray<T>.

Returns
the ValArray instance that holds the results of the operator-

Definition at line 497 of file val-array.h.

◆ operator-() [2/2]

template<class T >
ValArray< T > ns3::ValArray< T >::operator- ( const ValArray< T > &  rhs) const
inline

binary operator- definition for ValArray<T>.

Parameters
rhsThe rhs ValArray to be subtracted from this ValArray.
Returns
the ValArray instance that holds the results of the operator-

Definition at line 489 of file val-array.h.

References ns3::ValArray< T >::m_values.

◆ operator-=()

template<class T >
ValArray< T > & ns3::ValArray< T >::operator-= ( const ValArray< T > &  rhs)
inline

operator-= definition for ValArray<T>.

Parameters
rhsThe rhs ValArray to be subtracted from this ValArray.
Returns
a reference to this ValArray instance

Definition at line 513 of file val-array.h.

References ns3::ValArray< T >::m_values.

◆ operator=() [1/2]

template<class T >
ValArray< T > & ns3::ValArray< T >::operator= ( const ValArray< T > &  )
default

Copy assignment operator.

Instruct the compiler to generate the implicitly declared copy assignment operator.

Returns
a reference to the assigned object

◆ operator=() [2/2]

template<class T >
ValArray< T > & ns3::ValArray< T >::operator= ( ValArray< T > &&  )
default

Move assignment operator.

Instruct the compiler to generate the implicitly declared move assignment operator.

Returns
a reference to the assigned object

◆ operator==()

template<class T >
bool ns3::ValArray< T >::operator== ( const ValArray< T > &  rhs) const

operator== definition for ValArray<T>.

Parameters
rhsThe ValArray instance to be compared with lhs ValArray instance
Returns
true if rhs ValArray is equal to this ValArray, otherwise it returns false

Definition at line 669 of file val-array.h.

References ns3::ValArray< T >::m_values.

◆ operator[]() [1/2]

template<class T >
T & ns3::ValArray< T >::operator[] ( size_t  index)
inline

Single-element access operator[] that can be used to access a specific element of 1D ValArray.

It mimics operator[] from std::vector. This function is introduced for compatibility with ns-3 usage of 1D arrays, which are usually represented through std::vector operators in spectrum and antenna module.

Parameters
indexThe index of the element to be returned
Returns
A reference to a specific element from the underlying std::valarray.

Definition at line 546 of file val-array.h.

◆ operator[]() [2/2]

template<class T >
const T & ns3::ValArray< T >::operator[] ( size_t  index) const
inline

Const access operator that can be used to access a specific element of 1D ValArray.

Parameters
indexThe index of the element to be returned
Returns
A const reference to a specific element from the underlying std::valarray.

Definition at line 553 of file val-array.h.

Member Data Documentation

◆ m_numCols

template<class T >
size_t ns3::ValArray< T >::m_numCols
protected
Initial value:
=
0

The size of the second dimension, i.e., the number of columns of each 2D array.

Definition at line 367 of file val-array.h.

Referenced by ns3::ValArray< T >::ValArray(), ns3::ValArray< T >::AssertEqualDims(), ns3::ValArray< T >::EqualDims(), ns3::MatrixArray< T >::MultiplyByLeftAndRightMatrix(), and ns3::MatrixArray< T >::operator*().

◆ m_numPages

template<class T >
size_t ns3::ValArray< T >::m_numPages = 0
protected

◆ m_numRows

template<class T >
size_t ns3::ValArray< T >::m_numRows
protected
Initial value:
=
0

The size of the first dimension, i.e., the number of rows of each 2D array.

Definition at line 365 of file val-array.h.

Referenced by ns3::ValArray< T >::ValArray(), ns3::ValArray< T >::AssertEqualDims(), ns3::ValArray< T >::EqualDims(), ns3::MatrixArray< T >::MultiplyByLeftAndRightMatrix(), and ns3::MatrixArray< T >::operator*().

◆ m_values


The documentation for this class was generated from the following file: