0.12.0
Freundlich's C++ toolkit
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Static Public Member Functions
fcppt::math::matrix::object< T, N, M, S > Class Template Reference

Detailed Description

template<typename T, typename N, typename M, typename S>
class fcppt::math::matrix::object< T, N, M, S >

A class representing dynamic or static matrices.

Template Parameters
TThe matrix's value_type
NThe matrix's row type (this is not necessarily a number!)
MThe matrix's column type (this is not necessarily a number!)
SThe matrix's storage type

See the module documentation for more information.

Public Types

typedef N n_wrapper
 A typedef for the N parameter.
 
typedef M m_wrapper
 A typedef for the M parameter.
 
typedef boost::mpl::times< N,
M >::type 
dim_wrapper
 A typedef for the M and N parameters.
 
typedef S storage_type
 A typedef for the S parameter.
 
typedef math::size_type size_type
 A type that counts the number of elements in a matrix.
 
typedef math::difference_type difference_type
 A type that provides the difference between the addresses of two elements in a matrix.
 
typedef T value_type
 A type that represents the data type stored in a matrix.
 
typedef vector::object< T, N,
matrix::detail::row_view< T, N > > 
reference
 A type that provides a reference to an element stored in a matrix.
 
typedef
fcppt::math::vector::object< T,
N,
fcppt::math::matrix::detail::row_view
< T const, N > > 
const_reference
 A type that provides a reference to a const element stored in a vector for reading and performing const operations.
 
typedef T * pointer
 A type that provides a pointer to an element in a matrix.
 
typedef T const * const_pointer
 A type that provides a pointer to a const element in a matrix.
 
typedef pointer iterator
 A type that provides a random-access iterator that can read or modify any element in a matrix.
 
typedef const_pointer const_iterator
 A type that provides a random-access iterator that can read or modify any element in a matrix.
 
typedef std::reverse_iterator
< iterator
reverse_iterator
 A type that provides a random-access iterator that can read or modify any element in a reversed matrix.
 
typedef std::reverse_iterator
< const_iterator
const_reverse_iterator
 A type that provides a random-access iterator that can read any const element in the matrix.
 
typedef matrix::dim_type dim
 The dim type corresponding to this matrix type.
 

Public Member Functions

 FCPPT_STATIC_ASSERT_STATEMENT ((boost::is_same< typename N::value_type, typename M::value_type >::value))
 
 object ()
 Construct an uninitialized matrix.
 
 object (dim const &)
 Construct an uninitialized dynamic matrix.
 
 object (storage_type const &s)
 Construct a vector from a storage source.
 
 object (object const &)
 Copy-construct the matrix from another matrix.
 
template<typename OtherStorage >
 object (object< T, N, M, OtherStorage > const &)
 Create a matrix from a matrix with the same dimension and value type but different storage type.
 
template<typename In >
 object (In beg, typename boost::enable_if< type_traits::is_iterator< In >, In >::type end)
 Create a matrix and fill it with the contents of the given range.
 
template<typename In >
 object (dim const &_dim, In beg, typename boost::enable_if< type_traits::is_iterator< In >, In >::type end)
 Create a dynamic matrix and fill it with the contents of the given range.
 
