ASL
Array2< T > Class Template Reference

Detailed Description

template<class T>
class asl::Array2< T >

A simple 2-dimensional dynamic array or matrix.

Array2<int> a(3, 3);
Array2<float> b = {
{ 1, 2, 3 },
{ 3, -1.5f, 0 }
};
b(1, 1) = 7.25f;

For mathematical matrices use class Matrix_ which support arithmetic operations and other functions.

#include <Array2.h>

Inheritance diagram for Array2< T >:
Matrix_< T >

Public Member Functions

 Array2 ()
 Creates an empty array.
 
 Array2 (int rows, int cols)
 Creates an array with size rows x cols.
 
 Array2 (int rows, int cols, const T &value)
 Creates an array with size rows x cols and initializes all items with value.
 
 Array2 (int rows, int cols, const T *p)
 Creates an array of rows x cols elements and copies them from the pointer p (row-wise)
 
 Array2 (int rows, int cols, std::initializer_list< T > a)
 Creates an array with size rows x cols and the given elements.
 
 Array2 (std::initializer_list< std::initializer_list< T > > a)
 Creates an array with given list of lists of elements.
 
template<class K >
Array2< K > with () const
 Creates a copy of this array with items converted to type K.
 
Array< T > & data ()
 Returns the internal array holding all values (row-major) More...
 
const Array< T > & data () const
 Returns the internal array holding all values (row-major) More...
 
Array< T > & array ()
 Returns the internal array holding all values (row-major)
 
const Array< T > & array () const
 Returns the internal array holding all values (row-major)
 
bool operator== (const Array2 &b) const
 Returns true if both arrays are equal.
 
bool operator!= (const Array2 &b) const
 Returns true if both arrays are not equal.
 
Array2 clone () const
 Returns an independent copy of this array.
 
Array2 slice (int i1, int i2, int j1, int j2) const
 Returns a sub-array consisting of a rows [i1, i2) and columns [j1, j2)
 
Array2resize (int r, int c)
 Resizes the matrix to r x c.
 
int rows () const
 Returns the number of rows.
 
int cols () const
 Returns the number of columns.
 
T & operator() (int i, int j)
 Returns the item at row i, column j.
 
void set (const T &x)
 Sets all array items to value x.
 

Member Function Documentation

◆ data() [1/2]

Array<T>& data ( )

Returns the internal array holding all values (row-major)

Deprecated:
This will return a pointer to the beginning (for consistency)

◆ data() [2/2]

const Array<T>& data ( ) const

Returns the internal array holding all values (row-major)

Deprecated:
This will return a pointer to the beginning (for consistency)

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