3
$\begingroup$

I was trying to convert a MATLAB program to C program and i came across a problem where i got stuck. My Matlab program has an equation of the form 'A \ B', where '\' is mldivide in MATLAB. Matrix 'A' = D' * D, where D = nX9 matrix. Hence the matrix 'A' will be a symmetric matrix. Upon solving this and checking the sparse of 'A\B', the MATLAB is displaying,

sp\: bandwidth = 8+1+8.
sp\: is A diagonal? no.
sp\: is band density (1) > bandden (0.5) to try banded solver? yes.
sp\: is LAPACK's banded solver successful? yes.

I wanted to write a C code for banded solver. I checked the LAPACK library but i could not understand on how to use the same. If i make all, then there will be a static library generated, but i do not want to use all the library files, since this code would go on a micro-controller and i do not want unwanted files/libraries. If there is any reference for Banded solver algorithm, so that i can replicate in 'C' program, it would be very helpful.

Matrix 'A' can be any one of the following,

    1.2013    0.2676    0.4950    0.1863    0.0877    0.0738    0.0001   -0.0000   -0.0001
    0.2676    1.0004    0.4776    0.1181    0.0710   -0.0243    0.0000    0.0001   -0.0001
    0.4950    0.4776    1.5497    0.1826    0.0065    0.1060   -0.0000    0.0000   -0.0002
    0.1863    0.1181    0.1826    1.0705    0.1477    0.1420   -0.0000    0.0000   -0.0000
    0.0877    0.0710    0.0065    0.1477    1.9799    0.3652   -0.0001   -0.0000   -0.0000
    0.0738   -0.0243    0.1060    0.1420    0.3652    1.9103   -0.0000   -0.0001    0.0000
    0.0001    0.0000   -0.0000   -0.0000   -0.0001   -0.0000    0.0000    0.0000    0.0000
   -0.0000    0.0001    0.0000    0.0000   -0.0000   -0.0001    0.0000    0.0000    0.0000
   -0.0001   -0.0001   -0.0002   -0.0000   -0.0000    0.0000    0.0000    0.0000    0.0000

or

    1.0891    0.2368    0.4743    0.1291   -0.2816   -0.0688    0.0002    0.0000   -0.0001
    0.2368    0.5177    0.3292    0.0683   -0.0396   -0.0652    0.0000    0.0000   -0.0001
    0.4743    0.3292    1.7228    0.0809   -0.2229    0.0101    0.0000   -0.0000   -0.0003
    0.1291    0.0683    0.0809    0.9471   -0.1376   -0.0792    0.0000    0.0000   -0.0000
   -0.2816   -0.0396   -0.2229   -0.1376    1.8972    0.1617   -0.0001   -0.0000    0.0000
   -0.0688   -0.0652    0.0101   -0.0792    0.1617    1.3168   -0.0000   -0.0001   -0.0000
    0.0002    0.0000    0.0000    0.0000   -0.0001   -0.0000    0.0000    0.0000   -0.0000
    0.0000    0.0000   -0.0000    0.0000   -0.0000   -0.0001    0.0000    0.0000   -0.0000
   -0.0001   -0.0001   -0.0003   -0.0000    0.0000   -0.0000   -0.0000   -0.0000    0.0000

Thanks!

$\endgroup$
  • $\begingroup$ You might want to have a look at the book Matrix Computations by Golub and Van Loan. It will certainly have an algorithm for solving linear systems involving symmetric band matrices. $\endgroup$ – K. Miller Oct 24 '16 at 19:28
  • $\begingroup$ Thank you. Still trying to understand the concepts given in text book. $\endgroup$ – Abhishek G Oct 25 '16 at 4:56
  • $\begingroup$ Can you say any more about $D$. How big is $n$ typically? Does $D$ always have full rank? Does it have any special structure you can exploit? $\endgroup$ – K. Miller Oct 25 '16 at 11:24
  • $\begingroup$ If $D$ has full rank so that $A$ is symmetric positive definite, then I would factorize $A$ by the Cholesky factorization and compute the solution from that. If $A$ is only ever $9\times 9$, I am not sure you need to worry about exploiting any savings that band structure may afford. $\endgroup$ – K. Miller Oct 25 '16 at 13:28
  • $\begingroup$ @K.Miller D would have large number of rows, typically around 3000 to 4000. The rank of D is 9. D is formed by the formula, D = [ x .* x, y .* y, z .* z, 2 * x .* y, 2 * x .* z, 2 * y .* z, 2 * x, 2 * y, 2 * z ]; where x, y, and z are column matrix of size nX1. n might be typically 3000 to 4000. I will try with Cholesky factorization. Thank you ! $\endgroup$ – Abhishek G Oct 25 '16 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.