51 Error(
"TDecompQRH(Int_t,Int_t",
"matrix rows should be >= columns");
71 const Int_t nrows = row_upb-row_lwb+1;
72 const Int_t ncols = col_upb-col_lwb+1;
75 Error(
"TDecompQRH(Int_t,Int_t,Int_t,Int_t",
"matrix rows should be >= columns");
99 if (
a.GetNrows() <
a.GetNcols()) {
100 Error(
"TDecompQRH(const TMatrixD &",
"matrix rows should be >= columns");
112 const Int_t nRow =
a.GetNrows();
113 const Int_t nCol =
a.GetNcols();
148 Error(
"Decompose()",
"Matrix has not been set");
160 else diagR.
Use(nCol,work);
163 for (
Int_t i = 0; i < nRow; i++) {
164 const Int_t ic = (i < nCol) ? i : nCol;
165 for (
Int_t j = ic ; j < nCol; j++)
184 const Int_t nRow =
q.GetNrows();
185 const Int_t nCol =
q.GetNcols();
187 const Int_t n = (nRow <= nCol) ? nRow-1 : nCol;
189 for (
Int_t k = 0 ; k <
n ; k++) {
193 diagR(k) = qc_k(k)-up(k);
196 for (
Int_t j = k+1; j < nCol; j++) {
204 diagR(nRow-1) =
q(nRow-1,nRow-1);
220 if (
a.GetNrows() <
a.GetNcols()) {
221 Error(
"TDecompQRH(const TMatrixD &",
"matrix rows should be >= columns");
230 const Int_t nRow =
a.GetNrows();
231 const Int_t nCol =
a.GetNcols();
253 Error(
"Solve()",
"Matrix is singular");
258 Error(
"Solve()",
"Decomposition failed");
264 Error(
"Solve(TVectorD &",
"vector and matrix incompatible");
272 const Int_t nQ = (nQRow <= nQCol) ? nQRow-1 : nQCol;
273 for (
Int_t k = 0; k < nQ; k++) {
284 for (
Int_t i = nRCol-1; i >= 0; i--) {
285 const Int_t off_i = i*nRCol;
287 for (
Int_t j = i+1; j < nRCol; j++)
288 r -= pR[off_i+j]*pb[j];
291 Error(
"Solve(TVectorD &)",
"R[%d,%d]=%.4e < %.4e",i,i,pR[off_i+i],
fTol);
294 pb[i] =
r/pR[off_i+i];
309 Error(
"Solve()",
"Matrix is singular");
314 Error(
"Solve()",
"Decomposition failed");
321 Error(
"Solve(TMatrixDColumn &",
"vector and matrix incompatible");
329 const Int_t nQ = (nQRow <= nQCol) ? nQRow-1 : nQCol;
330 for (
Int_t k = 0; k < nQ; k++) {
342 for (
Int_t i = nRCol-1; i >= 0; i--) {
343 const Int_t off_i = i*nRCol;
344 const Int_t off_i2 = i*inc;
346 for (
Int_t j = i+1; j < nRCol; j++)
347 r -= pR[off_i+j]*pcb[j*inc];
350 Error(
"Solve(TMatrixDColumn &)",
"R[%d,%d]=%.4e < %.4e",i,i,pR[off_i+i],
fTol);
353 pcb[off_i2] =
r/pR[off_i+i];
367 Error(
"TransSolve()",
"Matrix is singular");
372 Error(
"TransSolve()",
"Decomposition failed");
378 Error(
"TransSolve(TVectorD &",
"matrix should be square");
383 Error(
"TransSolve(TVectorD &",
"vector and matrix incompatible");
393 for (
Int_t i = 0; i < nRCol; i++) {
394 const Int_t off_i = i*nRCol;
396 for (
Int_t j = 0; j < i; j++) {
397 const Int_t off_j = j*nRCol;
398 r -= pR[off_j+i]*pb[j];
402 Error(
"TransSolve(TVectorD &)",
"R[%d,%d]=%.4e < %.4e",i,i,pR[off_i+i],
fTol);
405 pb[i] =
r/pR[off_i+i];
411 for (
Int_t k = nQRow-1; k >= 0; k--) {
428 Error(
"TransSolve()",
"Matrix is singular");
433 Error(
"TransSolve()",
"Decomposition failed");
439 Error(
"TransSolve(TMatrixDColumn &",
"matrix should be square");
444 Error(
"TransSolve(TMatrixDColumn &",
"vector and matrix incompatible");
455 for (
Int_t i = 0; i < nRCol; i++) {
456 const Int_t off_i = i*nRCol;
457 const Int_t off_i2 = i*inc;
459 for (
Int_t j = 0; j < i; j++) {
460 const Int_t off_j = j*nRCol;
461 r -= pR[off_j+i]*pcb[j*inc];
465 Error(
"TransSolve(TMatrixDColumn &)",
"R[%d,%d]=%.4e < %.4e",i,i,pR[off_i+i],
fTol);
468 pcb[off_i2] =
r/pR[off_i+i];
474 for (
Int_t k = nQRow-1; k >= 0; k--) {
512 Error(
"Invert(TMatrixD &",
"Input matrix has wrong shape");
556 if (
this != &source) {
Bool_t DefHouseHolder(const TVectorD &vc, Int_t lp, Int_t l, Double_t &up, Double_t &b, Double_t tol=0.0)
Define a Householder-transformation through the parameters up and b .
void ApplyHouseHolder(const TVectorD &vc, Double_t up, Double_t b, Int_t lp, Int_t l, TMatrixDRow &cr)
Apply Householder-transformation.
TMatrixTColumn_const< Double_t > TMatrixDColumn_const
TMatrixTColumn< Double_t > TMatrixDColumn
Decomposition Base class.
virtual Bool_t MultiSolve(TMatrixD &B)
Solve set of equations with RHS in columns of B.
void Print(Option_t *opt="") const
Print class members.
TDecompBase & operator=(const TDecompBase &source)
Assignment operator.
virtual void Det(Double_t &d1, Double_t &d2)
Matrix determinant det = d1*TMath::Power(2.,d2)
virtual Int_t GetNrows() const
virtual Bool_t Solve(TVectorD &b)
Solve Ax=b assuming the QR form of A is stored in fR,fQ and fW, but assume b has not been transformed...
virtual Int_t GetNcols() const
virtual void SetMatrix(const TMatrixD &a)
Set matrix to be decomposed.
virtual void Det(Double_t &d1, Double_t &d2)
This routine calculates the absolute (!) value of the determinant |det| = d1*TMath::Power(2....
TDecompQRH & operator=(const TDecompQRH &source)
Assignment operator.
void Print(Option_t *opt="") const
Print the class members.
static Bool_t QRH(TMatrixD &q, TVectorD &diagR, TVectorD &up, TVectorD &w, Double_t tol)
Decomposition function .
virtual Bool_t TransSolve(TVectorD &b)
Solve A^T x=b assuming the QR form of A is stored in fR,fQ and fW, but assume b has not been transfor...
virtual Bool_t Decompose()
QR decomposition of matrix a by Householder transformations, see Golub & Loan first edition p41 & Sec...
void Print(Option_t *name="") const
Print the matrix as a table of elements.
virtual TMatrixTBase< Element > & Shift(Int_t row_shift, Int_t col_shift)
Shift the row index by adding row_shift and the column index by adding col_shift, respectively.
const TMatrixTBase< Element > * GetMatrix() const
virtual TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1)
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
virtual const Element * GetMatrixArray() const
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TVectorT< Element > & ResizeTo(Int_t lwb, Int_t upb)
Resize the vector to [lwb:upb] .
TVectorT< Element > & Use(Int_t lwb, Int_t upb, Element *data)
Use the array data to fill the vector lwb..upb].
void Print(Option_t *option="") const
Print the vector as a list of elements.
void inv(rsa_NUMBER *, rsa_NUMBER *, rsa_NUMBER *)