SourceForge Logo Tiny Vector Matrix library using Expression Templates Sourceforge Project Page

Functions
Global Unary Functions
Global Functions
Collaboration diagram for Global Unary Functions:

Functions

template<class E , std::size_t Rows, std::size_t Cols>
bool tvmet::all_elements (const XprMatrix< E, Rows, Cols > &e)
 check on statements for all elementsThis is for use with boolean operators like
template<class E , std::size_t Rows, std::size_t Cols>
bool tvmet::any_elements (const XprMatrix< E, Rows, Cols > &e)
 check on statements for any elementsThis is for use with boolean operators like
template<class T , std::size_t Rows, std::size_t Cols>
XprMatrix< XprMatrixTranspose
< MatrixConstReference< T,
Rows, Cols > >, Cols, Rows > 
tvmet::trans (const Matrix< T, Rows, Cols > &rhs) TVMET_CXX_ALWAYS_INLINE
 Transpose the matrix.
template<class T , std::size_t Sz>
XprVector< XprMatrixDiag
< MatrixConstReference< T, Sz,
Sz >, Sz >, Sz > 
tvmet::diag (const Matrix< T, Sz, Sz > &m) TVMET_CXX_ALWAYS_INLINE
 Returns the diagonal vector of the given square matrix.
template<class E , std::size_t Rows, std::size_t Cols>
Extremum< typename
E::value_type, std::size_t,
matrix_tag > 
tvmet::maximum (const XprMatrix< E, Rows, Cols > &e)
 Find the maximum of a matrix expression.
template<class T , std::size_t Rows, std::size_t Cols>
Extremum< T, std::size_t,
matrix_tag > 
tvmet::maximum (const Matrix< T, Rows, Cols > &m) TVMET_CXX_ALWAYS_INLINE
 Find the maximum of a matrix.
template<class E , std::size_t Rows, std::size_t Cols>
Extremum< typename
E::value_type, std::size_t,
matrix_tag > 
tvmet::minimum (const XprMatrix< E, Rows, Cols > &e)
 Find the minimum of a matrix expression.
template<class T , std::size_t Rows, std::size_t Cols>
Extremum< T, std::size_t,
matrix_tag > 
tvmet::minimum (const Matrix< T, Rows, Cols > &m) TVMET_CXX_ALWAYS_INLINE
 Find the minimum of a matrix.
template<class E , std::size_t Rows, std::size_t Cols>
E::value_type tvmet::max (const XprMatrix< E, Rows, Cols > &e)
 Find the maximum of a matrix expression.
template<class T , std::size_t Rows, std::size_t Cols>
tvmet::max (const Matrix< T, Rows, Cols > &m) TVMET_CXX_ALWAYS_INLINE
 Find the maximum of a matrix.
template<class E , std::size_t Rows, std::size_t Cols>
E::value_type tvmet::min (const XprMatrix< E, Rows, Cols > &e)
 Find the minimum of a matrix expression.
template<class T , std::size_t Rows, std::size_t Cols>
tvmet::min (const Matrix< T, Rows, Cols > &m) TVMET_CXX_ALWAYS_INLINE
 Find the minimum of a matrix.
template<class T , std::size_t Rows, std::size_t Cols>
XprMatrix< XprIdentity< T,
Rows, Cols >, Rows, Cols > 
tvmet::identity () TVMET_CXX_ALWAYS_INLINE
 Fill a matrix to an identity matrix.
template<class T , std::size_t Rows, std::size_t Cols>
XprMatrix
< MatrixConstReference< T,
Rows, Cols >, Rows, Cols > 
tvmet::cmatrix_ref (const T *mem) TVMET_CXX_ALWAYS_INLINE
 Creates an expression wrapper for a C like matrices.
template<class E , std::size_t Sz>
bool tvmet::all_elements (const XprVector< E, Sz > &e)
 check on statements for all elementsThis is for use with boolean operators like
template<class E , std::size_t Sz>
bool tvmet::any_elements (const XprVector< E, Sz > &e)
 check on statements for any elementsThis is for use with boolean operators like
template<class T , std::size_t Sz>
NumericTraits< T >::sum_type tvmet::sum (const Vector< T, Sz > &v) TVMET_CXX_ALWAYS_INLINE
 Compute the sum of the vector.
template<class T , std::size_t Sz>
NumericTraits< T >::sum_type tvmet::product (const Vector< T, Sz > &v) TVMET_CXX_ALWAYS_INLINE
 Compute the product of the vector elements.
