51 template <
class T>
inline 54 , m_(A.info().getSize(0))
55 , n_(A.info().getSize(1))
62 for (
int k=0; k<
n_; ++k )
65 for (
int i=k; i<
m_; ++i )
78 for (
int i=k; i<
m_; ++i )
79 qr_.set( i, k,
qr_.get( i, k )/norm );
81 qr_.set( k, k,
qr_.get( k, k ) + 1. );
83 for (
int j=k+1; j<
n_; ++j )
86 for (
int i=k; i<
m_; ++i )
87 s +=
qr_.get( i, k ) *
qr_.get( i, j );
89 s = -s /
qr_.get( k, k );
90 for (
int i=k; i<
m_; ++i )
91 qr_.set( i, j,
qr_.get( i, j ) + s *
qr_.get( i, k ) );
99 template <
class T>
inline 106 template <
class T>
inline 114 for (
int idx=0; idx<sz; idx++ )
115 arr->
set( idx, 0, b.
get( idx ) );
123 template <
class T>
inline 133 for (
int k=0; k<
n_; ++k )
135 for (
int j=0; j<nx; ++j )
138 for (
int i=k; i<
m_; ++i )
139 s +=
qr_.get( i, k ) * arr->
get( i, j );
141 s = -s /
qr_.get( k, k );
142 for (
int i=k; i<
m_; ++i )
143 arr->
set( i, j, arr->
get( i, j ) + s *
qr_.get( i, k ) );
148 for (
int k=n_-1; k>=0; --k )
150 for (
int j=0; j<nx; ++j )
153 for (
int i=0; i<k; ++i )
154 for (
int j=0; j<nx; ++j )
155 arr->
set( i, j, arr->
get( i, j ) -
156 arr->
get( k, j ) *
qr_.get( i, k ) );
161 for (
int idx=0; idx<
n_; idx++ )
162 out->
set( idx, arr->
get(idx,0) );
169 template <
class T>
inline 176 for (
int k=
n_-1; k>=0; --k )
178 for (
int i=0; i<
m_; ++i )
179 arr->
set( i, k, 0. );
181 arr->
set( k, k, 1. );
182 for (
int j=k; j<
n_; ++j )
188 for (
int i=k; i<
m_; ++i )
189 s +=
qr_.get( i, k) * arr->
get( i, j );
191 s = -s /
qr_.get( k, k );
192 for (
int i=k; i<
m_; ++i )
193 arr->
set( i, j, arr->
get( i, j ) + s *
qr_.get( i, k ) );
203 template <
class T>
inline 210 for (
int i=0; i<
n_; ++i )
213 for (
int j=i+1; j<
n_; ++j )
214 arr->
set( i, j,
qr_.get( i, j ) );
const Array2DImpl< T > * getQ() const
Definition: qrsolv.h:170
Array1D ( Subclass of ArrayND ) is a one dimensional array.
Definition: arraynd.h:101
~QRSolver()
Definition: qrsolv.h:100
Array2DImpl< T > qr_
Definition: qrsolv.h:42
Array1DImpl< T > * rdiag_
Definition: qrsolv.h:43
#define mIsZero(x, eps)
Definition: commondefs.h:53
#define TINY
Definition: qrsolv.h:18
Implementation of Array2D.
Definition: arrayndimpl.h:102
int n_
Definition: qrsolv.h:45
T get(int, int) const
Definition: arrayndimpl.h:470
void set(int pos, T)
Definition: arrayndimpl.h:360
bool isfullrank_
Definition: qrsolv.h:46
int m_
Definition: qrsolv.h:44
virtual int getSize(int dim) const =0
Array2D ( Subclass of ArrayND ) is a two dimensional array.
Definition: arraynd.h:131
QRSolver(const Array2D< T > &A)
Definition: qrsolv.h:52
const Array1DImpl< T > * apply(const Array1D< T > &B) const
Definition: qrsolv.h:107
const Array2DImpl< T > * getR() const
Definition: qrsolv.h:204
QRSolver - QR decomposition of a matrix A For an m-by-n matrix A, with m>=n, the QR decomposition is ...
Definition: qrsolv.h:28
virtual const Array1DInfo & info() const =0
bool isFullRank()
Definition: qrsolv.h:34
virtual T get(int) const =0
void set(int, int, T)
Definition: arrayndimpl.h:448
Implementation of Array1D.
Definition: arrayndimpl.h:52
#define mClass(module)
Definition: commondefs.h:164
virtual const Array2DInfo & info() const =0