PX4 Firmware
PX4 Autopilot Software http://px4.io
matrix::Matrix< Type, M, N > Class Template Reference

#include <Matrix.hpp>

Inheritance diagram for matrix::Matrix< Type, M, N >:
Collaboration diagram for matrix::Matrix< Type, M, N >:

Public Member Functions

 Matrix ()=default
 
 Matrix (const Type data_[M *N])
 
 Matrix (const Type data_[M][N])
 
 Matrix (const Matrix &other)
 
template<size_t P, size_t Q>
 Matrix (const Slice< Type, M, N, P, Q > &in_slice)
 
Type operator() (size_t i, size_t j) const
 Accessors/ Assignment etc. More...
 
Type & operator() (size_t i, size_t j)
 
Matrix< Type, M, N > & operator= (const Matrix< Type, M, N > &other)
 
void copyTo (Type dst[M *N]) const
 
void copyToColumnMajor (Type dst[M *N]) const
 
template<size_t P>
Matrix< Type, M, Poperator* (const Matrix< Type, N, P > &other) const
 Matrix Operations. More...
 
Matrix< Type, M, N > emult (const Matrix< Type, M, N > &other) const
 
Matrix< Type, M, N > edivide (const Matrix< Type, M, N > &other) const
 
Matrix< Type, M, N > operator+ (const Matrix< Type, M, N > &other) const
 
Matrix< Type, M, N > operator- (const Matrix< Type, M, N > &other) const
 
Matrix< Type, M, N > operator- () const
 
void operator+= (const Matrix< Type, M, N > &other)
 
void operator-= (const Matrix< Type, M, N > &other)
 
template<size_t P>
void operator*= (const Matrix< Type, N, P > &other)
 
Matrix< Type, M, N > operator* (Type scalar) const
 Scalar Operations. More...
 
Matrix< Type, M, N > operator/ (Type scalar) const
 
Matrix< Type, M, N > operator+ (Type scalar) const
 
Matrix< Type, M, N > operator- (Type scalar) const
 
void operator*= (Type scalar)
 
void operator/= (Type scalar)
 
void operator+= (Type scalar)
 
void operator-= (Type scalar)
 
bool operator== (const Matrix< Type, M, N > &other) const
 
bool operator!= (const Matrix< Type, M, N > &other) const
 
void write_string (char *buf, size_t n) const
 Misc. More...
 
void print (FILE *stream=stdout) const
 
Matrix< Type, N, M > transpose () const
 
Matrix< Type, N, M > T () const
 
template<size_t P, size_t Q>
const Slice< Type, P, Q, M, N > slice (size_t x0, size_t y0) const
 
template<size_t P, size_t Q>
Slice< Type, P, Q, M, N > slice (size_t x0, size_t y0)
 
const Slice< Type, 1, N, M, N > row (size_t i) const
 
Slice< Type, 1, N, M, N > row (size_t i)
 
const Slice< Type, M, 1, M, N > col (size_t j) const
 
Slice< Type, M, 1, M, N > col (size_t j)
 
void setRow (size_t i, const Matrix< Type, N, 1 > &row_in)
 
void setCol (size_t j, const Matrix< Type, M, 1 > &column)
 
void setZero ()
 
void zero ()
 
void setAll (Type val)
 
void setOne ()
 
void setNaN ()
 
void setIdentity ()
 
void identity ()
 
void swapRows (size_t a, size_t b)
 
void swapCols (size_t a, size_t b)
 
Matrix< Type, M, N > abs () const
 
Type max () const
 
Type min () const
 
bool isAllNan () const
 

Private Attributes

Type _data [M][N] {}
 

Detailed Description

template<typename Type, size_t M, size_t N>
class matrix::Matrix< Type, M, N >

Definition at line 36 of file Matrix.hpp.

Constructor & Destructor Documentation

◆ Matrix() [1/5]

template<typename Type, size_t M, size_t N>
matrix::Matrix< Type, M, N >::Matrix ( )
default

◆ Matrix() [2/5]

template<typename Type, size_t M, size_t N>
matrix::Matrix< Type, M, N >::Matrix ( const Type  data_[M *N])
inlineexplicit

Definition at line 66 of file Matrix.hpp.

◆ Matrix() [3/5]