template<class T , std::size_t Sz>
NumericTraits< T >::sum_type tvmet::norm1 (const Vector< T, Sz > &v) TVMET_CXX_ALWAYS_INLINE
 The $l_1$ norm of a vector v.
template<class T , std::size_t Sz>
NumericTraits< T >::sum_type tvmet::norm2 (const Vector< T, Sz > &v) TVMET_CXX_ALWAYS_INLINE
 The euklidian norm (or $l_2$ norm) of a vector v.
template<class T , std::size_t Sz>
XprVector< XprBinOp< Fcnl_div
< T, T >, VectorConstReference
< T, Sz >, XprLiteral< T >
>, Sz > 
tvmet::normalize (const Vector< T, Sz > &v) TVMET_CXX_ALWAYS_INLINE
 Normalize the given vector.
template<class E , std::size_t Sz>
Extremum< typename
E::value_type, std::size_t,
vector_tag > 
tvmet::maximum (const XprVector< E, Sz > &e)
 Find the maximum of a vector expression.
template<class T , std::size_t Sz>
Extremum< T, std::size_t,
vector_tag > 
tvmet::maximum (const Vector< T, Sz > &v) TVMET_CXX_ALWAYS_INLINE
 Find the maximum of a vector.
template<class E , std::size_t Sz>
Extremum< typename
E::value_type, std::size_t,
vector_tag > 
tvmet::minimum (const XprVector< E, Sz > &e)
 Find the minimum of a vector expression.
template<class T , std::size_t Sz>
Extremum< T, std::size_t,
vector_tag > 
tvmet::minimum (const Vector< T, Sz > &v) TVMET_CXX_ALWAYS_INLINE
 Find the minimum of a vector.
template<class E , std::size_t Sz>
E::value_type tvmet::max (const XprVector< E, Sz > &e)
 Find the maximum of a vector expression.
template<class T , std::size_t Sz>
tvmet::max (const Vector< T, Sz > &v) TVMET_CXX_ALWAYS_INLINE
 Find the maximum of a vector.
template<class E , std::size_t Sz>
E::value_type tvmet::min (const XprVector< E, Sz > &e)
 Find the minimum of a vector expression.
template<class T , std::size_t Sz>
tvmet::min (const Vector< T, Sz > &v) TVMET_CXX_ALWAYS_INLINE
 Find the minimum of a vector.
template<class T , std::size_t Sz>
XprVector
< VectorConstReference< T, Sz >
, Sz > 
tvmet::cvector_ref (const T *mem) TVMET_CXX_ALWAYS_INLINE
 Creates an expression wrapper for a C like vector arrays.
template<class E , std::size_t Rows, std::size_t Cols>
XprMatrix< XprMatrixTranspose
< XprMatrix< E, Rows, Cols >
>, Cols, Rows > 
tvmet::trans (const XprMatrix< E, Rows, Cols > &rhs) TVMET_CXX_ALWAYS_INLINE
 Transpose an expression matrix.
template<class E , std::size_t Sz>
XprVector< XprMatrixDiag
< XprMatrix< E, Sz, Sz >, Sz >
, Sz > 
tvmet::diag (const XprMatrix< E, Sz, Sz > &m) TVMET_CXX_ALWAYS_INLINE
 Returns the diagonal vector of the given square matrix.
template<class E , std::size_t Sz>
NumericTraits< typename
E::value_type >::sum_type 
tvmet::sum (const XprVector< E, Sz > &v) TVMET_CXX_ALWAYS_INLINE
 Compute the sum of the vector expression.
template<class E , std::size_t Sz>
NumericTraits< typename
E::value_type >::sum_type 
tvmet::product (const XprVector< E, Sz > &v) TVMET_CXX_ALWAYS_INLINE
 Compute the product of the vector elements.
template<class E , std::size_t Sz>
NumericTraits< typename
E::value_type >::sum_type 
tvmet::norm1 (const XprVector< E, Sz > &v) TVMET_CXX_ALWAYS_INLINE
 The $l_1$ norm of a vector expression.
template<class E , std::size_t Sz>
NumericTraits< typename
E::value_type >::sum_type 
tvmet::norm2 (const XprVector< E, Sz > &v) TVMET_CXX_ALWAYS_INLINE
 The euklidian norm (or $l_2$ norm) of a vector expression.
template<class E , std::size_t Sz>
XprVector< XprBinOp< Fcnl_div
< typename E::value_type,
typename E::value_type >
, XprVector< E, Sz >
, XprLiteral< typename
E::value_type > >, Sz > 
tvmet::normalize (const XprVector< E, Sz > &v) TVMET_CXX_ALWAYS_INLINE
 Normalize the given vector expression.

