cml::fixed_2D< Element, Rows, Cols, Layout > Class Template Reference

The internal statically-allocated 2D-array implementation class. More...

#include <fixed_2D.h>

Inheritance diagram for cml::fixed_2D< Element, Rows, Cols, Layout >:

Inheritance graph
[legend]
Collaboration diagram for cml::fixed_2D< Element, Rows, Cols, Layout >:

Collaboration graph
[legend]

List of all members.

Public Types

enum  { array_rows = Rows, array_cols = Cols }
typedef fixed_1D< Element, Cols > col_array_type
typedef const Element * const_pointer
typedef const Element & const_reference
typedef twod_tag dimension_tag
typedef fixed< Rows, Cols > generator_type
typedef Layout layout
typedef fixed_memory_tag memory_tag
typedef Element * pointer
typedef Element & reference
typedef not_resizable_tag resizing_tag
typedef fixed_1D< Element, Rows > row_array_type
typedef fixed_size_tag size_tag
typedef fixed_2D< Element,
Cols, Rows, Layout > 
transposed_type
typedef Element value_type

Public Member Functions

 CML_STATIC_REQUIRE_M ((same_type< Layout, row_major >::is_true||same_type< Layout, col_major >::is_true), invalid_layout_type_error)
 CML_STATIC_REQUIRE_M ((Rows > 0)&&(Cols > 0), negative_array_size_error)
size_t cols () const
 Return the number of cols in the array.
const_pointer data () const
 Return access to the data as a raw pointer.
pointer data ()
 Return access to the data as a raw pointer.
 fixed_2D ()
const_reference operator() (size_t row, size_t col) const
 Const access element (row,col) of the matrix.
reference operator() (size_t row, size_t col)
 Access element (row,col) of the matrix.
size_t rows () const
 Return the number of rows in the array.

Protected Types

typedef select_switch< Layout,
row_major, row_major_array,
col_major, col_major_array >
::result 
array_data
typedef Element col_major_array [Cols][Rows]
typedef Element row_major_array [Rows][Cols]

Protected Member Functions

const_reference get_element (size_t row, size_t col, col_major) const
reference get_element (size_t row, size_t col, col_major)
const_reference get_element (size_t row, size_t col, row_major) const
reference get_element (size_t row, size_t col, row_major)

Protected Attributes

array_data m_data


Detailed Description

template<typename Element, int Rows, int Cols, typename Layout>
class cml::fixed_2D< Element, Rows, Cols, Layout >

The internal statically-allocated 2D-array implementation class.

This uses an internal class to setup the data matrix with the proper layout. The alternative is to use a 1D array with size Rows*Cols and a multiplication to dereference an element, but it seems that compilers better optimize 2D array dereferences. This is different from dynamic_2D<>, which must use the 1D array method.

See also:
cml::fixed
Note:
This class is designed to have the same size as a C array with the same dimensions. It's therefore possible (but not recommended!) to coerce a normal C array into a fixed_2D<> like this:
typedef fixed_2D<double,10,10,row_major> array; double c_array[10][10]; array& array_object = *((array*)&c_array); double e11 = array_object[1][1];

It's also possible to do this with a pointer to an array of values (e.g. a double*), whether or not it was actually declared as a fixed C array. This is HIGHLY DISCOURAGED, though, since it's relatively straightforward to implement a separate class to take a C array (or pointer) and turn it into an array object.

Definition at line 61 of file fixed_2D.h.


Member Typedef Documentation

template<typename Element, int Rows, int Cols, typename Layout>
typedef select_switch< Layout, row_major, row_major_array, col_major, col_major_array >::result cml::fixed_2D< Element, Rows, Cols, Layout >::array_data [protected]

Definition at line 193 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
typedef fixed_1D<Element,Cols> cml::fixed_2D< Element, Rows, Cols, Layout >::col_array_type

Definition at line 107 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
typedef Element cml::fixed_2D< Element, Rows, Cols, Layout >::col_major_array[Cols][Rows] [protected]

Definition at line 187 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
typedef const Element* cml::fixed_2D< Element, Rows, Cols, Layout >::const_pointer

Definition at line 85 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
typedef const Element& cml::fixed_2D< Element, Rows, Cols, Layout >::const_reference

template<typename Element, int Rows, int Cols, typename Layout>
typedef twod_tag cml::fixed_2D< Element, Rows, Cols, Layout >::dimension_tag

Definition at line 100 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
typedef fixed<Rows,Cols> cml::fixed_2D< Element, Rows, Cols, Layout >::generator_type

template<typename Element, int Rows, int Cols, typename Layout>
typedef Layout cml::fixed_2D< Element, Rows, Cols, Layout >::layout

template<typename Element, int Rows, int Cols, typename Layout>
typedef fixed_memory_tag cml::fixed_2D< Element, Rows, Cols, Layout >::memory_tag

