65 #define TCL_MXMAD(n_,a,b,c,i,j,k) \
67 int l, m, n, ia, ic, ib, ja, jb, iia, iib, ioa, iob; \
74 const int iandj1[] = {2, 2 , 2 , 2 , 1 , 1 , 1 , 1 , 3 , 3 , 3 , 3 }; \
75 const int iandj2[] = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 }; \
76 int n1 = iandj1[n_]; \
77 int n2 = iandj2[n_]; \
78 if (i == 0 || k == 0) return 0; \
81 case 1: iia = 1; ioa = j; iib = k; iob = 1; break; \
82 case 2: iia = 1; ioa = j; iib = 1; iob = j; break; \
83 case 3: iia = i; ioa = 1; iib = k; iob = 1; break; \
84 case 4: iia = i; ioa = 1; iib = 1; iob = j; break; \
85 default: iia = ioa = iib = iob = 0; assert(iob); \
89 for (l = 1; l <= i; ++l) { \
91 for (m = 1; m <= k; ++m,++ic) { \
93 case 1: c[ic] = 0.; break; \
94 case 3: c[ic] = -c[ic]; break; \
96 if (j == 0) continue; \
99 for (n = 1; n <= j; ++n, ja+=iia, jb+=iib) \
100 cic += a[ja] * b[jb]; \
109 float *
TCL::mxmad_0_(
int n_,
const float *a,
const float *b,
float *
c,
int i,
int j,
int k)
117 double *
TCL::mxmad_0_(
int n_,
const double *a,
const double *b,
double *
c,
int i,
int j,
int k)
130 #define TCL_MXMLRT( n__, a, b, c, ni,nj) \
131 if (ni <= 0 || nj <= 0) return 0; \
133 int ia, ib, ic, ja, kc, ii, jj, kj, ki, ia1, ib1, ic1, ja1; \
134 int ipa = 1; int jpa = nj; \
135 if (n__ == 1) { ipa = ni; jpa = 1; } \
140 for (ii = 1; ii <= ni; ++ii, ic1+=ni, ia1+=jpa) { \
142 for (kc = 1; kc <= ni; ++kc,ic++) c[ic] = 0.; \
144 for (jj = 1; jj <= nj; ++jj,++ib1,ja1 += ipa) { \
145 ib = ib1; ia = ia1; \
147 for (kj = 1;kj <= nj;++kj,ia+=ipa,ib += nj) \
148 x += a[ia] * b[ib]; \
149 ja = ja1; ic = ic1; \
150 for (ki = 1; ki <= ni; ++ki,++ic,ja += jpa) \
151 c[ic] += x * a[ja]; \
161 float *
TCL::mxmlrt_0_(
int n__,
const float *a,
const float *b,
float *
c,
int ni,
int nj)
195 double *
TCL::mxmlrt_0_(
int n__,
const double *a,
const double *b,
double *
c,
int ni,
int nj)
209 #define TCL_MXTRP(a, b, i, j) \
210 if (i == 0 || j == 0) return 0; \
213 for (int k = 1; k <= j; ++k) \
215 for (int l = 1; l <= i; ++l,ia += j,++ib) b[ib] = a[ia]; }
261 #define TCL_TRAAT(a, s, m, n) \
263 int ipiv, i, j, ipivn, ia, is, iat; \
267 for (i = 1; i <= m; ++i) { \
271 for (j = 1; j <= i; ++j) { \
276 sum += a[ia] * a[iat]; \
277 } while (ia < ipivn); \
294 float *
TCL::traat(
const float *a,
float *s,
int m,
int n)
312 double *
TCL::traat(
const double *a,
double *s,
int m,
int n)
324 #define TCL_TRAL(a, u, b, m, n) \
325 int indu, i, j, k, ia, ib, iu; \
329 for (i = 1; i <= m; ++i) { \
331 for (j = 1; j <= n; ++j) { \
336 for (k = j; k <= n; ++k) {\
337 sum += a[ia] * u[iu]; \
354 float *
TCL::tral(
const float *a,
const float *u,
float *b,
int m,
int n)
371 double *
TCL::tral(
const double *a,
const double *u,
double *b,
int m,
int n)
385 #define TCL_TRALT(a, u, b, m, n) \
386 int indu, j, k, ia, ib, iu; \
390 indu = (n * n + n) / 2; \
393 for (j = 1; j <= n; ++j) { \
396 for (k = j; k <= n; ++k) {\
397 sum += a[ia] * u[iu]; \
413 float *
TCL::tralt(
const float *a,
const float *u,
float *b,
int m,
int n)
430 double *
TCL::
tralt(const
double *a, const
double *u,
double *b,
int m,
int n)
444 #define TCL_TRAS(a, s, b, m, n) \
445 int inds, i__, j, k, ia, ib, is; \
448 ib = 0; inds = 0; i__ = 0; \
453 for (j = 1; j <= m; ++j) { \
458 if (k > i__) is += k; \
461 sum += a[ia] * s[is]; \
478 float *
TCL::tras(
const float *a,
const float *s,
float *b,
int m,
int n)
495 double *
TCL::
tras(const
double *a, const
double *s,
double *b,
int m,
int n)
510 #define TCL_TRASAT(a, s, r__, m, n) \
512 int ia, mn, ir, is, iaa; \
515 imax = (m * m + m) / 2; \
516 vzero(&r__[1], imax); \
527 if (k > i__) is += k; \
530 sum += s[is] * a[ia]; \
536 r__[ir] += sum * a[iaa];\
538 } while (iaa <= ia); \
551 float *
TCL::trasat(
const float *a,
const float *s,
float *r__,
int m,
int n)
568 double *
TCL::
trasat(const
double *a, const
double *s,
double *r__,
int m,
int n)
585 float *
TCL::
trasat(const
double *a, const
float *s,
float *r__,
int m,
int n)
603 float *
TCL::trata(
const float *a,
float *r__,
int m,
int n)
611 int i__, j, ia, mn, ir, iat;
621 for (i__ = 1; i__ <=
m; ++i__) {
622 for (j = 1; j <= i__; ++j) {
627 sum += a[ia] * a[iat];
641 float *
TCL::trats(
const float *a,
const float *s,
float *b,
int m,
int n)
649 int inds, i__, j, k, ia, ib, is;
659 ib = 0; inds = 0; i__ = 0;
664 for (j = 1; j <=
m; ++j) {
671 if (k > i__) is += k;
673 sum += a[ia] * s[is];
689 float *
TCL::tratsa(
const float *a,
const float *s,
float *r__,
int m,
int n)
699 int ia, ir, is, iaa, ind;
710 imax = (m * m +
m) / 2;
711 vzero(&r__[1], imax);
719 for (j = 1; j <=
m; ++j) {
726 if (k > i__) is += k;
728 sum += s[is] * a[ia];
734 for (k = 1; k <= j; ++k) {
737 r__[ir] += sum * a[iaa];
748 float *
TCL::trchlu(
const float *a,
float *b,
int n)
756 int ipiv, kpiv, i__, j;
780 for (j = i__; j <=
n; ++j) {
782 if (i__ == 1)
goto L40;
783 if (r__ == 0.)
goto L42;
788 sum += b[kd] * b[
id];
795 if (j != i__) b[kpiv] = sum * r__;
799 if (r__ > 0.) r__ = 1. / dc;
811 float *
TCL::trchul(
const float *a,
float *b,
int n)
835 kpiv = (n * n +
n) / 2;
844 if (i__ == n)
goto L40;
845 if (r__ == 0.)
goto L42;
854 sum += b[
id] * b[kd];
860 if (kpiv < ipiv) b[kpiv] = sum * r__;
864 if (r__ > 0.) r__ = 1. / dc;
867 }
while (kpiv > ipiv - i__);
882 float *
TCL::trinv(
const float *t,
float *s,
int n)
889 int lhor, ipiv, lver, j;
899 mx = (n * n +
n) / 2;
905 if (t[ipiv] > 0.) r__ = 1. / t[ipiv];
910 while (ind != ipiv) {
920 sum += t[lhor] * s[lver];
922 }
while (lhor < ind);
939 float *
TCL::trla(
const float *u,
const float *a,
float *b,
int m,
int n)
941 int ipiv, ia, ib, iu;
958 ipiv = (m * m +
m) / 2;
967 sum += a[ia] * u[iu];
974 }
while (ia > 1 - n);
986 float *
TCL::trlta(
const float *u,
const float *a,
float *b,
int m,
int n)
988 int ipiv, mxpn, i__, nTep, ia, ib, iu, mx;
1022 sum += a[ia] * u[iu];
1029 }
while (ia < mxpn);
1043 float *
TCL::trpck(
const float *s,
float *u,
int n)
1049 int i__, ia, ind, ipiv;
1059 for (i__ = 1; i__ <=
n; ++i__) {
1065 }
while (ind < ipiv);
1079 float *
TCL::trqsq(
const float *q,
const float *s,
float *r__,
int m)
1086 int indq, inds, imax, i__, j, k,
l;
1087 int iq, ir, is, iqq;
1094 imax = (m * m +
m) / 2;
1095 vzero(&r__[1], imax);
1113 if (k > i__) is += k;
1119 sum += s[is] * q[
iq];
1127 if (l > i__) iqq +=
l;
1129 r__[ir] += q[iqq] * sum;
1147 float *
TCL::trsa(
const float *s,
const float *a,
float *b,
int m,
int n)
1154 int inds, i__, j, k, ia, ib, is;
1168 for (j = 1; j <=
n; ++j) {
1175 if (k > i__) is += k;
1177 sum += s[is] * a[ia];
1197 float *
TCL::trsinv(
const float *g,
float *gi,
int n)
1207 return trsmul(gi, gi, n);
1216 float *
TCL::trsmlu(
const float *u,
float *s,
int n)
1224 int lhor, lver, i__, k,
l, ind;
1231 ind = (n * n +
n) / 2;
1233 for (i__ = 1; i__ <=
n; ++i__) {
1236 for (k = i__; k <=
n; ++k,--ind) {
1237 lhor = ind; sum = 0.;
1238 for (l = k; l <=
n; ++
l,--lver,--lhor)
1239 sum += u[lver] * u[lhor];
1253 float *
TCL::trsmul(
const float *g,
float *gi,
int n)
1261 int lhor, lver, lpiv, i__, j, k, ind;
1270 for (i__ = 1; i__ <=
n; ++i__) {
1272 for (j = 1; j <= i__; ++j,++ind) {
1276 for (k = i__; k <=
n; lhor += k,lver += k,++k)
1277 sum += g[lver] * g[lhor];
1291 float *
TCL::trupck(
const float *u,
float *s,
int m)
1299 int i__, im, is, iu, iv, ih, m2;
1341 float *
TCL::trsat(
const float *s,
const float *a,
float *b,
int m,
int n)
1350 int inds, i__, j, k, ia, ib, is;
1370 for (j = 1; j <=
n; ++j) {
1376 if (k > i__) is += k;
1379 sum += s[is] * a[ia];
1396 double *
TCL::trata(
const double *a,
double *r__,
int m,
int n)
1405 int i__, j, ia, mn, ir, iat;
1420 for (i__ = 1; i__ <=
m; ++i__) {
1422 for (j = 1; j <= i__; ++j) {
1428 sum += a[ia] * a[iat];
1442 double *
TCL::trats(
const double *a,
const double *s,
double *b,
int m,
int n)
1450 int inds, i__, j, k, ia, ib, is;
1461 ib = 0; inds = 0; i__ = 0;
1467 for (j = 1; j <=
m; ++j) {
1474 if (k > i__) is += k;
1476 sum += a[ia] * s[is];
1492 double *
TCL::tratsa(
const double *a,
const double *s,
double *r__,
int m,
int n)
1500 int imax, i__, j, k;
1501 int ia, ir, is, iaa, ind;
1512 imax = (m * m +
m) / 2;
1513 vzero(&r__[1], imax);
1521 for (j = 1; j <=
m; ++j) {
1528 if (k > i__) is += k;
1530 sum += s[is] * a[ia];
1536 for (k = 1; k <= j; ++k) {
1539 r__[ir] += sum * a[iaa];
1552 double *
TCL::trchlu(
const double *a,
double *b,
int n)
1559 int ipiv, kpiv, i__, j;
1583 for (j = i__; j <=
n; ++j) {
1585 if (i__ == 1)
goto L40;
1586 if (r__ == 0.)
goto L42;
1587 id = ipiv - i__ + 1;
1588 kd = kpiv - i__ + 1;
1591 sum += b[kd] * b[
id];
1593 }
while (
id < ipiv);
1596 sum = a[kpiv] - sum;
1598 if (j != i__) b[kpiv] = sum * r__;
1602 if (r__ > 0.) r__ = (
double)1. / dc;
1614 double *
TCL::trchul(
const double *a,
double *b,
int n)
1622 int ipiv, kpiv, i__;
1638 kpiv = (n * n +
n) / 2;
1647 if (i__ == n)
goto L40;
1648 if (r__ == (
double)0.)
goto L42;
1657 sum += b[
id] * b[kd];
1661 sum = a[kpiv] - sum;
1663 if (kpiv < ipiv) b[kpiv] = sum * r__;
1667 if (r__ > (
double)0.) r__ = (
double)1. / dc;
1670 }
while (kpiv > ipiv - i__);
1685 double *
TCL::trinv(
const double *t,
double *s,
int n)
1691 int lhor, ipiv, lver, j;
1700 mx = (n * n +
n) / 2;
1706 if (t[ipiv] > 0.) r__ = (
double)1. / t[ipiv];
1711 while (ind != ipiv) {
1721 sum += t[lhor] * s[lver];
1723 }
while (lhor < ind);
1725 s[ind] = -sum * r__;
1745 double *
TCL::trla(
const double *u,
const double *a,
double *b,
int m,
int n)
1751 int ipiv, ia, ib, iu;
1759 ipiv = (m * m +
m) / 2;
1768 sum += a[ia] * u[iu];
1775 }
while (ia > 1 - n);
1789 double *
TCL::trlta(
const double *u,
const double *a,
double *b,
int m,
int n)
1796 int ipiv, mxpn, i__, nTep, ia, ib, iu, mx;
1821 sum += a[ia] * u[iu];
1828 }
while (ia < mxpn);
1841 double *
TCL::trpck(
const double *s,
double *u,
int n)
1847 int i__, ia, ind, ipiv;
1857 for (i__ = 1; i__ <=
n; ++i__) {
1863 }
while (ind < ipiv);
1876 double *
TCL::trqsq(
const double *q,
const double *s,
double *r__,
int m)
1883 int indq, inds, imax, i__, j, k,
l;
1884 int iq, ir, is, iqq;
1891 imax = (m * m +
m) / 2;
1892 vzero(&r__[1], imax);
1910 if (k > i__) is += k;
1916 sum += s[is] * q[
iq];
1924 if (l > i__) iqq +=
l;
1926 r__[ir] += q[iqq] * sum;
1943 double *
TCL::trsa(
const double *s,
const double *a,
double *b,
int m,
int n)
1950 int inds, i__, j, k, ia, ib, is;
1964 for (j = 1; j <=
n; ++j) {
1971 if (k > i__) is += k;
1973 sum += s[is] * a[ia];
1992 double *
TCL::trsinv(
const double *g,
double *gi,
int n)
2013 double *
TCL::trsmlu(
const double *u,
double *s,
int n)
2021 int lhor, lver, i__, k,
l, ind;
2028 ind = (n * n +
n) / 2;
2030 for (i__ = 1; i__ <=
n; ++i__) {
2033 for (k = i__; k <=
n; ++k,--ind) {
2034 lhor = ind; sum = 0.;
2035 for (l = k; l <=
n; ++
l,--lver,--lhor)
2036 sum += u[lver] * u[lhor];
2050 double *
TCL::trsmul(
const double *g,
double *gi,
int n)
2058 int lhor, lver, lpiv, i__, j, k, ind;
2067 for (i__ = 1; i__ <=
n; ++i__) {
2069 for (j = 1; j <= i__; ++j,++ind) {
2073 for (k = i__; k <=
n;lhor += k,lver += k,++k)
2074 sum += g[lver] * g[lhor];
2088 double *
TCL::trupck(
const double *u,
double *s,
int m)
2096 int i__, im, is, iu, iv, ih, m2;
2140 double *
TCL::trsat(
const double *s,
const double *a,
double *b,
int m,
int n)
2148 int inds, i__, j, k, ia, ib, is;
2163 for (j = 1; j <=
n; ++j) {
2169 if (k > i__) is += k;
2172 sum += s[is] * a[ia];
2197 float *
TCL::trsequ(
float *smx,
int m,
float *b,
int n)
2199 float *mem =
new float[(m*(m+1))/2+
m];
2206 for (
int i=0;i<
n;i++) {
2224 double *
TCL::trsequ(
double *smx,
int m,
double *b,
int n)
2226 double *mem =
new double[(m*(m+1))/2+
m];
2233 for (
int i=0;i<
n;i++) {
static float * trla(const float *u, const float *a, float *b, int m, int n)
static float * trchlu(const float *a, float *b, int n)
static float * trsa(const float *s, const float *a, float *b, int m, int n)
static float * mxmad_0_(int n, const float *a, const float *b, float *c, int i, int j, int k)
static float * trsmul(const float *g, float *gi, int n)
#define TCL_TRAAT(a, s, m, n)
static float * trinv(const float *t, float *s, int n)
#define TCL_TRASAT(a, s, r__, m, n)
static float * tratsa(const float *a, const float *s, float *r, int m, int n)
static float * trlta(const float *u, const float *a, float *b, int m, int n)
static float * tras(const float *a, const float *s, float *b, int m, int n)
static float * trsmlu(const float *u, float *s, int n)
static float * trsat(const float *s, const float *a, float *b, int m, int n)
static float * trsequ(float *smx, int m=3, float *b=0, int n=1)
#define TCL_MXTRP(a, b, i, j)
static float * trpck(const float *s, float *u, int n)
static float * mxtrp(const float *a, float *b, int i, int j)
Matrix Transposition CERN PROGLIB# F110 MXTRP .VERSION KERNFOR 1.0 650809 ORIG.
#define TCL_TRAL(a, u, b, m,n)
static float * trupck(const float *u, float *s, int m)
static float * trats(const float *a, const float *s, float *b, int m, int n)
static float * trchul(const float *a, float *b, int n)
static float * trata(const float *a, float *r, int m, int n)
#define TCL_TRAS(a, s, b, m, n)
static int * ucopy(const int *a, int *b, int n)
static float * tral(const float *a, const float *u, float *b, int m, int n)
Triangular - Rectangular Multiplication CERN PROGLIB# F112 TRAL .VERSION KERNFOR 4.15 861204 ORIG.
static float * trasat(const float *a, const float *s, float *r, int m, int n)
#define TCL_TRALT(a, u, b, m, n)
#define TCL_MXMLRT(n__, a, b, c,ni, nj)
static float * tralt(const float *a, const float *u, float *b, int m, int n)
static float * mxmlrt_0_(int n__, const float *a, const float *b, float *c, int ni, int nj)
Matrix Multiplication CERN PROGLIB# F110 MXMLRT .VERSION KERNFOR 2.00 720707 ORIG.
static float * vzero(float *a, int n2)
static float * traat(const float *a, float *s, int m, int n)
static float * trqsq(const float *q, const float *s, float *r, int m)
#define TCL_MXMAD(n_, a, b, c, i, j, k)
static float * trsinv(const float *g, float *gi, int n)
Double_t Sqrt(Double_t x)