13 #ifndef _USE_ROOT_TMATRIX_
73 memset(
this, 0x00,
sizeof(
KfMatrix));
79 #ifdef _USE_ROOT_TMATRIX_
81 mMtx =
new TMatrixD(
mDim1, mDim2);
86 memset(
mArr, 0x00,
mDim*
sizeof(
double));
94 #ifdef _USE_ROOT_TMATRIX_
95 if (mMtx)
delete mMtx;
107 if (!kfm2)
return -1;
135 int din1[2], din2[2];
138 if (!in1 || !in2)
return -1;
146 if (
mDim1 != din1[0] || din1[1] != din2[0] || din2[1] !=
mDim2)
return -1;
162 for(mring=buffer; mring; mring=mring->
next)
173 for(mring=buffer; mring; mring=mring->
next) {
185 btail = &mring->
next;
199 if (!buffer)
return NULL;
211 #ifdef _USE_ROOT_TMATRIX_
214 for(
int ii=0; ii<
mDim1; ii++)
215 for(
int ik=0; ik<
mDim2; ik++)
226 for(
int ii=0; ii<
mDim1; ii++)
227 for(
int ik=0; ik<
mDim1; ik++)
228 KFM(ii,ik) = ii == ik ? 1. : 0.;
240 if (in ==
this)
return 0;
244 #ifdef _USE_ROOT_TMATRIX_
247 for(
unsigned ii=0; ii<in->
mDim1; ii++)
248 for(
unsigned ik=0; ik<in->
mDim2; ik++)
249 KFM(ii,ik) = in->
KFM(ii,ik);
259 #define _KF_MATRIX_ADD_ 0
260 #define _KF_MATRIX_SUBTRACT_ 1
268 #ifdef _USE_ROOT_TMATRIX_
270 *mMtx = *in1->mMtx + *in2->mMtx;
272 *mMtx = *in1->mMtx - *in2->mMtx;
276 for(
unsigned ii=0; ii<in1->
mDim1; ii++)
277 for(
unsigned ik=0; ik<in1->
mDim2; ik++)
278 KFM(ii,ik) = in1->
KFM(ii,ik) + in2->
KFM(ii,ik);
280 for(
unsigned ii=0; ii<in1->
mDim1; ii++)
281 for(
unsigned ik=0; ik<in1->
mDim2; ik++)
282 KFM(ii,ik) = in1->
KFM(ii,ik) - in2->
KFM(ii,ik);
328 #ifdef _USE_ROOT_TMATRIX_
331 *mMtx = cff * *in->mMtx;
333 for(
unsigned ii=0; ii<in->
mDim1; ii++)
334 for(
unsigned ik=0; ik<in->
mDim2; ik++)
335 KFM(ii,ik) = cff*in->
KFM(ii,ik);
357 #ifdef _USE_ROOT_TMATRIX_
358 assert(!(trans1 && trans2));
361 *mMtx = *in1->mMtx * *in2->mMtx;
363 case _TRANSPOSE_IN1_:
364 *mMtx = TMatrixD(TMatrixD::kTransposed, *in1->mMtx) * *in2->mMtx;
366 case _TRANSPOSE_IN2_:
367 *mMtx = *in1->mMtx * TMatrixD(TMatrixD::kTransposed, *in2->mMtx);
372 if (
this == in1) tin1 = in1->
Bufferize();
374 if (
this == in2) tin2 = (in2 == in1) ? tin1 : in2->
Bufferize();
379 int qdim = trans1 ? tin1->
mDim1 : tin1->
mDim2;
381 for(
int ii=0; ii<
mDim1; ii++)
382 for(
int ip=0;
ip<qdim;
ip++)
383 for(
int ik=0; ik<
mDim2; ik++)
385 double val1 = trans1 ? tin1->
KFM(
ip,ii) : tin1->
KFM(ii,
ip);
386 double val2 = trans2 ? tin2->KFM(ik,
ip) : tin2->KFM(
ip,ik);
399 int ret, nl, nr, dim1, dim2, dim3, dim4;
411 nl = dim1*dim2*dim3 + dim1*dim3*dim4;
412 nr = dim2*dim3*dim4 + dim1*dim2*dim4;
435 ret = buffer->
SetToProduct(in2, in3, (trans2 | trans3) >> 1);
471 if (lsqr) *lsqr = value->
KFM(0,0);
500 double a[2][2] = {{
KFM(0,0),
KFM(0,1)}, {
KFM(1,0),
KFM(1,1)}};
501 double det = a[0][0]*a[1][1] - a[0][1]*a[1][0];
508 KFM(0,0) = a[1][1]/det;
509 KFM(0,1) = -a[0][1]/det;
510 KFM(1,0) = -a[1][0]/det;
511 KFM(1,1) = a[0][0]/det;
517 #ifdef _USE_ROOT_TMATRIX_
529 TMatrixD bff; bff.Use(mDim1, mDim1, arr.GetArray());
547 for(
int iq=0; iq<
mDim2; iq++)
562 printf(
"Non-positive diagonal element: %20.15f\n",
KFM(
ip,
ip));
568 for(
int iq=0; iq<
mDim2; iq++)
583 for(
int iq=0; iq<
mDim1; iq++) {
584 if (
ip == iq)
continue;
600 if (
KFM(
ip,
ip) <= 0.)
return -1;
603 for(
int iq=0; iq<
mDim1; iq++) {
604 if (
ip == iq)
continue;
615 double positivityCorrelationFix)
619 if (
KFM(
ip,
ip) <= 0.)
return -1;
623 for(
int iq=0; iq<
GetDim1(); iq++) {
624 if (
ip == iq)
continue;
632 if (corr > maxFixablePositivityScrewup) {
641 sqrt(limit*positivityCorrelationFix);