Function Documentation

template<class E , std::size_t Rows, std::size_t Cols>
bool tvmet::all_elements ( const XprMatrix< E, Rows, Cols > &  e) [inline]

check on statements for all elementsThis is for use with boolean operators like

Example:
 all_elements(matrix > 0) {
     // true branch
 } else {
     // false branch
 }
See also:
Compare Vectors and Matrices

References tvmet::meta::Matrix< Rows, Cols, M, N >::all_elements().

template<class E , std::size_t Sz>
bool tvmet::all_elements ( const XprVector< E, Sz > &  e) [inline]

check on statements for all elementsThis is for use with boolean operators like

Example:
 all_elements(vector > 0) {
     // true branch
 } else {
     // false branch
 }
See also:
Compare Vectors and Matrices

References tvmet::meta::Vector< Sz, K >::all_elements().

template<class E , std::size_t Rows, std::size_t Cols>
bool tvmet::any_elements ( const XprMatrix< E, Rows, Cols > &  e) [inline]

check on statements for any elementsThis is for use with boolean operators like

Example:
 any_elements(matrix > 0) {
     // true branch
 } else {
     // false branch
 }
See also:
Compare Vectors and Matrices

References tvmet::meta::Matrix< Rows, Cols, M, N >::any_elements().

template<class E , std::size_t Sz>
bool tvmet::any_elements ( const XprVector< E, Sz > &  e) [inline]

check on statements for any elementsThis is for use with boolean operators like

Example:
 any_elements(vector > 0) {
     // true branch
 } else {
     // false branch
 }
See also:
Compare Vectors and Matrices

References tvmet::meta::Vector< Sz, K >::any_elements().

template<class T , std::size_t Rows, std::size_t Cols>
XprMatrix< MatrixConstReference< T, Rows, Cols >, Rows, Cols > tvmet::cmatrix_ref ( const T *  mem) [inline]

Creates an expression wrapper for a C like matrices.

This is like creating a matrix of external data, as described at Construction and Initializing. With this function you wrap an expression around a C style matrix and you can operate directly with it as usual.

Example:
 static float lhs[3][3] = {
   {-1,  0,  1}, { 1,  0,  1}, {-1,  0, -1}
 };
 static float rhs[3][3] = {
   { 0,  1,  1}, { 0,  1, -1}, { 0, -1,  1}
 };
 ...

 typedef Matrix<float, 3, 3>      matrix_type;

 matrix_type M( cmatrix_ref<float, 3, 3>(&lhs[0][0])
                *  cmatrix_ref<float, 3, 3>(&rhs[0][0]) );
Since:
release 1.6.0
template<class T , std::size_t Sz>
XprVector< VectorConstReference< T, Sz >, Sz > tvmet::cvector_ref ( const T *  mem) [inline]

Creates an expression wrapper for a C like vector arrays.

This is like creating a vector of external data, as described at Construction and Initializing. With this function you wrap an expression around a C style vector array and you can operate directly with it as usual.

Example:
 static float vertices[N][3] = {
   {-1,  0,  1}, { 1,  0,  1}, ...
 };
 ...
 typedef Vector<float, 3>     vector_type;
 ...
 vector_type V( cross(cvector_ref<float, 3>(&vertices[0][0]),
                      cvector_ref<float, 3>(&vertices[1][0])) );
Since:
release 1.6.0
template<class T , std::size_t Sz>
XprVector< XprMatrixDiag< MatrixConstReference< T, Sz, Sz >, Sz >, Sz > tvmet::diag ( const Matrix< T, Sz, Sz > &  m) [inline]

Returns the diagonal vector of the given square matrix.

References tvmet::Matrix< T, NRows, NCols >::const_ref().

template<class E , std::size_t Sz>
XprVector< XprMatrixDiag< XprMatrix< E, Sz, Sz >, Sz >, Sz > tvmet::diag ( const XprMatrix< E, Sz, Sz > &  m) [inline]

Returns the diagonal vector of the given square matrix.

template<class T , std::size_t Rows, std::size_t Cols>
XprMatrix< XprIdentity< typename M::value_type, M::Rows, M::Cols >, M::Rows, M::Cols > tvmet::identity ( ) [inline]

Fill a matrix to an identity matrix.

Fill a matrix to an identity matrix (convenience wrapper for matrix typedefs).

Note:
The matrix doesn't need to be square. Only the elements where the current number of rows are equal to columns will be set to 1, else to 0.
Usage:
 typedef Matrix<double,3,3>   matrix_type;
 ...
 matrix_type E( identity<double, 3, 3>() );