template<typename Element, int Rows, int Cols, typename Layout>
typedef Element* cml::fixed_2D< Element, Rows, Cols, Layout >::pointer

Definition at line 82 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
typedef Element& cml::fixed_2D< Element, Rows, Cols, Layout >::reference

template<typename Element, int Rows, int Cols, typename Layout>
typedef not_resizable_tag cml::fixed_2D< Element, Rows, Cols, Layout >::resizing_tag

Definition at line 97 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
typedef fixed_1D<Element,Rows> cml::fixed_2D< Element, Rows, Cols, Layout >::row_array_type

Definition at line 106 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
typedef Element cml::fixed_2D< Element, Rows, Cols, Layout >::row_major_array[Rows][Cols] [protected]

Definition at line 186 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
typedef fixed_size_tag cml::fixed_2D< Element, Rows, Cols, Layout >::size_tag

template<typename Element, int Rows, int Cols, typename Layout>
typedef fixed_2D<Element,Cols,Rows,Layout> cml::fixed_2D< Element, Rows, Cols, Layout >::transposed_type

template<typename Element, int Rows, int Cols, typename Layout>
typedef Element cml::fixed_2D< Element, Rows, Cols, Layout >::value_type


Member Enumeration Documentation

template<typename Element, int Rows, int Cols, typename Layout>
anonymous enum

Enumerator:
array_rows 
array_cols 

Definition at line 112 of file fixed_2D.h.


Constructor & Destructor Documentation

template<typename Element, int Rows, int Cols, typename Layout>
cml::fixed_2D< Element, Rows, Cols, Layout >::fixed_2D (  )  [inline]

Definition at line 161 of file fixed_2D.h.


Member Function Documentation

template<typename Element, int Rows, int Cols, typename Layout>
cml::fixed_2D< Element, Rows, Cols, Layout >::CML_STATIC_REQUIRE_M ( (same_type< Layout, row_major >::is_true||same_type< Layout, col_major >::is_true ,
invalid_layout_type_error   
)

template<typename Element, int Rows, int Cols, typename Layout>
cml::fixed_2D< Element, Rows, Cols, Layout >::CML_STATIC_REQUIRE_M ( (Rows > 0)&&(Cols > 0)  ,
negative_array_size_error   
)

template<typename Element, int Rows, int Cols, typename Layout>
size_t cml::fixed_2D< Element, Rows, Cols, Layout >::cols (  )  const [inline]

Return the number of cols in the array.

Definition at line 121 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
const_pointer cml::fixed_2D< Element, Rows, Cols, Layout >::data (  )  const [inline]

Return access to the data as a raw pointer.

Definition at line 156 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
pointer cml::fixed_2D< Element, Rows, Cols, Layout >::data (  )  [inline]

Return access to the data as a raw pointer.

Definition at line 153 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
const_reference cml::fixed_2D< Element, Rows, Cols, Layout >::get_element ( size_t  row,
size_t  col,
col_major   
) const [inline, protected]

Definition at line 178 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
reference cml::fixed_2D< Element, Rows, Cols, Layout >::get_element ( size_t  row,
size_t  col,
col_major   
) [inline, protected]

Definition at line 174 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
const_reference cml::fixed_2D< Element, Rows, Cols, Layout >::get_element ( size_t  row,
size_t  col,
row_major   
) const [inline, protected]

Definition at line 170 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
reference cml::fixed_2D< Element, Rows, Cols, Layout >::get_element ( size_t  row,
size_t  col,
row_major   
) [inline, protected]

Definition at line 166 of file fixed_2D.h.

Referenced by cml::fixed_2D< Element, Rows, Cols, Layout >::operator()().

Here is the caller graph for this function:

template<typename Element, int Rows, int Cols, typename Layout>
const_reference cml::fixed_2D< Element, Rows, Cols, Layout >::operator() ( size_t  row,
size_t  col 
) const [inline]

Const access element (row,col) of the matrix.

Parameters:
row row of element.
col column of element.
Returns:
const reference.
Note:
This function does not range-check the arguments.

Definition at line 147 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
reference cml::fixed_2D< Element, Rows, Cols, Layout >::operator() ( size_t  row,
size_t  col 
) [inline]

Access element (row,col) of the matrix.

Parameters:
row row of element.
col column of element.
Returns:
mutable reference.
Note:
This function does not range-check the arguments.

Definition at line 134 of file fixed_2D.h.

template<typename Element, int Rows, int Cols, typename Layout>
size_t cml::fixed_2D< Element, Rows, Cols, Layout >::rows (  )  const [inline]

Return the number of rows in the array.

Definition at line 118 of file fixed_2D.h.


Member Data Documentation

template<typename Element, int Rows, int Cols, typename Layout>
array_data cml::fixed_2D< Element, Rows, Cols, Layout >::m_data [protected]


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

Generated on Sat Jul 18 19:35:38 2009 for CML 1.0 by  doxygen 1.5.9