简体   繁体   中英

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"?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM