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);
65 for (
unsigned int j = 0; j < nrow; j++)
66 for (k = j; k < nrow; k++)
67 a(j, k) += (pp(j) *
q(k));
70 for (
unsigned int j = 0; j < nrow; j++)
71 for (
unsigned int k = j; k < nrow; k++)
72 a(j, k) *= (s(j) * s(k));
86 for (
unsigned int i = 0; i <
n; ++i) {
87 out += std::abs(arr[i]);
105void mndspr(
unsigned int n,
double alpha,
const double *
x,
double *ap)
121 if (
n == 0 || alpha == 0.) {
133 for (j = 1; j <= i__1; ++j) {
138 for (i__ = 1; i__ <= i__2; ++i__) {
139 ap[k] +=
x[i__] * temp;
148void Mndspmv(
unsigned int n,
double alpha,
const double *ap,
const double *
x,
double beta,
double *
y)
165 if ((
n == 0) || (alpha == 0. && beta == 1.)) {
179 for (i__ = 1; i__ <= i__1; ++i__) {
185 for (i__ = 1; i__ <= i__1; ++i__) {
186 y[i__] = beta *
y[i__];
199 for (j = 1; j <= i__1; ++j) {
200 temp1 = alpha *
x[j];
204 for (i__ = 1; i__ <= i__2; ++i__) {
205 y[i__] += temp1 * ap[k];
206 temp2 += ap[k] *
x[i__];
209 y[j] =
y[j] + temp1 * ap[kk + j - 1] + alpha * temp2;
215 :
fSize(0), fNRow(0), fData(nullptr)
220 fNRow = out.Obj().Obj().Obj().size();
224 Outer_prod(*
this, out.Obj().Obj().Obj(), out.f() * out.Obj().Obj().f() * out.Obj().Obj().f());
234 fNRow = out.Obj().Obj().Obj().size();
238 Outer_prod(*
this, out.Obj().Obj().Obj(), out.f() * out.Obj().Obj().f() * out.Obj().Obj().f());
242 tmp *=
double(out.f() * out.Obj().Obj().f() * out.Obj().Obj().f());
255void Mndaxpy(
unsigned int n,
double da,
const double *dx,
double *dy)
277 for (i__ = 1; i__ <= i__1; ++i__) {
278 dy[i__] += da * dx[i__];
286 for (i__ = mp1; i__ <= i__1; i__ += 4) {
287 dy[i__] += da * dx[i__];
288 dy[i__ + 1] += da * dx[i__ + 1];
289 dy[i__ + 2] += da * dx[i__ + 2];
290 dy[i__ + 3] += da * dx[i__ + 3];
304 double tmp = t.
Data()[0];
308 t.
Data()[0] = 1. / tmp;
319 return std::inner_product(
v1.Data(),
v1.Data() +
v1.size(),
v2.Data(), 0.0);
322int mneigen(
double *
a,
unsigned int ndima,
unsigned int n,
unsigned int mits,
double *work)
324 constexpr double precis = 1.e-6;
329 unsigned int a_dim1, a_offset, i__1, i__2, i__3;
333 double b, c__,
f, h__;
334 unsigned int i__, j, k,
l,
m = 0;
336 unsigned int i0, i1, j1, m1, n1;
337 double hh, gl, pr,
pt;
342 a_offset = 1 + a_dim1 * 1;
351 for (i1 = 2; i1 <= i__1; ++i1) {
353 f =
a[i__ + (i__ - 1) * a_dim1];
361 for (k = 1; k <= i__2; ++k) {
363 r__1 =
a[i__ + k * a_dim1];
369 h__ = gl + r__1 * r__1;
371 if (gl > (
double)1
e-35) {
383 if (
f >= (
double)0.) {
389 a[i__ + (i__ - 1) * a_dim1] =
f - gl;
392 for (j = 1; j <= i__2; ++j) {
393 a[j + i__ * a_dim1] =
a[i__ + j * a_dim1] / h__;
396 for (k = 1; k <= i__3; ++k) {
397 gl +=
a[j + k * a_dim1] *
a[i__ + k * a_dim1];
406 for (k = j1; k <= i__3; ++k) {
407 gl +=
a[k + j * a_dim1] *
a[i__ + k * a_dim1];
410 work[
n + j] = gl / h__;
411 f += gl *
a[j + i__ * a_dim1];
413 hh =
f / (h__ + h__);
415 for (j = 1; j <= i__2; ++j) {
416 f =
a[i__ + j * a_dim1];
417 gl = work[
n + j] - hh *
f;
420 for (k = 1; k <= i__3; ++k) {
421 a[j + k * a_dim1] =
a[j + k * a_dim1] -
f * work[
n + k] - gl *
a[i__ + k * a_dim1];
431 for (i__ = 1; i__ <= i__1; ++i__) {
434 if (work[i__] == (
double)0. ||
l == 0) {
439 for (j = 1; j <= i__3; ++j) {
442 for (k = 1; k <= i__2; ++k) {
443 gl +=
a[i__ + k * a_dim1] *
a[k + j * a_dim1];
446 for (k = 1; k <= i__2; ++k) {
447 a[k + j * a_dim1] -= gl *
a[k + i__ * a_dim1];
451 work[i__] =
a[i__ + i__ * a_dim1];
452 a[i__ + i__ * a_dim1] = (
double)1.;
459 for (j = 1; j <= i__2; ++j) {
460 a[i__ + j * a_dim1] = (
double)0.;
461 a[j + i__ * a_dim1] = (
double)0.;
468 for (i__ = 2; i__ <= i__1; ++i__) {
470 work[i0] = work[i0 + 1];
476 for (
l = 1;
l <= i__1; ++
l) {
478 h__ = precis * ((r__1 = work[
l], std::fabs(r__1)) + (r__2 = work[
n +
l], std::fabs(r__2)));
485 for (m1 =
l; m1 <= i__2; ++m1) {
488 if ((r__1 = work[
n +
m], std::fabs(r__1)) <=
b) {
504 pt = (work[
l + 1] - work[
l]) / (work[
n +
l] * (
double)2.);
505 r__ = std::sqrt(
pt *
pt + (
double)1.);
508 if (
pt < (
double)0.) {
512 h__ = work[
l] - work[
n +
l] / pr;
514 for (i__ =
l; i__ <= i__2; ++i__) {
524 for (i1 =
l; i1 <= i__2; ++i1) {
527 gl = c__ * work[
n + i__];
530 if (std::fabs(
pt) >= (r__1 = work[
n + i__], std::fabs(r__1))) {
534 c__ =
pt / work[
n + i__];
535 r__ = std::sqrt(c__ * c__ + (
double)1.);
536 work[
n + j] = s * work[
n + i__] * r__;
541 c__ = work[
n + i__] /
pt;
542 r__ = std::sqrt(c__ * c__ + (
double)1.);
543 work[
n + j] = s *
pt * r__;
547 pt = c__ * work[i__] - s * gl;
548 work[j] = h__ + s * (c__ * gl + s * work[i__]);
550 for (k = 1; k <= i__3; ++k) {
551 h__ =
a[k + j * a_dim1];
552 a[k + j * a_dim1] = s *
a[k + i__ * a_dim1] + c__ * h__;
553 a[k + i__ * a_dim1] = c__ *
a[k + i__ * a_dim1] - s * h__;
556 work[
n +
l] = s *
pt;
559 if ((r__1 = work[
n +
l], std::fabs(r__1)) >
b) {
567 for (i__ = 1; i__ <= i__1; ++i__) {
572 for (j = i1; j <= i__3; ++j) {
590 for (j = 1; j <= i__3; ++j) {
591 pt =
a[j + i__ * a_dim1];
592 a[j + i__ * a_dim1] =
a[j + k * a_dim1];
593 a[j + k * a_dim1] =
pt;
605 unsigned int nrow = mat.
Nrow();
610 for (
unsigned int i = 0; i < nrow; i++) {
611 for (
unsigned int j = 0; j <= i; j++) {
612 tmp(i + j * nrow) = mat(i, j);
613 tmp(i * nrow + j) = mat(i, j);
622 for (
unsigned int i = 0; i < nrow; i++) {
636 return std::inner_product(avec.
Data(), avec.
Data() + avec.
size(), tmp.
Data(), 0.0);
641 for (
unsigned int i = 0; i <
n; ++i) {
662 const int pr = os.precision(8);
663 const unsigned int nrow = matrix.
Nrow();
664 const unsigned int n = std::min(nrow,
static_cast<unsigned int>(
MnMatrix::MaxNP()));
665 for (
unsigned int i = 0; i < nrow; i++) {
676 for (
unsigned int j = 0; j < nrow; j++) {
695 const unsigned int nrow =
vec.size();
696 const unsigned int np = std::min(nrow,
static_cast<unsigned int>(
MnMatrix::MaxNP()));
698 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 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)