Search code examples
javavectorarithmetic-expressions

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


Solution

  • 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.