Multiply TMatrixD and TVectorD

I have looked at the documentation and i am not exactly clear how I can multiply a mtrix and vector, can somone help? For instance if i had:

TMatrixD * m = TMatrixD(4,4);
m->UnitMatrix();
TVectorD * v = TVectorD(4);
for (Int_t i=0; i<4; i++)
{
v(i)=(Double_t) i;
}

And I wanted to calculate:

m * v = y

(which of course gives y==v) how can i do this?

Thanks

Hi,
I modified your code to make it correct C++ and perform a matrix/vector
multiplication :

{
  TMatrixD *m = new TMatrixD(4,4);
  m->UnitMatrix();
  TVectorD *v = new TVectorD(4);
  for (Int_t i=0; i<4; i++)
  {
    *v(i)=(Double_t) i;
  }
  *v *= *m;
  v->Print();
}

In the latest production version 5.08, also the “*” operator has been
added so that you could also do:

TVectorD v2 = *m * *v;

Eddy

Eddy,

Thanks!!!

(sorry for the syntax errors it was late when I wrote the post :slight_smile: )

Alex