4#ifndef ROOT_Math_MatrixInversion_icc
5#define ROOT_Math_MatrixInversion_icc
8#error "Do not use MatrixInversion.icc directly. #include \"Math/Dinv.h\" instead."
38template <
unsigned int idim,
unsigned int N>
76 value_type lambda,
sigma;
77 const value_type alpha = .6404;
87 for (i = 0; i <
nrow; i++)
102 for (i=
j+1; i <=
nrow ;
ip += i++)
103 if (std::abs(*
ip) > lambda)
105 lambda = std::abs(*
ip);
121 if (std::abs(*
mjj) >= lambda*alpha)
137 if ( std::abs(*
mjj) >= alpha * lambda * (lambda/
sigma) )
159 for (i=
j+1; i <=
nrow; i++)
162 ip =
rhs.Array()+i*(i-1)/2+
j;
163 for (k=
j+1; k<=i; k++)
165 *
ip -=
static_cast<T
> (
temp1 * *(
rhs.Array() + k*(k-1)/2 +
j-1) );
173 for (i=
j+1; i <=
nrow;
ip += i++)
174 *
ip *=
static_cast<T
> (
temp2 );
185 temp1 = *(
rhs.Array() + i*(i-1)/2 +
j-1);
186 *(
rhs.Array() + i*(i-1)/2 +
j-1)= *
ip;
187 *
ip =
static_cast<T
> (
temp1 );
209 for (i =
j+1; i <=
nrow; i++)
212 ip =
rhs.Array()+i*(i-1)/2+
j;
213 for (k=
j+1; k<=i; k++)
215 *
ip -=
static_cast<T
> (
temp1 * *(
rhs.Array() + k*(k-1)/2 +
j-1) );
223 for (i=
j+1; i<=
nrow;
ip += i++)
224 *
ip *=
static_cast<T
>(
temp2 );
239 *(
rhs.Array() + i*(i-1)/2 +
j) = *
ip;
262 <<
"SymMatrix::bunch_invert: error in pivot choice"
275 for (i=
j+2; i <=
nrow ; i++)
277 ip =
rhs.Array() + i*(i-1)/2 +
j-1;
284 for (k =
j+2; k <= i ; k++)
286 ip =
rhs.Array() + i*(i-1)/2 + k-1;
287 iq =
rhs.Array() + k*(k-1)/2 +
j-1;
294 for (i=
j+2; i <=
nrow ; i++)
296 ip =
rhs.Array() + i*(i-1)/2 +
j-1;
301 + *(
ip+1) * *(
mjj +
j + 1);
325 for (
j =
nrow ;
j >= 1 ;
j -= s)
334 for (i=0; i <
nrow-
j;
ip += 1+
j+i++)
336 for (i=
j+1; i<=
nrow ; i++)
339 ip =
rhs.Array() + i*(i-1)/2 +
j;
340 for (k=0; k <= i-
j-1; k++)
344 *(
rhs.Array()+ i*(i-1)/2 +
j-1) =
static_cast<T
>( -
temp2 );
348 for (k=0; k <
nrow-
j;
ip += 1+
j+k++)
356 std::cerr <<
"error in piv" <<
piv[
j-1] << std::endl;
361 for (i=0; i <
nrow-
j;
ip += 1+
j+i++)
363 for (i=
j+1; i<=
nrow ; i++)
366 ip =
rhs.Array() + i*(i-1)/2 +
j;
367 for (k=0; k <= i-
j-1; k++)
371 *(
rhs.Array()+ i*(i-1)/2 +
j-1) =
static_cast<T
>( -
temp2 );
375 for (k=0; k <
nrow-
j;
ip += 1+
j+k++)
380 for (i=
j+1; i <=
nrow;
ip += i++)
382 *(
mjj-1) -=
static_cast<T
>(
temp2 );
384 for (i=0; i <
nrow-
j;
ip += 1+
j+i++)
386 for (i=
j+1; i <=
nrow ; i++)
389 ip =
rhs.Array() + i*(i-1)/2 +
j;
390 for (k=0; k <= i-
j-1; k++)
394 *(
rhs.Array()+ i*(i-1)/2 +
j-2)=
static_cast<T
>( -
temp2 );
398 for (k=0; k <
nrow-
j;
ip += 1+
j+k++)
411 temp1 = *(
rhs.Array() + i*(i-1)/2 +
j-1);
412 *(
rhs.Array() + i*(i-1)/2 +
j-1) = *
ip;
445template <
unsigned int idim,
unsigned int n>
449 if (
idim !=
n)
return -1;
455 typedef T value_type;
460 value_type
g1 = 1.0e-19,
g2 = 1.0e19;
466 const value_type epsilon = 0.0;
472 int normal = 0,
imposs = -1;
480 for (
unsigned int j=1;
j<=
n;
j++) {
482 p = (std::abs(*
mjj));
485 for (
unsigned int i=
j+1;i<=
n;i++) {
486 q = (std::abs(*(
mij)));
505 for (
unsigned int l=1;
l<=
n;
l++) {
508 *(
mkl++) =
static_cast<T
>(
tf);
534 for (k=
j+1;k<=
n;k++) {
542 for (
unsigned int i=1;i<
j;i++) {
543 s11 += (*mik) * (*(
mji++));
544 s12 += (*mijp) * (*(
mki++));
550 *(
mjk++) =
static_cast<T
>( -
s11 * (*
mjj) );
575template <
unsigned int idim,
unsigned int n>
582 typedef T value_type;
586 if (
idim !=
n)
return -1;
596 *
m21 = -(*m22) * (*m11) * (*m21);
602 for (
unsigned int i=3;i<=
n;i++) {
603 unsigned int im2 = i - 2;
607 for (
unsigned int j=1;
j<=
im2;
j++) {
614 for (
unsigned int k=
j;k<=
im2;k++) {
615 s31 += (*mkj) * (*(
mik++));
620 *
mij =
static_cast<T
>( -(*mii) * (((*(
mij-
n)))*( (*(
mii-1)))+(
s31)) );
621 *
mji =
static_cast<T
> ( -
s32 );
626 *(
mii-1) = -(*
mii) * (*mimim) * (*(
mii-1));
635 for (
unsigned int i=1;i<
n;i++) {
636 unsigned int ni =
n - i;
639 for (
unsigned j=1;
j<=i;
j++) {
648 *(
mij++) =
static_cast<T
> (
s33 );
650 for (
unsigned j=1;
j<=
ni;
j++) {
654 for (
unsigned int k=
j;k<=
ni;k++) {
664 if (
nxch==0)
return 0;
665 for (
unsigned int mm=1;mm<=
nxch;mm++) {
666 unsigned int k =
nxch - mm + 1;
672 for (k=1; k<=
n;k++) {
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
static void InvertBunchKaufman(MatRepSym< T, idim > &rhs, int &ifail)
Bunch-Kaufman method for inversion of symmetric matrices.
static int DfactMatrix(MatRepStd< T, idim, n > &rhs, T &det, unsigned int *work)
LU Factorization method for inversion of general square matrices (see implementation in Math/MatrixIn...
static int DfinvMatrix(MatRepStd< T, idim, n > &rhs, unsigned int *work)
LU inversion of general square matrices.
MatRepSym Matrix storage representation for a symmetric matrix of dimension NxN This class is a templ...
const_iterator begin() const
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...