template<typename Type, size_t M, size_t N>
matrix::Matrix< Type, M, N >::Matrix ( const Type  data_[M][N])
inlineexplicit

Definition at line 71 of file Matrix.hpp.

◆ Matrix() [4/5]

template<typename Type, size_t M, size_t N>
matrix::Matrix< Type, M, N >::Matrix ( const Matrix< Type, M, N > &  other)
inline

Definition at line 76 of file Matrix.hpp.

◆ Matrix() [5/5]

template<typename Type, size_t M, size_t N>
template<size_t P, size_t Q>
matrix::Matrix< Type, M, N >::Matrix ( const Slice< Type, M, N, P, Q > &  in_slice)
inline

Definition at line 82 of file Matrix.hpp.

Member Function Documentation

◆ abs()

template<typename Type, size_t M, size_t N>
Matrix<Type, M, N> matrix::Matrix< Type, M, N >::abs ( ) const
inline

Definition at line 492 of file Matrix.hpp.

◆ col() [1/2]

template<typename Type, size_t M, size_t N>
const Slice<Type, M, 1, M, N> matrix::Matrix< Type, M, N >::col ( size_t  j) const
inline

Definition at line 395 of file Matrix.hpp.

Referenced by main(), and MatrixTest::matrixAssignmentTests().

Here is the caller graph for this function:

◆ col() [2/2]

template<typename Type, size_t M, size_t N>
Slice<Type, M, 1, M, N> matrix::Matrix< Type, M, N >::col ( size_t  j)
inline

Definition at line 400 of file Matrix.hpp.

◆ copyTo()

◆ copyToColumnMajor()

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::copyToColumnMajor ( Type  dst[M *N]) const
inline

Definition at line 120 of file Matrix.hpp.

Referenced by main().

Here is the caller graph for this function:

◆ edivide()

template<typename Type, size_t M, size_t N>
Matrix<Type, M, N> matrix::Matrix< Type, M, N >::edivide ( const Matrix< Type, M, N > &  other) const
inline

Definition at line 171 of file Matrix.hpp.

Referenced by main().

Here is the caller graph for this function:

◆ emult()

template<typename Type, size_t M, size_t N>
Matrix<Type, M, N> matrix::Matrix< Type, M, N >::emult ( const Matrix< Type, M, N > &  other) const
inline

Definition at line 157 of file Matrix.hpp.

Referenced by main(), MatrixTest::matrixMultTests(), MulticopterRateControl::parameters_updated(), MulticopterRateControl::Run(), AttitudeControl::update(), and RateControl::update().

Here is the caller graph for this function:

◆ identity()

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::identity ( )
inline

Definition at line 457 of file Matrix.hpp.

Referenced by main(), MathlibTest::testMatrix3x3(), MathlibTest::testQuaternionfrom_dcm(), MathlibTest::testQuaternionfrom_euler(), and landing_target_estimator::KalmanFilter::update().

Here is the caller graph for this function:

◆ isAllNan()

template<typename Type, size_t M, size_t N>
bool matrix::Matrix< Type, M, N >::isAllNan ( ) const
inline

Definition at line 531 of file Matrix.hpp.

Referenced by main().

Here is the caller graph for this function:

◆ max()

template<typename Type, size_t M, size_t N>
Type matrix::Matrix< Type, M, N >::max ( ) const
inline

Definition at line 503 of file Matrix.hpp.

Referenced by matrix::max().

Here is the caller graph for this function:

◆ min()

template<typename Type, size_t M, size_t N>
Type matrix::Matrix< Type, M, N >::min ( ) const
inline

Definition at line 517 of file Matrix.hpp.

Referenced by main(), MatrixTest::matrixAssignmentTests(), and matrix::min().

Here is the caller graph for this function:

◆ operator!=()

template<typename Type, size_t M, size_t N>
bool matrix::Matrix< Type, M, N >::operator!= ( const Matrix< Type, M, N > &  other) const
inline

Definition at line 321 of file Matrix.hpp.

◆ operator()() [1/2]

template<typename Type, size_t M, size_t N>
Type matrix::Matrix< Type, M, N >::operator() ( size_t  i,
size_t  j 
) const
inline

Accessors/ Assignment etc.

Definition at line 97 of file Matrix.hpp.

◆ operator()() [2/2]

template<typename Type, size_t M, size_t N>
Type& matrix::Matrix< Type, M, N >::operator() ( size_t  i,
size_t  j 
)
inline

