我试图了解如何存储带矩阵,我在“C++ 和面向对象的数值计算”一书中找到了一个示例,但我无法弄清楚bda[i] += P;行的目的是什么 这在尝试打印带状矩阵时也给我带来了问题。这里是:
int N = 5; //Matrix of NxN
int P = 1; //Left bandwidth
int R = 2; //Right bandwidth
//Matrix A
double A[5][5] = { { 1, 6, 10, 0, 0 },
{ 13, 2, 0, 11, 0 },
{ 0, 14, 3, 8, 12 },
{ 0, 0, 0, 4, 9 },
{ 0, 0, 0, 16, 5 } };
//Allocate memory for rows
double** bda = new double*[N];
for (int i = 0; i < N; i++) {
bda[i] = new double[P + R + 1]; //Allocate memory for cols
bda[i] += P; //What's the purpose of this?
}