简体   繁体   中英

Segmentation fault when using dpbtrf

I try to use the LAPACK routine dpbtrf ( Documentaton ) in c++ but always get a segmentation fault. I am not sure how to pass the matrix LAPACKE_dpbtrf and tried to replicate it from the few examples I found without success. How to make the code below work?

I want to compute the cholesky decomposition of the matrix

   1 -0.9    0    0    0
-0.9 1.81 -0.9    0    0
   0 -0.9 1.81 -0.9    0
   0    0 -0.9 1.81 -0.9
   0    0    0 -0.9 1.81

Here is what I tried:

#include<iostream>
#include<lapacke.h>


int main() {
    lapack_int info;
    lapack_int N = 5;
    lapack_int KD = 1; 
    lapack_int LDAB = KD + 1;

    double AB[N * KD] = {
     1, 1.81, 1.81, 1.81, 1.81, 
     -0.9, -0.9, -0.9, -0.9, -0.9
    };


    info = LAPACKE_dpbtrf( LAPACK_COL_MAJOR, 'L', N, KD, AB, LDAB);


    for(int i=0;i<N * KD; i++)
   {
         std::cout << AB[i] << std::endl;

   }

    return(info);

}

Seems like you don't have the proper dimensions for AB . According to the documentation, the size is (LDAB,N), not (KD,N).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM