linear algebra - LAPACK + C, weird behaviour -


I am trying to solve a simple linear equation system using LAPACK. I use the dbsvg method which is optimized for banded matrix. I have violated a real strange behavior when I fill the matrix like this:

 for  (i = 0 ; I & lt; dim; i ++) AB [0] [i] = -1; For (i = 0; i & lt; dim; i ++) AB [1] [i] = 2; For (i = 0; i & lt; dim; i ++) AB [2] [ii] = -1; For (i = 0; i & lt; 3; i ++) (j = 0; j & lt; dim; j ++) {at [i * dim + j] = ab [i] [j ]; }  

and call:

  dgbsv _ (& amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; ; Amp;;; U; and; NRHS, AT, & LDAB, myIviv, X, and LDB, and INFO);  

This works perfectly, however, when I do this:

  for (i = 0; i  

This is the result with a vector filled with Nayen. Here are the announcements:

  Double AB [3] [DIM], AT [3 * DIM]; Double X [DIM]; Int'myyipiv [DIM]; Int N = DIM, KL = 1, KU = 1, NRHS = 1, LDAB = DIM, LDB = DIM, information;  

Any ideas?

You are not laying out the entries in the band storage properly; It was working before a happy accident says:

  On entry, band storage in matrix A, KL + 1 to 2 * KL + KU + 1; The array 1 of the array does not require a KL set. The AJ-J column is stored in the J-th column of the array AB: A (I, J) for AB (KL + Ku + 1 + EJ, J) = Max (1, J-Ku) Lt; = I & lt; = Min (N, J + KL) on exit, details of dispersion: U is stored as an upper triangular band matrix with KL + Ku supdrenal in LAL1 KL + Ku + 1, and multiplier filtration. The lines are reserved in KL + KU + 2 to 2 * KL + KU + 1 See below for more information.  

So if you want the diagonal and the triadier matrix with 1 up and down 2, then the layout should be:

 < Code> * * * * * * * * * * * * -1 -1 -1 -1 -1 -1 ... -1 -1 -1 -1 2 2 2 2 2 2 2 .. 2 2 2 -1 -1 -1 -1 -1 -1 -1; -1 -1 -1 *  

In this case LDAB should be 4. Keep in mind that LAPACK uses a column-head layout, so the actual array should look like this in memory:

  {*, *, 2.0, -1.0, *, -1.0 , 2.0, -1.0, *, -1.0, 2.0, -1.0, ...}  

dgbsv giving different results for two identical arrays Was because it was reading


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -