64 const Int_t nRows =
a.GetNrows();
65 const Int_t nCols =
a.GetNcols();
66 const Int_t rowLwb =
a.GetRowLwb();
67 const Int_t colLwb =
a.GetColLwb();
69 if (nRows != nCols || rowLwb != colLwb)
71 Error(
"TMatrixDEigen(TMatrixD &)",
"matrix should be square");
75 const Int_t rowUpb = rowLwb+nRows-1;
83 else ortho.
Use(nRows,work);
124 for (
m = low+1;
m <= high-1;
m++) {
130 for (i =
m; i <= high; i++) {
139 for (i = high; i >=
m; i--) {
141 pO[i] = pH[off_i+
m-1]/scale;
153 for (j =
m; j <
n; j++) {
155 for (i = high; i >=
m; i--) {
157 f += pO[i]*pH[off_i+j];
160 for (i =
m; i <= high; i++) {
162 pH[off_i+j] -=
f*pO[i];
166 for (i = 0; i <= high; i++) {
169 for (j = high; j >=
m; j--)
170 f += pO[j]*pH[off_i+j];
172 for (j =
m; j <= high; j++)
173 pH[off_i+j] -=
f*pO[j];
176 pH[off_m+
m-1] = scale*
g;
182 for (i = 0; i <
n; i++) {
184 for (j = 0; j <
n; j++)
185 pV[off_i+j] = (i == j ? 1.0 : 0.0);
188 for (
m = high-1;
m >= low+1;
m--) {
190 if (pH[off_m+
m-1] != 0.0) {
191 for (i =
m+1; i <= high; i++) {
193 pO[i] = pH[off_i+
m-1];
195 for (j =
m; j <= high; j++) {
197 for (i =
m; i <= high; i++) {
199 g += pO[i]*pV[off_i+j];
202 g = (
g/pO[
m])/pH[off_m+
m-1];
203 for (i =
m; i <= high; i++) {
205 pV[off_i+j] +=
g*pO[i];
241 const Int_t nn =
v.GetNrows();
244 const Int_t high = nn-1;
258 for (i = 0; i < nn; i++) {
259 const Int_t off_i = i*nn;
260 if ((i < low) || (i > high)) {
273 const Int_t off_n1 = (
n-1)*nn;
279 const Int_t off_l1 = (
l-1)*nn;
293 pH[off_n+
n] = pH[off_n+
n]+exshift;
301 }
else if (
l ==
n-1) {
302 w = pH[off_n+
n-1]*pH[off_n1+
n];
303 p = (pH[off_n1+
n-1]-pH[off_n+
n])/2.0;
306 pH[off_n+
n] = pH[off_n+
n]+exshift;
307 pH[off_n1+
n-1] = pH[off_n1+
n-1]+exshift;
333 for (j =
n-1; j < nn; j++) {
335 pH[off_n1+j] =
q*z+
p*pH[off_n+j];
336 pH[off_n+j] =
q*pH[off_n+j]-
p*z;
341 for (i = 0; i <=
n; i++) {
342 const Int_t off_i = i*nn;
344 pH[off_i+
n-1] =
q*z+
p*pH[off_i+
n];
345 pH[off_i+
n] =
q*pH[off_i+
n]-
p*z;
350 for (i = low; i <= high; i++) {
351 const Int_t off_i = i*nn;
353 pV[off_i+
n-1] =
q*z+
p*pV[off_i+
n];
354 pV[off_i+
n] =
q*pV[off_i+
n]-
p*z;
379 w = pH[off_n+
n-1]*pH[off_n1+
n];
386 for (i = low; i <=
n; i++) {
387 const Int_t off_i = i*nn;
404 s =
x-
w/((
y-
x)/2.0+s);
405 for (i = low; i <=
n; i++) {
406 const Int_t off_i = i*nn;
415 Error(
"MakeSchurr",
"too many iterations");
424 const Int_t off_m_1 = (
m-1)*nn;
425 const Int_t off_m1 = (
m+1)*nn;
426 const Int_t off_m2 = (
m+2)*nn;
430 p = (
r*s-
w)/pH[off_m1+
m]+pH[off_m+
m+1];
431 q = pH[off_m1+
m+1]-z-
r-s;
446 for (i =
m+2; i <=
n; i++) {
447 const Int_t off_i = i*nn;
455 for (k =
m; k <=
n-1; k++) {
456 const Int_t off_k = k*nn;
457 const Int_t off_k1 = (k+1)*nn;
458 const Int_t off_k2 = (k+2)*nn;
459 const Int_t notlast = (k !=
n-1);
463 r = (notlast ? pH[off_k2+k-1] : 0.0);
479 pH[off_k+k-1] = -s*
x;
481 pH[off_k+k-1] = -pH[off_k+k-1];
491 for (j = k; j < nn; j++) {
492 p = pH[off_k+j]+
q*pH[off_k1+j];
494 p =
p+
r*pH[off_k2+j];
495 pH[off_k2+j] = pH[off_k2+j]-
p*z;
497 pH[off_k+j] = pH[off_k+j]-
p*
x;
498 pH[off_k1+j] = pH[off_k1+j]-
p*
y;
504 const Int_t off_i = i*nn;
505 p =
x*pH[off_i+k]+
y*pH[off_i+k+1];
507 p =
p+z*pH[off_i+k+2];
508 pH[off_i+k+2] = pH[off_i+k+2]-
p*
r;
510 pH[off_i+k] = pH[off_i+k]-
p;
511 pH[off_i+k+1] = pH[off_i+k+1]-
p*
q;
516 for (i = low; i <= high; i++) {
517 const Int_t off_i = i*nn;
518 p =
x*pV[off_i+k]+
y*pV[off_i+k+1];
520 p =
p+z*pV[off_i+k+2];
521 pV[off_i+k+2] = pV[off_i+k+2]-
p*
r;
523 pV[off_i+k] = pV[off_i+k]-
p;
524 pV[off_i+k+1] = pV[off_i+k+1]-
p*
q;
536 for (
n = nn-1;
n >= 0;
n--) {
546 for (i =
n-1; i >= 0; i--) {
547 const Int_t off_i = i*nn;
548 const Int_t off_i1 = (i+1)*nn;
551 for (j =
l; j <=
n; j++) {
552 const Int_t off_j = j*nn;
553 r =
r+pH[off_i+j]*pH[off_j+
n];
564 pH[off_i+
n] = -
r/(eps*norm);
571 q = (pD[i]-
p)*(pD[i]-
p)+pE[i]*pE[i];
575 pH[i+1+
n] = (-
r-
w*t)/
x;
577 pH[i+1+
n] = (-s-
y*t)/z;
584 for (j = i; j <=
n; j++) {
585 const Int_t off_j = j*nn;
586 pH[off_j+
n] = pH[off_j+
n]/t;
596 const Int_t off_n1 = (
n-1)*nn;
601 pH[off_n1+
n-1] =
q/pH[off_n+
n-1];
602 pH[off_n1+
n] = -(pH[off_n+
n]-
p)/pH[off_n+
n-1];
604 cdiv(0.0,-pH[off_n1+
n],pH[off_n1+
n-1]-
p,
q);
610 for (i =
n-2; i >= 0; i--) {
611 const Int_t off_i = i*nn;
612 const Int_t off_i1 = (i+1)*nn;
615 for (j =
l; j <=
n; j++) {
616 const Int_t off_j = j*nn;
617 ra += pH[off_i+j]*pH[off_j+
n-1];
618 sa += pH[off_i+j]*pH[off_j+
n];
640 if ((vr == 0.0) && (vi == 0.0)) {
648 pH[off_i1+
n-1] = (-ra-
w*pH[off_i+
n-1]+
q*pH[off_i+
n])/
x;
649 pH[off_i1+
n] = (-sa-
w*pH[off_i+
n]-
q*pH[off_i+
n-1])/
x;
651 cdiv(-
r-
y*pH[off_i+
n-1],-s-
y*pH[off_i+
n],z,
q);
661 for (j = i; j <=
n; j++) {
662 const Int_t off_j = j*nn;
663 pH[off_j+
n-1] = pH[off_j+
n-1]/t;
664 pH[off_j+
n] = pH[off_j+
n]/t;
674 for (i = 0; i < nn; i++) {
675 if (i < low || i > high) {
676 const Int_t off_i = i*nn;
677 for (j = i; j < nn; j++)
678 pV[off_i+j] = pH[off_i+j];
684 for (j = nn-1; j >= low; j--) {
685 for (i = low; i <= high; i++) {
686 const Int_t off_i = i*nn;
689 const Int_t off_k = k*nn;
690 z = z+pV[off_i+k]*pH[off_k+j];
712 Double_t eps = std::numeric_limits<Double_t>::epsilon();
714 for (
Int_t i = 0; i <
n-1; i++) {
716 Double_t norm = pD[i]*pD[i]+pE[i]*pE[i];
718 for (j = i+1; j <
n; j++) {
719 const Double_t norm_new = pD[j]*pD[j]+pE[j]*pE[j];
720 if (norm_new > norm) {
724 if (std::fabs(norm_new - norm) <= eps * norm_new) {
725 if ((std::fabs(pD[i] - pD[j]) <= eps) && (std::fabs(pE[i] + pE[j]) <= eps)) {
741 for (j = 0; j <
n; j++) {
744 pV[off_j+i] = pV[off_j+k];
756 if (
this != &source) {
810 const Int_t rowUpb = rowLwb+nrows-1;
812 TMatrixD mD(rowLwb,rowUpb,rowLwb,rowUpb);
818 for (
Int_t i = 0; i < nrows; i++) {
819 const Int_t off_i = i*nrows;
820 for (
Int_t j = 0; j < nrows; j++)
824 pD[off_i+i+1] = pe[i];
825 }
else if (pe[i] < 0) {
826 pD[off_i+i-1] = pe[i];
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
static void cdiv(Double_t xr, Double_t xi, Double_t yr, Double_t yi)
static Double_t gCdivr
Complex scalar division.
static void MakeHessenBerg(TMatrixD &v, TVectorD &ortho, TMatrixD &H)
Nonsymmetric reduction to Hessenberg form.
const TMatrixD GetEigenValues() const
Computes the block diagonal eigenvalue matrix.
TMatrixDEigen & operator=(const TMatrixDEigen &source)
Assignment operator.
static void Sort(TMatrixD &v, TVectorD &d, TVectorD &e)
Sort eigenvalues and corresponding vectors in descending order of Re^2+Im^2 of the complex eigenvalue...
static void MakeSchurr(TMatrixD &v, TVectorD &d, TVectorD &e, TMatrixD &H)
Nonsymmetric reduction from Hessenberg to real Schur form.
const Element * GetMatrixArray() const override
TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1) override
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
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].
Element * GetMatrixArray()
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t Sqrt(Double_t x)
Returns the square root of x.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.