我試圖尋找與該主題相關的類似螺紋的工資制度,但似乎沒有人關心帶狀系統(...)解決由C使用LAPACK的DGBSV
我感興趣解決一個殺雞取卵矩陣使用來自C代碼的LAPACK/ScaLAPACK。首先,我想在使用ScaLAPACK之前嘗試使用LAPACK來實現順序解決方案。
問題:兩種語言之間的行 - 主/列 - 主要差異似乎影響我的解決過程。這裏我打算解決系統:
下面的代碼,該轉換矩陣進LAPACK的帶狀的數據結構,在here指定。
int rr = 6; // Rank.
int kl = 2; // Number of lower diagonals.
int ku = 1; // Number of upper diagonals.
int nrhs = 1; // Number of RHS.
double vals[36] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, // Req. ex. space.
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, // Req. ex. space.
666.0, 0.0, 0.0, 0.0, 0.0, 22.5, // First up diag.
1.0, -50.0, -50.0, -50.0, -50.0, -2.6, // Main diagonal.
27.5, 27.5, 27.5, 27.5, 4.0, 666.0, // First low diag.
0.0, 0.0, 0.0, -1.0, 666.0, 666.0}; // 2nd low diag.
int lda = rr; // Leading dimension of the matrix.
int ipiv[6]; // Information on pivoting array.
double rhs[] = {1.0, 1.0, 1.0, 1.0, 1.0, 0.0}; // RHS.
int ldb = lda; // Leading dimension of the RHS.
int info = 0; // Evaluation variable for solution process.
int ii; // Iterator.
int jj; // Iterator.
dgbsv_(&rr, &kl, &ku, &nrhs, vals, &lda, ipiv, rhs, &ldb, &info);
printf("info = %d\n", info);
for (ii = 0; ii < ldb; ii++) {
printf("%f\n", rhs[ii]);
}
putchar('\n');
正如我所說的,我很擔心,我翻譯我的矩陣的方式不正確,給出的COL-主要性質,以及Fortran語言的索引性質,因爲我的解決方案,得到:
[[email protected] lapack-ex02]$ make runs
`pwd`/blogs < blogs.in
info = 1
1.000000
1.000000
1.000000
1.000000
1.000000
0.000000
從Fortran語言info = 1
的返回值意味着分解完成,但在A = LU
的LU分解U(1,1) = 0
。
任何幫助都是值得歡迎的。
感謝先進!
有什麼辦法,我可以把這個作爲解決?我其實有一個功能正常的代碼! :d – Eduardo 2013-03-20 22:27:19