STK++ 0.9.13
STK::Qr Class Reference

The class Qr perform the QR decomposition of an ArrayXX. More...

#include <STK_Qr.h>

Inheritance diagram for STK::Qr:
Inheritance graph

Public Types

typedef hidden::AlgebraTraits< Qr >::ColVector ColVector
 
typedef hidden::AlgebraTraits< Qr >::RowVector RowVector
 
typedef IQr< QrBase
 

Public Member Functions

 Qr (ArrayXX const &A, bool ref=false)
 Default constructor.
 
template<class Derived >
 Qr (ExprBase< Derived > const &data)
 Constructor.
 
 Qr (Qr const &decomp)
 Copy constructor.
 
virtual ~Qr ()
 virtual destructor
 
virtual Qrclone () const
 clone pattern
 
Qroperator= (Qr const &decomp)
 Operator = : overwrite the Qr with decomp.
 
bool runImpl ()
 Compute the QR decomposition.
 
- Public Member Functions inherited from STK::IQr< Qr >
virtual ~IQr ()
 virtual destructor
 
IQroperator= (IQr const &decomp)
 Operator = : overwrite the this with decomp.
 
bool isCompQ () const
 
int rank () const
 
Array constQ () const
 give the matrix Q of the QR decomposition.
 
ArrayUpperTriangularXX constR () const
 give the matrix R of the QR decomposition.
 
void setCompQ (bool compq)
 Set the compq_ flag.
 
virtual bool run ()
 Compute the QR decomposition.
 
void compQ ()
 Compute Q (to use after run).
 
void popBackCols (int n=1)
 Delete the n last columns and update the QR decomposition.
 
void eraseCol (int pos)
 Delete the column pos and update the QR decomposition.
 
void pushBackCol (ColVector_ const &T)
 Add a column with value T and update th QR decomposition.
 
void insertCol (ColVector_ const &T, int pos)
 Add a column with value T at the position pos and update the QR decomposition.
 
void setData (ExprBase< OtherDerived > const &data)
 overloading of setData.
 
- Public Member Functions inherited from STK::IRunnerBase
String consterror () const
 get the last error message.
 
- Public Member Functions inherited from STK::IRecursiveTemplate< Derived >
Derived & asDerived ()
 static cast : return a reference of this with a cast to the derived class.
 
Derived constasDerived () const
 static cast : return a const reference of this with a cast to the derived class.
 
Derived * asPtrDerived ()
 static cast : return a ptr on a Derived of this with a cast to the derived class.
 
Derived constasPtrDerived () const
 static cast : return a ptr on a constant Derived of this with a cast to the derived class.
 
Derived * clone () const
 create a leaf using the copy constructor of the Derived class.
 
Derived * clone (bool isRef) const
 create a leaf using the copy constructor of the Derived class and a flag determining if the clone is a reference or not.
 

Private Member Functions

void qr ()
 Compute the qr decomposition of the matrix Q_.
 

Additional Inherited Members

- Protected Types inherited from STK::IQr< Qr >
typedef hidden::AlgebraTraits< Qr >::Array Array
 
typedef hidden::AlgebraTraits< Qr >::ColVector ColVector
 
typedef hidden::AlgebraTraits< Qr >::RowVector RowVector
 
- Protected Member Functions inherited from STK::IQr< Qr >
 IQr (Array const &Q, bool ref=false)
 Constructor.
 
 IQr (ExprBase< DerivedExpr > const &Q)
 Constructor.
 
 IQr (IQr const &decomp)
 Copy constructor.
 
- Protected Member Functions inherited from STK::IRunnerBase
 IRunnerBase ()
 default constructor
 
 IRunnerBase (IRunnerBase const &runner)
 copy constructor
 
virtual ~IRunnerBase ()
 destructor
 
virtual void update ()
 update the runner.
 
- Protected Member Functions inherited from STK::IRecursiveTemplate< Derived >
 IRecursiveTemplate ()
 constructor.
 
 ~IRecursiveTemplate ()
 destructor.
 
- Protected Attributes inherited from STK::IQr< Qr >
Array Q_
 Q Array of the QR decomposition.
 
ArrayUpperTriangularXX R_
 R Array of th QR decomposition.
 
bool compq_
 is Q computed ?
 
int rank_
 estimated rank_ of the matrix A
 
- Protected Attributes inherited from STK::IRunnerBase
String msg_error_
 String with the last error message.
 
bool hasRun_
 true if run has been used, false otherwise
 

Detailed Description

