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

#include <LeastSquaresSolver.hpp>

Collaboration diagram for matrix::LeastSquaresSolver< Type, M, N >:

Public Member Functions

 LeastSquaresSolver (const Matrix< Type, M, N > &A)
 Class calculates QR decomposition which can be used for linear least squares. More...
 
Vector< Type, M > qtb (const Vector< Type, M > &b)
 qtb Calculate Q^T * b More...
 
Vector< Type, N > solve (const Vector< Type, M > &b)
 Solve Ax=b for x. More...
 

Private Attributes

Matrix< Type, M, N > _A
 
Vector< Type, N > _tau
 

Detailed Description

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

Definition at line 22 of file LeastSquaresSolver.hpp.

Constructor & Destructor Documentation

◆ LeastSquaresSolver()

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

Class calculates QR decomposition which can be used for linear least squares.

Parameters
AMatrix of size MxN

Initialize the class with a MxN matrix. The constructor starts the QR decomposition. This class does not check the rank of the matrix. The user needs to make sure that rank(A) = N and M >= N.

Definition at line 35 of file LeastSquaresSolver.hpp.

References matrix::LeastSquaresSolver< Type, M, N >::_A, matrix::LeastSquaresSolver< Type, M, N >::_tau, and matrix::sqrt().

Here is the call graph for this function:

Member Function Documentation

◆ qtb()

template<typename Type, size_t M, size_t N>
Vector<Type, M> matrix::LeastSquaresSolver< Type, M, N >::qtb ( const Vector< Type, M > &  b)
inline

qtb Calculate Q^T * b

Parameters
b
Returns
Q^T*b

This function calculates Q^T * b. This is useful for the solver because R*x = Q^T*b.

Definition at line 85 of file LeastSquaresSolver.hpp.

References matrix::LeastSquaresSolver< Type, M, N >::_A, and matrix::LeastSquaresSolver< Type, M, N >::_tau.

Referenced by matrix::LeastSquaresSolver< Type, M, N >::solve().

Here is the caller graph for this function:

◆ solve()

template<typename Type, size_t M, size_t N>
Vector<Type, N> matrix::LeastSquaresSolver< Type, M, N >::solve ( const Vector< Type, M > &  b)
inline

Solve Ax=b for x.

Parameters
b
Returns
Vector x

Find x in the equation Ax = b. A is provided in the initializer of the class.

Definition at line 115 of file LeastSquaresSolver.hpp.

References matrix::LeastSquaresSolver< Type, M, N >::_A, matrix::isEqualF(), and matrix::LeastSquaresSolver< Type, M, N >::qtb().

Referenced by test_4x3(), test_4x4(), and test_div_zero().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _A

◆ _tau

template<typename Type, size_t M, size_t N>
Vector<Type, N> matrix::LeastSquaresSolver< Type, M, N >::_tau
private

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