Note, we have to specify the type, number of rows and columns since ADL can't work here.

Since:
release 1.6.0
Note:
The matrix doesn't need to be square. Only the elements where the current number of rows are equal to columns will be set to 1, else to 0.
Usage:
 typedef Matrix<double,3,3>   matrix_type;
 ...
 matrix_type E( identity<matrix_type>() );

Note, we have to specify the matrix type, since ADL can't work here.

Since:
release 1.6.0
template<class E , std::size_t Rows, std::size_t Cols>
E::value_type tvmet::max ( const XprMatrix< E, Rows, Cols > &  e) [inline]
template<class T , std::size_t Rows, std::size_t Cols>
T tvmet::max ( const Matrix< T, Rows, Cols > &  m) [inline]
template<class E , std::size_t Sz>
E::value_type tvmet::max ( const XprVector< E, Sz > &  e) [inline]

Find the maximum of a vector expression.

template<class T , std::size_t Sz>
T tvmet::max ( const Vector< T, Sz > &  v) [inline]

Find the maximum of a vector.

References tvmet::Vector< T, Sz >::begin(), and tvmet::Vector< T, Sz >::end().

template<class E , std::size_t Rows, std::size_t Cols>
Extremum< typename E::value_type, std::size_t, matrix_tag > tvmet::maximum ( const XprMatrix< E, Rows, Cols > &  e) [inline]

Find the maximum of a matrix expression.

Referenced by tvmet::maximum().

template<class E , std::size_t Sz>
Extremum< typename E::value_type, std::size_t, vector_tag > tvmet::maximum ( const XprVector< E, Sz > &  e) [inline]

Find the maximum of a vector expression.

template<class T , std::size_t Sz>
Extremum< T, std::size_t, vector_tag > tvmet::maximum ( const Vector< T, Sz > &  v) [inline]

Find the maximum of a vector.

References tvmet::Vector< T, Sz >::as_expr(), and tvmet::maximum().

template<class T , std::size_t Rows, std::size_t Cols>
Extremum< T, std::size_t, matrix_tag > tvmet::maximum ( const Matrix< T, Rows, Cols > &  m) [inline]

Find the maximum of a matrix.

References tvmet::Matrix< T, NRows, NCols >::as_expr(), and tvmet::maximum().

template<class E , std::size_t Rows, std::size_t Cols>
E::value_type tvmet::min ( const XprMatrix< E, Rows, Cols > &  e) [inline]
template<class T , std::size_t Rows, std::size_t Cols>
T tvmet::min ( const Matrix< T, Rows, Cols > &  m) [inline]
template<class E , std::size_t Sz>
E::value_type tvmet::min ( const XprVector< E, Sz > &  e) [inline]

Find the minimum of a vector expression.

template<class T , std::size_t Sz>
T tvmet::min ( const Vector< T, Sz > &  v) [inline]

Find the minimum of a vector.

References tvmet::Vector< T, Sz >::begin(), and tvmet::Vector< T, Sz >::end().

template<class T , std::size_t Rows, std::size_t Cols>
Extremum< T, std::size_t, matrix_tag > tvmet::minimum ( const Matrix< T, Rows, Cols > &  m) [inline]

Find the minimum of a matrix.

References tvmet::Matrix< T, NRows, NCols >::as_expr(), and tvmet::minimum().

template<class E , std::size_t Rows, std::size_t Cols>
Extremum< typename E::value_type, std::size_t, matrix_tag > tvmet::minimum ( const XprMatrix< E, Rows, Cols > &  e) [inline]

Find the minimum of a matrix expression.

Referenced by tvmet::minimum().

template<class T , std::size_t Sz>
Extremum< T, std::size_t, vector_tag > tvmet::minimum ( const Vector< T, Sz > &  v) [inline]

Find the minimum of a vector.

References tvmet::Vector< T, Sz >::as_expr(), and tvmet::minimum().

template<class E , std::size_t Sz>
Extremum< typename E::value_type, std::size_t, vector_tag > tvmet::minimum ( const XprVector< E, Sz > &  e) [inline]

Find the minimum of a vector expression.

template<class E , std::size_t Sz>
NumericTraits< typename E::value_type >::sum_type tvmet::norm1 ( const XprVector< E, Sz > &  v) [inline]

The $l_1$ norm of a vector expression.

The norm of any vector is just the square root of the dot product of a vector with itself, or

\[ |Vector<T, Sz> v| = |v| = \sum_{i=0}^{Sz-1}\,|v[i]| \]