Definition at line 102 of file Matrix.hpp.

◆ operator*() [1/2]

template<typename Type, size_t M, size_t N>
template<size_t P>
Matrix<Type, M, P> matrix::Matrix< Type, M, N >::operator* ( const Matrix< Type, N, P > &  other) const
inline

Matrix Operations.

Definition at line 140 of file Matrix.hpp.

Referenced by matrix::Vector3< Type >::operator*().

Here is the caller graph for this function:

◆ operator*() [2/2]

template<typename Type, size_t M, size_t N>
Matrix<Type, M, N> matrix::Matrix< Type, M, N >::operator* ( Type  scalar) const
inline

Scalar Operations.

Definition at line 251 of file Matrix.hpp.

◆ operator*=() [1/2]

template<typename Type, size_t M, size_t N>
template<size_t P>
void matrix::Matrix< Type, M, N >::operator*= ( const Matrix< Type, N, P > &  other)
inline

Definition at line 241 of file Matrix.hpp.

◆ operator*=() [2/2]

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::operator*= ( Type  scalar)
inline

Definition at line 289 of file Matrix.hpp.

◆ operator+() [1/2]

template<typename Type, size_t M, size_t N>
Matrix<Type, M, N> matrix::Matrix< Type, M, N >::operator+ ( const Matrix< Type, M, N > &  other) const
inline

Definition at line 185 of file Matrix.hpp.

Referenced by matrix::Vector3< Type >::operator+().

Here is the caller graph for this function:

◆ operator+() [2/2]

template<typename Type, size_t M, size_t N>
Matrix<Type, M, N> matrix::Matrix< Type, M, N >::operator+ ( Type  scalar) const
inline

Definition at line 270 of file Matrix.hpp.

◆ operator+=() [1/2]

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::operator+= ( const Matrix< Type, M, N > &  other)
inline

Definition at line 228 of file Matrix.hpp.

◆ operator+=() [2/2]

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::operator+= ( Type  scalar)
inline

Definition at line 306 of file Matrix.hpp.

◆ operator-() [1/3]

template<typename Type, size_t M, size_t N>
Matrix<Type, M, N> matrix::Matrix< Type, M, N >::operator- ( const Matrix< Type, M, N > &  other) const
inline

Definition at line 199 of file Matrix.hpp.

◆ operator-() [2/3]

template<typename Type, size_t M, size_t N>
Matrix<Type, M, N> matrix::Matrix< Type, M, N >::operator- ( ) const
inline

Definition at line 214 of file Matrix.hpp.

Referenced by matrix::Vector3< Type >::operator-().

Here is the caller graph for this function:

◆ operator-() [3/3]

template<typename Type, size_t M, size_t N>
Matrix<Type, M, N> matrix::Matrix< Type, M, N >::operator- ( Type  scalar) const
inline

Definition at line 284 of file Matrix.hpp.

◆ operator-=() [1/2]

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::operator-= ( const Matrix< Type, M, N > &  other)
inline

Definition at line 234 of file Matrix.hpp.

◆ operator-=() [2/2]

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::operator-= ( Type  scalar)
inline

Definition at line 311 of file Matrix.hpp.

◆ operator/()

template<typename Type, size_t M, size_t N>
Matrix<Type, M, N> matrix::Matrix< Type, M, N >::operator/ ( Type  scalar) const
inline

Definition at line 265 of file Matrix.hpp.

◆ operator/=()

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::operator/= ( Type  scalar)
inline

Definition at line 300 of file Matrix.hpp.

◆ operator=()

template<typename Type, size_t M, size_t N>
Matrix<Type, M, N>& matrix::Matrix< Type, M, N >::operator= ( const Matrix< Type, M, N > &  other)
inline

Definition at line 107 of file Matrix.hpp.

Referenced by matrix::SquareMatrix< Type, 3 >::operator=().

Here is the caller graph for this function:

◆ operator==()

template<typename Type, size_t M, size_t N>
bool matrix::Matrix< Type, M, N >::operator== ( const Matrix< Type, M, N > &  other) const
inline

Definition at line 316 of file Matrix.hpp.

◆ print()

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::print ( FILE *  stream = stdout) const
inline

Definition at line 343 of file Matrix.hpp.

