nec2++  1.7.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
safe_array< T > Class Template Reference

A Safe Array class for nec2++ that performs bounds checking. More...

#include <safe_array.h>

Inheritance diagram for safe_array< T >:
safe_matrix< T >

Public Member Functions

 safe_array (int64_t in_size)
 
 safe_array (const safe_array< T > &in_array)
 
int64_t size () const
 
int32_t rows () const
 
int32_t cols () const
 
int64_t capacity () const
 
void resize (int32_t n_rows, int32_t n_cols)
 
void copy (const safe_array< T > &in_array)
 
void resize (int64_t new_length)
 
maxCoeff () const
 return the largest element of the array
 
minCoeff () const
 return the largest element of the array
 
sum (int64_t start_index, int64_t stop_index)
 return the sum of the specified elements in the array
 
sum ()
 return the sum of all elements in the array
 
void fill (int64_t start, int64_t N, const T &x)
 
void setConstant (const T &x)
 
void set_col_major (int32_t col_dim, int32_t col, int32_t row, const T &val)
 Set an element assuming that the data is stored in column major form.
 
T & get_col_major (int32_t col_dim, int32_t col, int32_t row)
 Get an element assuming that the data is stored in column major form.
 
T & getItem (int32_t row, int32_t col)
 
T & operator() (int32_t row, int32_t col)
 
const T & operator() (int32_t row, int32_t col) const
 
T & getItem (int64_t i)
 
const T & operator[] (int64_t i) const
 
T & operator[] (int64_t i)
 
safe_array< T > segment (int64_t start_index, int64_t end_index)
 Return a representation of a subset of this array. More...
 
safe_array< T > eigen_segment (int64_t start_index, int64_t n)
 Return a representation of a subset of this array. More...
 
T * data () const
 
safe_array< T > & operator= (const safe_array< T > &in_array)
 

Protected Member Functions

 safe_array (const safe_array< T > &in_array, int64_t start_index, int64_t end_index, bool in_copy_data)
 Constructor only used to construct segment. More...
 
int64_t check (int64_t i) const
 
int64_t check (int32_t row, int32_t col) const
 

Protected Attributes

int64_t len_
 
int32_t rows_
 
int32_t cols_
 
int64_t resize_chunk_
 
T * data_
 
int64_t data_size_
 
bool own_data_
 

Detailed Description

template<typename T>
class safe_array< T >

A Safe Array class for nec2++ that performs bounds checking.

Bounds checking is done if the macro NEC_ERROR_CHECK is defined at compile time.

This class also includes some utility functions for handling common vector operations.

Constructor & Destructor Documentation

template<typename T>
safe_array< T >::safe_array ( const safe_array< T > &  in_array,
int64_t  start_index,
int64_t  end_index,
bool  in_copy_data 
)
inlineprotected

Constructor only used to construct segment.

Parameters
start_indexThe first element of in_array to copy.
end_indexThe last element of in_array to copy.
in_copy_dataTrue if we create a copy of data from in_array. False - just reference the data in in_array.

Member Function Documentation

template<typename T>
safe_array<T> safe_array< T >::eigen_segment ( int64_t  start_index,
int64_t  n 
)
inline

Return a representation of a subset of this array.

Parameters
start_indexThe index of the first element
nNumber of elements in the segment
template<typename T>
T& safe_array< T >::getItem ( int32_t  row,
int32_t  col 
)
inline
Remarks
This is an accessor function that is useful for wrapping.

Referenced by safe_array< int32_t >::operator()().

template<typename T>
T& safe_array< T >::operator() ( int32_t  row,
int32_t  col 
)
inline
Remarks
We use round brackets for indexing into 2D arrays.
template<typename T>
safe_array<T> safe_array< T >::segment ( int64_t  start_index,
int64_t  end_index 
)
inline

Return a representation of a subset of this array.

Parameters
start_indexThe index of the first element
end_indexIf -1, then finish at the end of the array

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