我有一个 while 循环,在其中我使用 Matrix A、向量B和x不同的维度:
int count=0;
while(true){
count+=1;
MatrixXd A(count,2*count);
VectorXd B(2*count);
// assignment of A, and B
//
VectorXd x = A.householderQr().solve(B);
// output of x
if (x.norm()>30)
break;
}
然而,以这种方式构建的程序总是崩溃。我尝试使用指向此类矩阵或向量的指针,并遇到了类似的失败。
我该如何处理这样的问题?