27 unsigned int nrow =
a.Nrow();
32 for (
unsigned int i = 0; i < nrow; i++) {
36 s(i) = 1. / std::sqrt(si);
39 for (
unsigned int i = 0; i < nrow; i++)
40 for (
unsigned int j = i; j < nrow; j++)
41 a(i, j) *= (s(i) * s(j));
43 for (
unsigned i = 0; i < nrow; i++) {
50 unsigned int kp1 = k + 1;
52 for (
unsigned int j = 0; j < k; j++) {
54 q(j) =
a(j, k) *
q(k);
59 for (
unsigned int j = kp1; j < nrow; j++) {
61 q(j) = -
a(k, j) *
q(k);
66 double *
data =
a.Data();
67 for (k = 0; k < nrow; k++) {
68 double *col =
data + k * (k + 1) / 2;
69 for (
unsigned int j = 0; j <= k; j++)
70 col[j] += (pp(j) *
q(k));
74 for (
unsigned int j = 0; j < nrow; j++)
75 for (
unsigned int k = j; k < nrow; k++)
76 a(j, k) *= (s(j) * s(k));
90 for (
unsigned int i = 0; i <
n; ++i) {
91 out += std::abs(arr[i]);
109void mndspr(
unsigned int n,
double alpha,
const double *
x,
double *ap)
125 if (
n == 0 || alpha == 0.) {
137 for (j = 1; j <= i__1; ++j) {
142 for (i__ = 1; i__ <= i__2; ++i__) {
143 ap[k] +=
x[i__] * temp;
152void Mndspmv(
unsigned int n,
double alpha,
const double *ap,
const double *
x,
double beta,
double *
y)
169 if ((
n == 0) || (alpha == 0. && beta == 1.)) {
183 for (i__ = 1; i__ <= i__1; ++i__) {
189 for (i__ = 1; i__ <= i__1; ++i__) {
190 y[i__] = beta *
y[i__];
203 for (j = 1; j <= i__1; ++j) {
204 temp1 = alpha *
x[j];
208 for (i__ = 1; i__ <= i__2; ++i__) {
209 y[i__] += temp1 * ap[k];
210 temp2 += ap[k] *
x[i__];
213 y[j] =
y[j] + temp1 * ap[kk + j - 1] + alpha * temp2;
219 :
fSize(0), fNRow(0), fData(nullptr)
224 fNRow = out.Obj().Obj().Obj().size();
228 Outer_prod(*
this, out.Obj().Obj().Obj(), out.f() * out.Obj().Obj().f() * out.Obj().Obj().f());
238 fNRow = out.Obj().Obj().Obj().size();
242 Outer_prod(*
this, out.Obj().Obj().Obj(), out.f() * out.Obj().Obj().f() * out.Obj().Obj().f());
246 tmp *=
double(out.f() * out.Obj().Obj().f() * out.Obj().Obj().f());
259void Mndaxpy(
unsigned int n,
double da,
const double *dx,
double *dy)
281 for (i__ = 1; i__ <= i__1; ++i__) {
282 dy[i__] += da * dx[i__];
290 for (i__ = mp1; i__ <= i__1; i__ += 4) {
291 dy[i__] += da * dx[i__];
292 dy[i__ + 1] += da * dx[i__ + 1];
293 dy[i__ + 2] += da * dx[i__ + 2];
294 dy[i__ + 3] += da * dx[i__ + 3];
308 double tmp = t.
Data()[0];
312 t.
Data()[0] = 1. / tmp;
323 return std::inner_product(
v1.Data(),
v1.Data() +
v1.size(),
v2.Data(), 0.0);
326int mneigen(
double *
a,
unsigned int ndima,
unsigned int n,
unsigned int mits,
double *work)
328 constexpr double precis = 1.e-6;
333 unsigned int a_dim1, a_offset, i__1, i__2, i__3;
337 double b, c__,
f, h__;
338 unsigned int i__, j, k,
l,
m = 0;
340 unsigned int i0, i1, j1, m1, n1;
341 double hh, gl, pr,
pt;
346 a_offset = 1 + a_dim1 * 1;
355 for (i1 = 2; i1 <= i__1; ++i1) {
357 f =
a[i__ + (i__ - 1) * a_dim1];
365 for (k = 1; k <= i__2; ++k) {
367 r__1 =
a[i__ + k * a_dim1];
373 h__ = gl + r__1 * r__1;
375 if (gl > (
double)1
e-35) {
387 if (
f >= (
double)0.) {
393 a[i__ + (i__ - 1) * a_dim1] =
f - gl;
396 for (j = 1; j <= i__2; ++j) {
397 a[j + i__ * a_dim1] =
a[i__ + j * a_dim1] / h__;
400 for (k = 1; k <= i__3; ++k) {
401 gl +=
a[j + k * a_dim1] *
a[i__ + k * a_dim1];
410 for (k = j1; k <= i__3; ++k) {
411 gl +=
a[k + j * a_dim1] *
a[i__ + k * a_dim1];
414 work[
n + j] = gl / h__;
415 f += gl *
a[j + i__ * a_dim1];
417 hh =
f / (h__ + h__);
419 for (j = 1; j <= i__2; ++j) {
420 f =
a[i__ + j * a_dim1];
421 gl = work[
n + j] - hh *
f;
424 for (k = 1; k <= i__3; ++k) {
425 a[j + k * a_dim1] =
a[j + k * a_dim1] -
f * work[
n + k] - gl *
a[i__ + k * a_dim1];
435 for (i__ = 1; i__ <= i__1; ++i__) {
438 if (work[i__] == (
double)0. ||
l == 0) {
443 for (j = 1; j <= i__3; ++j) {
446 for (k = 1; k <= i__2; ++k) {
447 gl +=
a[i__ + k * a_dim1] *
a[k + j * a_dim1];
450 for (k = 1; k <= i__2; ++k) {
451 a[k + j * a_dim1] -= gl *
a[k + i__ * a_dim1];
455 work[i__] =
a[i__ + i__ * a_dim1];
456 a[i__ + i__ * a_dim1] = (
double)1.;
463 for (j = 1; j <= i__2; ++j) {
464 a[i__ + j * a_dim1] = (
double)0.;
465 a[j + i__ * a_dim1] = (
double)0.;
472 for (i__ = 2; i__ <= i__1; ++i__) {
474 work[i0] = work[i0 + 1];
480 for (
l = 1;
l <= i__1; ++
l) {
482 h__ = precis * ((r__1 = work[
l], std::fabs(r__1)) + (r__2 = work[
n +
l], std::fabs(r__2)));
489 for (m1 =
l; m1 <= i__2; ++m1) {
492 if ((r__1 = work[
n +
m], std::fabs(r__1)) <=
b) {
508 pt = (work[
l + 1] - work[
l]) / (work[
n +
l] * (
double)2.);
509 r__ = std::sqrt(
pt *
pt + (
double)1.);
512 if (
pt < (
double)0.) {
516 h__ = work[
l] - work[
n +
l] / pr;
518 for (i__ =
l; i__ <= i__2; ++i__) {
528 for (i1 =
l; i1 <= i__2; ++i1) {
531 gl = c__ * work[
n + i__];
534 if (std::fabs(
pt) >= (r__1 = work[
n + i__], std::fabs(r__1))) {
538 c__ =
pt / work[
n + i__];
539 r__ = std::sqrt(c__ * c__ + (
double)1.);
540 work[
n + j] = s * work[
n + i__] * r__;
545 c__ = work[
n + i__] /
pt;
546 r__ = std::sqrt(c__ * c__ + (
double)1.);
547 work[
n + j] = s *
pt * r__;
551 pt = c__ * work[i__] - s * gl;
552 work[j] = h__ + s * (c__ * gl + s * work[i__]);
554 for (k = 1; k <= i__3; ++k) {
555 h__ =
a[k + j * a_dim1];
556 a[k + j * a_dim1] = s *
a[k + i__ * a_dim1] + c__ * h__;
557 a[k + i__ * a_dim1] = c__ *
a[k + i__ * a_dim1] - s * h__;
560 work[
n +
l] = s *
pt;
563 if ((r__1 = work[
n +
l], std::fabs(r__1)) >
b) {
571 for (i__ = 1; i__ <= i__1; ++i__) {
576 for (j = i1; j <= i__3; ++j) {
594 for (j = 1; j <= i__3; ++j) {
595 pt =
a[j + i__ * a_dim1];
596 a[j + i__ * a_dim1] =
a[j + k * a_dim1];
597 a[j + k * a_dim1] =
pt;
609 unsigned int nrow = mat.
Nrow();
614 for (
unsigned int i = 0; i < nrow; i++) {
615 for (
unsigned int j = 0; j <= i; j++) {
616 tmp(i + j * nrow) = mat(i, j);
617 tmp(i * nrow + j) = mat(i, j);
626 for (
unsigned int i = 0; i < nrow; i++) {
640 return std::inner_product(avec.
Data(), avec.
Data() + avec.
size(), tmp.
Data(), 0.0);
645 for (
unsigned int i = 0; i <
n; ++i) {
666 const int pr = os.precision(8);
667 const unsigned int nrow = matrix.
Nrow();
668 const unsigned int n = std::min(nrow,
static_cast<unsigned int>(
MnMatrix::MaxNP()));
669 for (
unsigned int i = 0; i < nrow; i++) {
680 for (
unsigned int j = 0; j < nrow; j++) {
699 const unsigned int nrow =
vec.size();
700 const unsigned int np = std::min(nrow,
static_cast<unsigned int>(
MnMatrix::MaxNP()));
702 for (
unsigned int i = 0; i <
np; i++) {
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Class describing a symmetric matrix of size n.
const double * Data() const
LASymMatrix & operator=(const LASymMatrix &v)
LASymMatrix(unsigned int n)
unsigned int Nrow() const
unsigned int size() const
const double * Data() const
unsigned int size() const
static StackAllocator & Get()
void * Allocate(size_t nBytes)
void Mndaxpy(unsigned int, double, const double *, double *)
LAVector eigenvalues(const LASymMatrix &)
int Invert(LASymMatrix &)
void Mndscal(unsigned int, double, double *)
void Mndspmv(unsigned int, double, const double *, const double *, double, double *)
std::ostream & operator<<(std::ostream &, const LAVector &)
double sum_of_elements(const LASymMatrix &)
double similarity(const LAVector &, const LASymMatrix &)
int mneigen(double *a, unsigned int ndima, unsigned int n, unsigned int mits, double *work)
void Outer_prod(LASymMatrix &, const LAVector &, double f=1.)
double inner_product(const LAVector &, const LAVector &)
void mndspr(unsigned int n, double alpha, const double *x, double *ap)