The class Qr perform the QR decomposition of an ArrayXX.

  • Input: A matrix (nrow,ncol)
  • Output:
    1. Q matrix (nrow,ncol) with the Housholder vectors in the min(nrow, ncol) first columns.
    2. R matrix (nrow,ncol) upper triangular.
See also
STK::IQr

Definition at line 97 of file STK_Qr.h.

Member Typedef Documentation

◆ Base

Definition at line 102 of file STK_Qr.h.

◆ ColVector

Definition at line 100 of file STK_Qr.h.

◆ RowVector

Definition at line 101 of file STK_Qr.h.

Constructor & Destructor Documentation

◆ Qr() [1/3]

STK::Qr::Qr ( ArrayXX const A,
bool  ref = false 
)
inline

Default constructor.

Parameters
Athe matrix to decompose
reftrue if we overwrite A

Definition at line 110 of file STK_Qr.h.

110: Base(A, ref) {}
IQr< Qr > Base
Definition STK_Qr.h:102

◆ Qr() [2/3]

template<class Derived >
STK::Qr::Qr ( ExprBase< Derived > const data)
inline

Constructor.

Parameters
datareference on a matrix expression

Definition at line 115 of file STK_Qr.h.

115: Base(data) {}

◆ Qr() [3/3]

STK::Qr::Qr ( Qr const decomp)
inline

Copy constructor.

Parameters
decompthe decomposition to copy

Definition at line 119 of file STK_Qr.h.

119: Base(decomp) {}

◆ ~Qr()

virtual STK::Qr::~Qr ( )
inlinevirtual

virtual destructor

Definition at line 121 of file STK_Qr.h.

121{}

Member Function Documentation

◆ clone()

virtual Qr * STK::Qr::clone ( ) const
inlinevirtual

clone pattern

Definition at line 123 of file STK_Qr.h.

123{ return new Qr(*this);}
Qr(ArrayXX const &A, bool ref=false)
Default constructor.
Definition STK_Qr.h:110

◆ operator=()

Qr & STK::Qr::operator= ( Qr const decomp)
inline

Operator = : overwrite the Qr with decomp.

Definition at line 125 of file STK_Qr.h.

126 { Base::operator=(decomp);
127 return *this;
128 }
IQr & operator=(IQr const &decomp)
Operator = : overwrite the this with decomp.
Definition STK_IQr.h:139

References STK::IQr< Qr >::operator=().

◆ qr()

void STK::Qr::qr ( )
inlineprivate

Compute the qr decomposition of the matrix Q_.

Definition at line 138 of file STK_Qr.h.

139{
140 R_.resize(Q_.rows(), Q_.cols());
141 // start left householder reflections
142 Range r(Q_.rows()), c(Q_.cols());
143 for(int j = R_.beginRows(); (j < R_.endRows()) && (j < R_.endCols()) ; ++j)
144 {
145 ColVector u(Q_, r, j);// get a reference on the j-th column in the range r
146 R_(j, j) = house(u); // compute the housolder vector
147 applyLeftHouseholderVector(Q_.sub(r, c.incFirst(1)), u); // apply-it to the remaining part of Q_
148 R_.row(j, c).copy(Q_.row(j, c)); // copy current row of Q_ in the range c in R_
149 r.incFirst(1); // decrease the range
150 }
151}
int beginRows() const
int endRows() const
Derived & resize(Range const &I, Range const &J)
resize the array.
int endCols() const
Row row(int i) const
access to a part of a row.
ArrayUpperTriangularXX R_
R Array of th QR decomposition.
Definition STK_IQr.h:219
Array Q_
Q Array of the QR decomposition.
Definition STK_IQr.h:217
hidden::AlgebraTraits< Qr >::ColVector ColVector
Definition STK_Qr.h:100
void applyLeftHouseholderVector(ArrayBase< Lhs > const &M, ExprBase< Rhs > const &v)
left multiplication by a Householder vector.
Real house(ArrayBase< Vector > &x)
Compute the Householder vector v of a vector x.
TRange< UnknownSize > Range
Definition STK_Range.h:59

References STK::applyLeftHouseholderVector(), STK::IArray2D< Derived >::beginRows(), STK::IArray2D< Derived >::endCols(), STK::IArray2D< Derived >::endRows(), STK::house(), STK::IQr< Qr >::Q_, STK::IQr< Qr >::R_, STK::IArray2D< Derived >::resize(), and STK::IArray2D< Derived >::row().

Referenced by runImpl().

◆ runImpl()

bool STK::Qr::runImpl ( )
inline

Compute the QR decomposition.

Definition at line 130 of file STK_Qr.h.

130{ qr(); return true;}
void qr()
Compute the qr decomposition of the matrix Q_.
Definition STK_Qr.h:138

References qr().


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