我有一个MathMatrix类的成员函数,它扩展了ArrayList< ArrayList<双> >
public void LUFactPivoting(MathMatrix l, MathMatrix u) throws LUException, CloneNotSupportedException {
double [] Parray = {1,2,3,4};
P = new MathVector(Parray);
MathMatrix temp = new MathMatrix(this);
int n = ncols;
double mult;
for (int k = 0; k < n; k++) {
System.out.println("TEMP: " + u.toString());
this.partialPivotingStep(l, temp, k);
for (int i = k + 1; i < n; i++) {
if(temp.getElem(k, k) == 0) System.out.println("ZERO");
mult = temp.getElem(i, k) / temp.getElem(k, k);
l.setElem(i, k, mult);
for (int j = k; j < n; j++) {
double newval = temp.getElem(i, j) - mult * temp.getElem(k, j);
temp.setElem(i, j, newval);
}
}
}
for (int i = 0; i < n; i++) {
l.setElem(i, i, 1.0);
}
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
u.setElem(i, j, temp.getElem(i, j));
}
}
}
我正在使用ArrayList.set()
但是当我调用this.partialPivotingStep(l, temp, k)
时对象没有得到更新,所以当我将它作为参数传递时,对象temp保持与初始化相同(但是当我使用时它会改变它在LUFactPivoting
范围内)。有什么问题?