Referenced by main(), and MathlibTest::testMatrixNonsymmetric().

Here is the caller graph for this function:

◆ row() [1/2]

template<typename Type, size_t M, size_t N>
const Slice<Type, 1, N, M, N> matrix::Matrix< Type, M, N >::row ( size_t  i) const
inline

Definition at line 385 of file Matrix.hpp.

Referenced by matrix::collectDerivatives(), MatrixTest::dcmRenormTests(), AttitudeEstimatorQ::init_attq(), main(), MatrixTest::matrixAssignmentTests(), and matrix::Dcm< float >::renormalize().

Here is the caller graph for this function:

◆ row() [2/2]

template<typename Type, size_t M, size_t N>
Slice<Type, 1, N, M, N> matrix::Matrix< Type, M, N >::row ( size_t  i)
inline

Definition at line 390 of file Matrix.hpp.

◆ setAll()

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::setAll ( Type  val)
inline

◆ setCol()

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::setCol ( size_t  j,
const Matrix< Type, M, 1 > &  column 
)
inline

Definition at line 411 of file Matrix.hpp.

Referenced by main().

Here is the caller graph for this function:

◆ setIdentity()

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::setIdentity ( )
inline

Definition at line 447 of file Matrix.hpp.

Referenced by MatrixTest::filterTests(), matrix::Matrix< float, n_x, n_u >::identity(), main(), MatrixTest::matrixMultTests(), MatrixTest::setIdentityTests(), and TerrainEstimator::TerrainEstimator().

Here is the caller graph for this function:

◆ setNaN()

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::setNaN ( )
inline

Definition at line 442 of file Matrix.hpp.

Referenced by matrix::constrain(), StraightLine::generateSetpoints(), ObstacleAvoidance::injectAvoidanceSetpoints(), main(), matrix::nans(), and ObstacleAvoidance::ObstacleAvoidance().

Here is the caller graph for this function:

◆ setOne()

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::setOne ( )
inline

Definition at line 437 of file Matrix.hpp.

Referenced by matrix::ones().

Here is the caller graph for this function:

◆ setRow()

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::setRow ( size_t  i,
const Matrix< Type, N, 1 > &  row_in 
)
inline

Definition at line 405 of file Matrix.hpp.

Referenced by main().

Here is the caller graph for this function:

◆ setZero()

◆ slice() [1/2]

template<typename Type, size_t M, size_t N>
template<size_t P, size_t Q>
const Slice<Type, P, Q, M, N> matrix::Matrix< Type, M, N >::slice ( size_t  x0,
size_t  y0 
) const
inline

Definition at line 374 of file Matrix.hpp.

Referenced by main().

Here is the caller graph for this function:

◆ slice() [2/2]

template<typename Type, size_t M, size_t N>
template<size_t P, size_t Q>
Slice<Type, P, Q, M, N> matrix::Matrix< Type, M, N >::slice ( size_t  x0,
size_t  y0 
)
inline

Definition at line 380 of file Matrix.hpp.

◆ swapCols()

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::swapCols ( size_t  a,
size_t  b 
)
inline

Definition at line 477 of file Matrix.hpp.

Referenced by main(), and MatrixTest::matrixAssignmentTests().

Here is the caller graph for this function:

◆ swapRows()

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::swapRows ( size_t  a,
size_t  b 
)
inline

Definition at line 462 of file Matrix.hpp.

Referenced by main(), and MatrixTest::matrixAssignmentTests().

Here is the caller graph for this function:

◆ T()

template<typename Type, size_t M, size_t N>
Matrix<Type, N, M> matrix::Matrix< Type, M, N >::T ( ) const
inline

Definition at line 368 of file Matrix.hpp.

Referenced by matrix::kalman_correct(), and main().

Here is the caller graph for this function:

◆ transpose()

◆ write_string()

template<typename Type, size_t M, size_t N>
void matrix::Matrix< Type, M, N >::write_string ( char *  buf,
size_t  n 
) const
inline

Misc.

Functions

Definition at line 331 of file Matrix.hpp.

Referenced by main(), and matrix::Matrix< float, n_x, n_u >::print().

Here is the caller graph for this function:

◆ zero()

Member Data Documentation

◆ _data

template<typename Type, size_t M, size_t N>
Type matrix::Matrix< Type, M, N >::_data[M][N] {}
private

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