References tvmet::sum().

template<class T , std::size_t Sz>
NumericTraits< T >::sum_type tvmet::norm1 ( const Vector< T, Sz > &  v) [inline]

The $l_1$ norm of a vector v.

The norm of any vector is just the square root of the dot product of a vector with itself, or

\[ |Vector<T, Sz> v| = |v| = \sum_{i=0}^{Sz-1}\,|v[i]| \]

References tvmet::sum().

template<class T , std::size_t Sz>
NumericTraits< T >::sum_type tvmet::norm2 ( const Vector< T, Sz > &  v) [inline]

The euklidian norm (or $l_2$ norm) of a vector v.

The norm of any vector is just the square root of the dot product of a vector with itself, or

\[ |Vector<T, Sz> v| = |v| = \sqrt{ \sum_{i=0}^{Sz-1}\,v[i]^2 } \]

Note:
The internal cast for Vector<int> avoids warnings on sqrt.

References tvmet::dot().

Referenced by tvmet::normalize().

template<class E , std::size_t Sz>
NumericTraits< typename E::value_type >::sum_type tvmet::norm2 ( const XprVector< E, Sz > &  v) [inline]

The euklidian norm (or $l_2$ norm) of a vector expression.

The norm of any vector is just the square root of the dot product of a vector with itself, or

\[ |Vector<T, Sz> v| = |v| = \sqrt{ \sum_{i=0}^{Sz-1}\,v[i]^2 } \]

Note:
The internal cast for Vector<int> avoids warnings on sqrt.

References tvmet::dot().

template<class T , std::size_t Sz>
XprVector< XprBinOp< Fcnl_div< T, T >, VectorConstReference< T, Sz >, XprLiteral< T > >, Sz > tvmet::normalize ( const Vector< T, Sz > &  v) [inline]

Normalize the given vector.

See also:
norm2

using the equation:

\[ \frac{Vector<T, Sz> v}{\sqrt{ \sum_{i=0}^{Sz-1}\,v[i]^2 }} \]

References tvmet::Vector< T, Sz >::const_ref(), and tvmet::norm2().

template<class E , std::size_t Sz>
XprVector< XprBinOp< Fcnl_div< typename E::value_type, typename E::value_type >, XprVector< E, Sz >, XprLiteral< typename E::value_type > >, Sz > tvmet::normalize ( const XprVector< E, Sz > &  v) [inline]

Normalize the given vector expression.

See also:
norm2

using the equation:

\[ \frac{Vector<T, Sz> v}{\sqrt{ \sum_{i=0}^{Sz-1}\,v[i]^2 }} \]

References tvmet::norm2().

template<class T , std::size_t Sz>
NumericTraits< T >::sum_type tvmet::product ( const Vector< T, Sz > &  v) [inline]

Compute the product of the vector elements.

Simply computer the product of the given vector as:

\[ \prod_{i = 0}^{Sz - 1} v[i] \]

References tvmet::meta::Vector< Sz, K >::product().

template<class E , std::size_t Sz>
NumericTraits< typename E::value_type >::sum_type tvmet::product ( const XprVector< E, Sz > &  v) [inline]

Compute the product of the vector elements.

Simply computer the product of the given vector expression as:

\[ \prod_{i = 0}^{Sz - 1} v[i] \]

References tvmet::meta::Vector< Sz, K >::product().

template<class T , std::size_t Sz>
NumericTraits< T >::sum_type tvmet::sum ( const Vector< T, Sz > &  v) [inline]
template<class E , std::size_t Sz>
NumericTraits< typename E::value_type >::sum_type tvmet::sum ( const XprVector< E, Sz > &  v) [inline]

Compute the sum of the vector expression.

Simply compute the sum of the given vector as:

\[ \sum_{i = 0}^{Sz-1} v[i] \]

References tvmet::meta::Vector< Sz, K >::sum().

template<class E , std::size_t Rows, std::size_t Cols>
XprMatrix< XprMatrixTranspose< XprMatrix< E, Rows, Cols > >, Cols, Rows > tvmet::trans ( const XprMatrix< E, Rows, Cols > &  rhs) [inline]

Transpose an expression matrix.

template<class T , std::size_t Rows, std::size_t Cols>
XprMatrix< XprMatrixTranspose< MatrixConstReference< T, Rows, Cols > >, Cols, Rows > tvmet::trans ( const Matrix< T, Rows, Cols > &  rhs) [inline]

Transpose the matrix.

References tvmet::Matrix< T, NRows, NCols >::const_ref().

 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Defines

Author: