gpt4 book ai didi

java - Java 中的算术 vector 运算

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:10:55 25 4
gpt4 key购买 nike

我有四个具有相同维度(一维)和相同大小的 vector 。我的载体构造为:

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);

例如:vp=v1*v2

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

还有 vector 减法,例如 vs=1-v1

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

java中有没有函数可以将 vector 相乘的结果赋值给 vector “vp”和“vs”?

最佳答案

您可以使用 vecmath用于 vector 运算。它非常精确。没有舍入错误!

关于java - Java 中的算术 vector 运算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13787411/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com