JoshuaJeanThree
JoshuaJeanThree

Reputation: 1392

arithmetic vector operations in Java

I have four vectors have same dimension (1 dimensional) and same size. My vectors are consturcated as:

Vector<Integer> v1=new Vector<Integer>(5);
Vector<Integer> v2=new Vector<Integer>(5);
Vector<Integer> vp=new Vector<Integer>(5);
Vector<Integer> vs=new Vector<Integer>(5);

for example: vp=v1*v2

<1 3 4 1 2>
<0 0 2 2 3>
<0 0 8 2 6>

and vector subtraction also for example vs=1-v1

1-v1= <0 -2 -3 0 -1>

is there any function in java to assign the result of multiplication of vectors to vector "vp" and "vs"?

Upvotes: 2

Views: 2875

Answers (2)

padawan
padawan

Reputation: 1315

You may use vecmath for vector operations. It is very precise. No rounding errors!

Upvotes: 1

NPKR
NPKR

Reputation: 5496

I think there is no API methods provided for this.

It looks like the definiton might change from one to one , we have implement mannually for this.

Upvotes: 0

Related Questions