TMatrixD help

Good Morning,

Please I using TMatrices in my work, Transpose and TMatric division is giving an error. Is there anything I am missing? Thank you for your help. This is the error and the code is attached.

``````root [0]
Processing macro6.C...
In file included from input_line_8:1:
/home/harriet/fair_install/ATTPCROOTv2/build/macro6.C:115:22: error: invalid operands to binary expression ('TMatrixT<double>' and 'TMatrixT<double>')
K =  (P_pred * H_1) / (H_1 * P_pred * H_1 + R_1);
~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
``````
``````void macro6 () {

// using TMATRICES FROM CERN.
//DEfine all matrices

TMatrixD A_1(2,2);
TMatrixD B_1(2,1);
TMatrixD X_1(2,1);
TMatrixD Y_1(2,1);
TMatrixD H_1(2,2);
TMatrixD R_1(2,2);
TMatrixD C_1(2,2);
TMatrixD ax_1(2,1);
TMatrixD P_1(2,2);
TMatrixD Q_1(2,2);

//kalman storage
TMatrixD x_pred(2,1);
TMatrixD P_pred(2,2);
TMatrixD K(2,2);

Int_t n = 100;
Double_t Q, E_Est[n],E_CE[n],E_Mea,KG[n],q,mn[n],C_E[n];
Double_t x[n],dt,w,y[n],ay,v[n];
Double_t dx,dv;
Double_t ax;
//initial values.
dx = 20.0; // meters.
dv = 5; //m/s.
Q = 0.0; // Error in the process.
x[0] = 4000.0; //  Units in meters.
v[0] = 280.0; //    Units in meter/seconds.
ax= 2.0;        //in m/sec².
dt = 1.0;
C_E[0] = 10; // unit in m.
Double_t z[10] = {49.95,49.967,50.10,50.106,49.992,49.819,49.933,50.007,50.023,49.99};  // units in m.

//filling the matrices
Double_t Matrix_A[4] = {1,dt,0,1};
A_1.Use(A_1.GetNrows(), A_1.GetNcols(), Matrix_A);

Double_t Matrix_B[2] = {0.5*TMath::Power(dt,2),dt};
B_1.Use(B_1.GetNrows(), B_1.GetNcols(), Matrix_B);

Double_t Matrix_X[2] = {x[0],v[0]};
X_1.Use(X_1.GetNrows(), X_1.GetNcols(), Matrix_X);

Double_t Matrix_Y[2] ;
Y_1.Use(Y_1.GetNrows(), Y_1.GetNcols(), Matrix_Y);

Double_t Matrix_H[4] = {1,0,0,1} ;
H_1.Use(H_1.GetNrows(), H_1.GetNcols(), Matrix_H);

Double_t Matrix_R[4] ={625,0,0,36};
R_1.Use(R_1.GetNrows(), R_1.GetNcols(), Matrix_R);

Double_t Matrix_C[4] = {1,0,0,1};
C_1.Use(C_1.GetNrows(), C_1.GetNcols(), Matrix_C);
//Double_t ax[2]  = {2.0,0.0};
//ax_1.Use(ax_1.GetNrows(), ax_1.GetNcols(), ax);

Double_t Matrix_P[4] = {TMath::Power(dx,2),0.0,0.0,TMath::Power(dv,2)} ; // generated errors.
P_1.Use(P_1.GetNrows(), P_1.GetNcols(), Matrix_P);

for(Int_t i=0; i<n; i++){

//start kalman

x_pred = (A_1 * X_1) +( (B_1*ax) + Q) ;
P_pred =  A_1 * P_1* Transpose(A_1) + Q;

K =  (P_pred * H_1) / (H_1 * P_pred * H_1 + R_1);
X_1 = x_pred + K *(z[n]*x_pred);
P=(1-K*H_1)*P_pred;
//std::cout<< z[n] << " " << x_pred << std::endl;
}
//std::cout<<Q<<endl;
P_pred.Print();
return 0;

}
``````

``````Processing macro6.C...

In file included from input_line_9:1:

A_1.Use(Matrix_A);

**~~~~^~~**
``````

This works for me but not the transpose and division

``````Double_t Matrix_A[4] = {1,dt,0,1};
A_1.Use(A_1.GetNrows(), A_1.GetNcols(), Matrix_A);
``````

The available arithmetic operations are described in the links given in:

n file included from input_line_8:1:
/home/harriet/fair_install/ATTPCROOTv2/build/macro6.C:106:7: error: use of undeclared identifier ‘Div’
K = Div(TMatrixD(P_pred, TMatrixD::kMultTranspose,H_1) , ((H_1 * TMatrixD(P_pred, TMatrixD::kMultTranspose,H_1)) + R_1));
^

And where do you see “`Div`” in the list of available arithmetic operations?

I saw it here:

Div()

template<class T , unsigned int D, unsigned int D2, class R1 , class R2 >

Expr< BinaryOp< DivOp< T >, SMatrix< T, D, D2, R1 >, SMatrix< T, D, D2, R2 >, T >, T, D, D2, typename AddPolicy< T, D, D2, R1, R2 >::RepType > ROOT::Math::Div ( const SMatrix< T, D, D2, R1 > & lhs,
const SMatrix< T, D, D2, R2 > & rhs
)

“SMatrix” is unrelated to “TMatrix”.

Even here :
Element wise division ElementDiv(A,B) A(i,j)/= B(i,j)

okay I soo confused what can I use please

Use a “linear algebra package” that best suits your needs.