77 fU.ResizeTo(nrows,nrows);
85 const Int_t nrows = row_upb-row_lwb+1;
90 fU.ResizeTo(nrows,nrows);
110 const Int_t nRows =
a.GetNrows();
112 fU.ResizeTo(nRows,nRows);
113 memcpy(
fU.GetMatrixArray(),
a.GetMatrixArray(),nRows*nRows*
sizeof(
Double_t));
135 Error(
"Decompose()",
"Matrix has not been set");
180 if (absakk >= alpha*colmax) {
197 if (absakk >= alpha*colmax*(colmax/rowmax)) {
200 }
else if(
TMath::Abs(diag(imax)) >= alpha*rowmax) {
210 const Int_t kk = k-kstep+1;
215 for (
Int_t irow = 0; irow < kp; irow++) {
223 c_kk = pU+(kp+1)*
n+kk;
225 for (
Int_t icol = 0; icol < kk-kp-1; icol++) {
238 pU[(k-1)*
n+k] = pU[kp*
n+k];
245 if (kstep == 1 && k > 0) {
271 const Double_t d22 = pU_k1[k-1]/d12;
276 for (
Int_t j = k-2; j >= 0; j--) {
278 const Double_t wkm1 = d12*(d11*pU_j[k-1]-pU_j[k]);
279 const Double_t wk = d12*(d22*pU_j[k]-pU_j[k-1]);
280 for (
Int_t i = j; i >= 0; i--) {
282 pU_i[j] -= (pU_i[k]*wk+pU_i[k-1]*wkm1);
295 fIpiv[k-1] = -(kp+1);
329 const Int_t nRows =
a.GetNrows();
331 fU.ResizeTo(nRows,nRows);
332 memcpy(
fU.GetMatrixArray(),
a.GetMatrixArray(),nRows*nRows*
sizeof(
Double_t));
342 Error(
"Solve()",
"Matrix is singular");
347 Error(
"Solve()",
"Decomposition failed");
352 if (
fU.GetNrows() !=
b.GetNrows() ||
fU.GetRowLwb() !=
b.GetLwb()) {
353 Error(
"Solve(TVectorD &",
"vector and matrix incompatible");
383 for (
Int_t i = 0; i < k; i++)
384 pb[i] -= pU[i*
n+k]*pb[k];
403 for (i = 0; i < k-1; i++)
404 pb[i] -= pU[i*
n+k]*pb[k];
405 for (i = 0; i < k-1; i++)
406 pb[i] -= pU[i*
n+k-1]*pb[k-1];
411 const Double_t ukm1 = pU_k1[k-1]/ukm1k;
414 const Double_t bkm1 = pb[k-1]/ukm1k;
416 pb[k-1] = (uk*bkm1-bk)/denom;
417 pb[k] = (ukm1*bk-bkm1)/denom;
434 for (
Int_t i = 0; i < k; i++)
435 pb[k] -= pU[i*
n+k]*pb[i];
450 for (i = 0; i < k; i++)
451 pb[k] -= pU[i*
n+k]*pb[i];
452 for (i = 0; i < k; i++)
453 pb[k+1] -= pU[i*
n+k+1]*pb[i];
477 Error(
"Solve()",
"Matrix is singular");
482 Error(
"Solve()",
"Decomposition failed");
487 if (
fU.GetNrows() !=
b->GetNrows() ||
fU.GetRowLwb() !=
b->GetRowLwb()) {
488 Error(
"Solve(TMatrixDColumn &",
"vector and matrix incompatible");
514 pcb[k*inc] = pcb[kp*inc];
520 for (
Int_t i = 0; i < k; i++)
521 pcb[i*inc] -= pU[i*
n+k]*pcb[k*inc];
524 pcb[k*inc] /= diag(k);
532 const Double_t tmp = pcb[(k-1)*inc];
533 pcb[(k-1)*inc] = pcb[kp*inc];
540 for (i = 0; i < k-1; i++)
541 pcb[i*inc] -= pU[i*
n+k]*pcb[k*inc];
542 for (i = 0; i < k-1; i++)
543 pcb[i*inc] -= pU[i*
n+k-1]*pcb[(k-1)*inc];
548 const Double_t ukm1 = pU_k1[k-1]/ukm1k;
551 const Double_t bkm1 = pcb[(k-1)*inc]/ukm1k;
552 const Double_t bk = pcb[k*inc]/ukm1k;
553 pcb[(k-1)*inc] = (uk*bkm1-bk)/denom;
554 pcb[k*inc] = (ukm1*bk-bkm1)/denom;
571 for (
Int_t i = 0; i < k; i++)
572 pcb[k*inc] -= pU[i*
n+k]*pcb[i*inc];
578 pcb[k*inc] = pcb[kp*inc];
587 for (i = 0; i < k; i++)
588 pcb[k*inc] -= pU[i*
n+k]*pcb[i*inc];
589 for (i = 0; i < k; i++)
590 pcb[(k+1)*inc] -= pU[i*
n+k+1]*pcb[i*inc];
596 pcb[k*inc] = pcb[kp*inc];
612 Error(
"Invert(TMatrixDSym &",
"Input matrix has wrong shape");
621 for (
Int_t icol = colLwb; icol <= colUpb && status; icol++) {
652 printf(
"[%d] = %d\n",i,
fIpiv[i]);
661 if (
this != &source) {
663 fU.ResizeTo(source.
fU);
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char).
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
TMatrixTBase< Double_t > TMatrixDBase
TMatrixTSym< Double_t > TMatrixDSym
TMatrixTSub< Double_t > TMatrixDSub
TMatrixTColumn_const< Double_t > TMatrixDColumn_const
TMatrixTDiag< Double_t > TMatrixDDiag
TMatrixTRow_const< Double_t > TMatrixDRow_const
TMatrixTDiag_const< Double_t > TMatrixDDiag_const
TMatrixTColumn< Double_t > TMatrixDColumn
TVectorT< Double_t > TVectorD
Int_t GetNrows() const override
TDecompBK & operator=(const TDecompBK &source)
Assignment operator.
TDecompBK()
Default constructor.
Bool_t Decompose() override
Matrix A is decomposed in components U and D so that A = U*D*U^T If the decomposition succeeds,...
Bool_t Solve(TVectorD &b) override
Solve Ax=b assuming the BK form of A is stored in fU . Solution returned in b.
virtual void SetMatrix(const TMatrixDSym &a)
Set the matrix to be decomposed, decomposition status is reset.
void Print(Option_t *opt="") const override
Print the class members.
TDecompBase & operator=(const TDecompBase &source)
Assignment operator.
TDecompBase()
Default constructor.
void Print(Option_t *opt="") const override
Print class members.
virtual TMatrixTBase< Element > & UnitMatrix()
Make a unit matrix (matrix need not be a square one).
const TMatrixTBase< Element > * GetMatrix() const
void Rank1Update(const TVectorT< Element > &vec, Element alpha=1.0)
Perform a rank 1 operation on the matrix: A += alpha * v * v^T.
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 > & Abs()
Take an absolute value of a vector, i.e. apply Abs() to each element.
Element * GetMatrixArray()
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Long64_t LocMax(Long64_t n, const T *a)
Returns index of array with the maximum element.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.