# Re: valarray, scalar product

From: Otto Schaile <Otto.Schaile_at_Physik.uni-muenchen.de>
Date: Thu, 27 Oct 2005 16:47:55 +0200

Hi all.
this work for me:

```root [0] Double_t x[2] = { 2,2}
root [1] Double_t y[2] = { 2,2}
root [2] TVectorD vx(2,x);
root [3] TVectorD vy(2,y);
root [4] vx*vy
(Double_t)8.00000000000000000e+00

```

Cheers
Otto

Maxim Nikulin wrote:
> Dear Tomasz,
>
> You wrote:
>

```>>
>> Have a look at TVectorD if you meant multiplication of numbers.
```

>
>
> I've done it already. Unfortunately I can't find an appropriate function
> or an operator.
>
> Double_t operator* (const TVectorD &source1,const TVectorD &source2);
>
> and other operators are suitable for linear algebra operations but not
> in my case. There are some methods similar to std::valarray operators
>
> void TVectorD::AddSomeConstant(Double_t val, const TVectorD& select);
> TVectorD& TVectorD::Sqr();
> TVectorD& TVectorD::Sqrt();
> TVectorD& TVectorD::Invert(); // can be used instead of operator/()
>
> However I don't see per element multiplication. Could you point me to
> the method producing the vector c as shown below
>
> TVectorD a,b;
> TVectorD c(a.GetNrows());
> for (UInt_t i = 0; i < c.GetNrows(); ++i) {
> c[i] = a[i]*b[i];
> }
>
> I'm really sorry if I missed it in the reference.
>
```--
Dr. Otto Schaile            Department f"ur Physik, LMU M"unchen
Phone: +49 89 289 14070     Am Coulombwall 1, D-85748 Garching, Germany
Mobil: +49 160 1553598
FAX:   +49 89 289 14072     EMail: Otto.Schaile_at_Physik.Uni-Muenchen.DE
```
Received on Thu Oct 27 2005 - 16:48:01 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:13 MET