0

I want to multiply two vectors a^T = (1,2,3) and b = (4,5,6). With pen and pencil, I got

c = 1*4 + 2*5 + 3*6 = 4 + 10 + 18 = 32

With apache commons math3 I do

ArrayRealVector a = new ArrayRealVector(new double []{1, 2, 3});
ArrayRealVector b = new ArrayRealVector(new double []{4, 5, 6});

to get a representation of the vectors. And to get the result I want to do something like

double c = a.transpose().multiply(b);

but I can't find the right method for it (Wether transpose nor multiply).

Cœur
  • 37,241
  • 25
  • 195
  • 267
waXve
  • 792
  • 2
  • 9
  • 30

1 Answers1

2

This is the dot product, which you can do with double c = a.dotProduct(b);

Sean
  • 3,002
  • 1
  • 26
  • 32