template<typename Container >
 object (dim const &, Container const &)
 Create a dynamic matrix and fill it with the contents of a range.
 
 FCPPT_MATH_DETAIL_ARRAY_ADAPTER (object) FCPPT_MATH_DETAIL_MAKE_VARIADIC_CONSTRUCTOR_DECL(FCPPT_MATH_MATRIX_MAX_CTOR_PARAMS
 
object objectoperator= (object const &)
 Copy the values from a different matrix.
 
template<typename OtherStorage >
objectoperator= (object< T, N, M, OtherStorage > const &)
 Copy the values from a different matrix of the same size but different storage type.
 
 ~object ()
 
objectoperator*= (value_type const &)
 Multiply a matrix by a scalar.
 
objectoperator/= (value_type const &)
 Divide a matrix by a scalar.
 
reference operator[] (size_type)
 Returns a reference to a row in the matrix.
 
const_reference const operator[] (size_type) const
 Returns a reference to a (constant) row in the matrix.
 
size_type rows () const
 Returns the number of rows in the matrix.
 
size_type columns () const
 Returns the number of columns in the matrix.
 
dim const dimension () const
 Returns the matrix's dimensions.
 
void swap (object &)
 Exchanges the elements of two matrices.
 

Static Public Member Functions

static object const identity ()
 Returns the identity matrix;.
 

Member Typedef Documentation

template<typename T, typename N, typename M, typename S>
typedef const_pointer fcppt::math::matrix::object< T, N, M, S >::const_iterator

A type that provides a random-access iterator that can read or modify any element in a matrix.

Warning
An "element" in this case is not a row, but a single cell. See the iteration section above.
template<typename T, typename N, typename M, typename S>
typedef T const* fcppt::math::matrix::object< T, N, M, S >::const_pointer

A type that provides a pointer to a const element in a matrix.

template<typename T, typename N, typename M, typename S>
typedef fcppt::math::vector::object< T, N, fcppt::math::matrix::detail::row_view< T const, N > > fcppt::math::matrix::object< T, N, M, S >::const_reference

A type that provides a reference to a const element stored in a vector for reading and performing const operations.

This is one of the few non-trivial implementations of the reference typedef, as it's really a vector that models a row-view over the matrix, see the explanation above.

template<typename T, typename N, typename M, typename S>
typedef std::reverse_iterator<const_iterator> fcppt::math::matrix::object< T, N, M, S >::const_reverse_iterator

A type that provides a random-access iterator that can read any const element in the matrix.

template<typename T, typename N, typename M, typename S>
typedef math::difference_type fcppt::math::matrix::object< T, N, M, S >::difference_type

A type that provides the difference between the addresses of two elements in a matrix.

template<typename T, typename N, typename M, typename S>
typedef matrix::dim_type fcppt::math::matrix::object< T, N, M, S >::dim

The dim type corresponding to this matrix type.

template<typename T, typename N, typename M, typename S>
typedef boost::mpl::times< N, M >::type fcppt::math::matrix::object< T, N, M, S >::dim_wrapper

A typedef for the M and N parameters.

template<typename T, typename N, typename M, typename S>
typedef pointer fcppt::math::matrix::object< T, N, M, S >::iterator

A type that provides a random-access iterator that can read or modify any element in a matrix.

Warning
An "element" in this case is not a row, but a single cell. See the iteration section above.
template<typename T, typename N, typename M, typename S>
typedef M fcppt::math::matrix::object< T, N, M, S >::m_wrapper

A typedef for the M parameter.

template<typename T, typename N, typename M, typename S>
typedef N fcppt::math::matrix::object< T, N, M, S >::n_wrapper

A typedef for the N parameter.

template<typename T, typename N, typename M, typename S>
typedef T* fcppt::math::matrix::object< T, N, M, S >::pointer

A type that provides a pointer to an element in a matrix.

template<typename T, typename N, typename M, typename S>
typedef vector::object< T, N, matrix::detail::row_view< T, N > > fcppt::math::matrix::object< T, N, M, S >::reference

A type that provides a reference to an element stored in a matrix.

This is one of the few non-trivial implementations of the reference typedef, as it's really a vector that models a row-view over the matrix, see the explanation above.

template<typename T, typename N, typename M, typename S>
typedef std::reverse_iterator<iterator> fcppt::math::matrix::object< T, N, M, S >::reverse_iterator

A type that provides a random-access iterator that can read or modify any element in a reversed matrix.

template<typename T, typename N, typename M, typename S>
typedef math::size_type fcppt::math::matrix::object< T, N, M, S >::size_type

A type that counts the number of elements in a matrix.

template<typename T, typename N, typename M, typename S>
typedef S fcppt::math::matrix::object< T, N, M, S >::storage_type

A typedef for the S parameter.

template<typename T, typename N, typename M, typename S>
typedef T fcppt::math::matrix::object< T, N, M, S >::value_type

A type that represents the data type stored in a matrix.

Constructor & Destructor Documentation

template<typename T , typename N , typename M , typename S >
FCPPT_PP_PUSH_WARNING object< T, N, M, S >::object ( )

Construct an uninitialized matrix.

Warning
The content of the vector will be undefined (not null) after initialization
template<typename T , typename N , typename M , typename S >
object< T, N, M, S >::object ( dim const &  _dim)
explicit

Construct an uninitialized dynamic matrix.

Warning
This operation makes no sense on a static matrix.
template<typename T , typename N , typename M , typename S >
FCPPT_PP_POP_WARNING object< T, N, M, S >::object ( storage_type const &  s)
explicit

Construct a vector from a storage source.

Parameters
sThe storage source to copy from
template<typename T , typename N , typename M , typename S >
object< T, N, M, S >::object ( object< T, N, M, S > const &  _other)

Copy-construct the matrix from another matrix.

template<typename T, typename N, typename M, typename S >
template<typename OtherStorage >
FCPPT_PP_PUSH_WARNING object< T, N, M, S >::object ( object< T, N, M, OtherStorage > const &  _other)

Create a matrix from a matrix with the same dimension and value type but different storage type.

Template Parameters
OtherStorageThe other matrix's storage type
template<typename T, typename N, typename M, typename S >
template<typename In >
object< T, N, M, S >::object ( In  beg,
typename boost::enable_if< type_traits::is_iterator< In >, In >::type  end 
)

Create a matrix and fill it with the contents of the given range.

Template Parameters
InA forward iterator pointing to elements of type T
Parameters
begThe beginning of the range
endOne past the end of the range
template<typename T, typename N, typename M, typename S >
template<typename In >
object< T, N, M, S >::object ( dim const &  _dim,
In  beg,
typename boost::enable_if< type_traits::is_iterator< In >, In >::type  end 
)

Create a dynamic matrix and fill it with the contents of the given range.

Template Parameters
InA forward iterator pointing to elements of type T
Parameters
_dimThe two-dimensional dimension corresponding to the one-dimensional range
begThe beginning of the range
endOne past the end of the range
Warning
This operation makes no sense on a static matrix.
template<typename T, typename N, typename M, typename S >
template<typename Container >
object< T, N, M, S >::object ( dim const &  _dim,
Container const &  _container 
)

Create a dynamic matrix and fill it with the contents of a range.

Template Parameters
ContainerA sequence container containing elements of type T
Warning
This operation makes no sense on a static matrix.
template<typename T , typename N , typename M , typename S >
object< T, N, M, S >::~object ( )

Member Function Documentation

template<typename T , typename N , typename M , typename S >
fcppt::math::matrix::object< T, N, M, S >::size_type object< T, N, M, S >::columns ( ) const

Returns the number of columns in the matrix.

template<typename T , typename N , typename M , typename S >
fcppt::math::matrix::object< T, N, M, S >::dim const object< T, N, M, S >::dimension ( ) const

Returns the matrix's dimensions.

template<typename T, typename N, typename M, typename S>
fcppt::math::matrix::object< T, N, M, S >::FCPPT_MATH_DETAIL_ARRAY_ADAPTER ( object< T, N, M, S >  )
template<typename T, typename N, typename M, typename S>
fcppt::math::matrix::object< T, N, M, S >::FCPPT_STATIC_ASSERT_STATEMENT ( (boost::is_same< typename N::value_type, typename M::value_type >::value)  )
template<typename T , typename N , typename M , typename S >
fcppt::math::matrix::object< T, N, M, S > const object< T, N, M, S >::identity ( )
static

Returns the identity matrix;.

template<typename T , typename N , typename M , typename S >
fcppt::math::matrix::object< T, N, M, S > & object< T, N, M, S >::operator*= ( value_type const &  _value)

Multiply a matrix by a scalar.

template<typename T , typename N , typename M , typename S >
fcppt::math::matrix::object< T, N, M, S > & object< T, N, M, S >::operator/= ( value_type const &  _value)

Divide a matrix by a scalar.

template<typename T, typename N, typename M, typename S>
FCPPT_PP_POP_WARNING fcppt::math::matrix::object< T, N, M, S >::object FCPPT_PP_POP_WARNING fcppt::math::matrix::object< T, N, M, S > & object< T, N, M, S >::operator= ( object< T, N, M, S > const &  _other)

Copy the values from a different matrix.

template<typename T, typename N, typename M, typename S >
template<typename OtherStorage >
fcppt::math::matrix::object< T, N, M, S > & object< T, N, M, S >::operator= ( object< T, N, M, OtherStorage > const &  _other)

Copy the values from a different matrix of the same size but different storage type.

Template Parameters
OtherStorageThe other matrix's storage type
template<typename T , typename N , typename M , typename S >
fcppt::math::matrix::object< T, N, M, S >::reference object< T, N, M, S >::operator[] ( size_type  _j)

Returns a reference to a row in the matrix.

Warning
Behaviour is undefined if the index is out of range.
template<typename T , typename N , typename M , typename S >
fcppt::math::matrix::object< T, N, M, S >::const_reference const object< T, N, M, S >::operator[] ( size_type  _j) const

Returns a reference to a (constant) row in the matrix.

Warning
Behaviour is undefined if the index is out of range.
template<typename T , typename N , typename M , typename S >
fcppt::math::matrix::object< T, N, M, S >::size_type object< T, N, M, S >::rows ( ) const

Returns the number of rows in the matrix.

template<typename T , typename N , typename M , typename S >
void object< T, N, M, S >::swap ( object< T, N, M, S > &  _other)

Exchanges the elements of two matrices.